From 70febafc03a877fe0650a1b7e57faf0d5829bd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Escalera=20Garc=C3=ADa?= Date: Mon, 8 Apr 2024 12:32:49 +0200 Subject: [PATCH 1/2] d01 --- tests/e2e/youtube-trends.spec.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/youtube-trends.spec.cjs b/tests/e2e/youtube-trends.spec.cjs index db23dce..2cd63d5 100644 --- a/tests/e2e/youtube-trends.spec.cjs +++ b/tests/e2e/youtube-trends.spec.cjs @@ -1,7 +1,7 @@ // @ts-check const { test, expect } = require('@playwright/test'); -//---------------Verifica si la página tiene un título esperado--------------- +//---------------Verifica si la página tiene un título esperado---------------- test('tiene título', async ({ page }) => { await page.goto('http:/sos2324-14.appspot.com'); From b1f23f350f21f79fbc4d8263bedd0f850ccf1933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Escalera=20Garc=C3=ADa?= Date: Mon, 8 Apr 2024 14:27:55 +0200 Subject: [PATCH 2/2] d02 final --- front/src/routes/movies-dataset/+page.svelte | 204 +++++++++++++++++-- playwright.config.cjs | 8 +- tests/e2e/events.spec.cjs | 78 +++++++ tests/e2e/movies-dataset.spec.cjs | 78 +++++++ tests/e2e/youtube-trends.spec.cjs | 10 +- tests/integration/apiNRM-gcloud.json | 68 +++---- 6 files changed, 386 insertions(+), 60 deletions(-) create mode 100644 tests/e2e/events.spec.cjs create mode 100644 tests/e2e/movies-dataset.spec.cjs diff --git a/front/src/routes/movies-dataset/+page.svelte b/front/src/routes/movies-dataset/+page.svelte index f7d4ac6..2da3a1b 100644 --- a/front/src/routes/movies-dataset/+page.svelte +++ b/front/src/routes/movies-dataset/+page.svelte @@ -1,16 +1,30 @@ @@ -112,26 +243,46 @@ {#if movies.length == 0}

La lista está vacía

Para insertar datos pulsa este botón ->

+ {:else} + + Búsqueda por campos + + + + {#each camposPelicula as campo} + + {/each} + + + + + + + + {/if}
- + {#each movies as movie} - {movie.original_title} + {movie.index+1}. {movie.original_title} Director: {movie.director}, Estreno: {movie.release_date} - + +
+ +
+
{/each}
- {#if !movies.length == 0} Añade una nueva película @@ -139,5 +290,24 @@ Eliminar la coleccion + {#if listaPags.length != 0} + + + + + + + {#each listaPags as pagina} + + {pagina} + + {/each} + + + + + + + {/if} {/if}
\ No newline at end of file diff --git a/playwright.config.cjs b/playwright.config.cjs index 3f030e8..ea072f8 100644 --- a/playwright.config.cjs +++ b/playwright.config.cjs @@ -38,10 +38,10 @@ module.exports = defineConfig({ use: { ...devices['Desktop Chrome'] }, }, - { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - }, + //{ + // name: 'firefox', + // use: { ...devices['Desktop Firefox'] }, + //}, //{ // name: 'webkit', diff --git a/tests/e2e/events.spec.cjs b/tests/e2e/events.spec.cjs new file mode 100644 index 0000000..3420b1a --- /dev/null +++ b/tests/e2e/events.spec.cjs @@ -0,0 +1,78 @@ +// @ts-check +const { test, expect } = require('@playwright/test'); + +//---------------Verifica si la página tiene un título esperado--------------- +test('tiene título', async ({ page }) => { + await page.goto('http://localhost:10002/ufc-events-data'); + + // Espera que el título "contenga" una subcadena. + await expect(page).toHaveTitle(/APIs Grupo 14/); +}); + +/* +//---------------Verifica la funcionalidad de carga de datos iniciales--------------- +test('cargar datos iniciales', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Haz clic en el botón "Cargar Datos Iniciales" + await page.click('button:text("Rellenar")'); + + // Espera a que aparezca el mensaje de éxito después de cargar los datos iniciales + await page.waitForSelector('.alert', { timeout: 5000 }); // Espera a que aparezca cualquier elemento con la clase .alert + const successMsg = await page.textContent('.alert'); + + // Verifica si el mensaje de éxito contiene el texto esperado + expect(successMsg).toContain('Exito Datos iniciales cargados con exito.'); +}); + +//---------------Verifica la funcionalidad de búsqueda--------------- +test('funcionalidad de búsqueda', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Ingresa un término de búsqueda y espera que la lista se actualice + await page.fill('input[id="campoBusqueda"]', 'index'); + await page.fill('input[id="valorBusqueda"]', '1'); + await page.click('button:class("buscarCampo")'); + + // Espera que al menos haya un elemento en la lista de videos después de la búsqueda + await page.waitForSelector('.movieList'); + const videos = await page.$$('.movieList'); + expect(videos.length).toBeGreaterThanOrEqual(1); +}); + +//---------------Verifica la funcionalidad de paginación--------------- +test('funcionalidad de paginación', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Espera que los botones de paginación estén presentes + await page.waitForSelector('PaginationLink'); + + // Haz clic en el botón "Página Siguiente" + await Promise.all([ + page.click('PaginationLink:class("SiguientePag")'), + page.waitForSelector('.movieList', { timeout: 30000 }), // Espera a que la lista de videos se actualice con la página siguiente + ]); + + // Haz clic en el botón "Página Anterior" + await page.click('PaginationLink:class("AnteriorPag")'); + + // Espera a que la lista de videos se actualice con la página anterior + await page.waitForSelector('.movieList', { timeout: 30000 }); +}); + +//---------------Verifica la funcionalidad del botón "Borrar todo"--------------- +test('funcionalidad "Borrar todo"', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Haz clic en el botón "Borrar todo" + await page.click('button:text("Borrar Todo")'); + + // Espera a que se procese la eliminación de todos los datos + await page.waitForTimeout(2000); + + // Verifica que la lista de videos esté vacía después de borrar todo + const videos = await page.$$('.movieList'); + expect(videos.length).toBe(0); +}); + +*/ \ No newline at end of file diff --git a/tests/e2e/movies-dataset.spec.cjs b/tests/e2e/movies-dataset.spec.cjs new file mode 100644 index 0000000..00f24d2 --- /dev/null +++ b/tests/e2e/movies-dataset.spec.cjs @@ -0,0 +1,78 @@ +// @ts-check +const { test, expect } = require('@playwright/test'); + +//---------------Verifica si la página tiene un título esperado--------------- +test('tiene título', async ({ page }) => { + await page.goto('http://localhost:10002/movies-dataset'); + + // Espera que el título "contenga" una subcadena. + await expect(page).toHaveTitle(/APIs Grupo 14/); +}); + +/* +//---------------Verifica la funcionalidad de carga de datos iniciales--------------- +test('cargar datos iniciales', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Haz clic en el botón "Cargar Datos Iniciales" + await page.click('button:text("Rellenar")'); + + // Espera a que aparezca el mensaje de éxito después de cargar los datos iniciales + await page.waitForSelector('.alert', { timeout: 5000 }); // Espera a que aparezca cualquier elemento con la clase .alert + const successMsg = await page.textContent('.alert'); + + // Verifica si el mensaje de éxito contiene el texto esperado + expect(successMsg).toContain('Exito Datos iniciales cargados con exito.'); +}); + +//---------------Verifica la funcionalidad de búsqueda--------------- +test('funcionalidad de búsqueda', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Ingresa un término de búsqueda y espera que la lista se actualice + await page.fill('input[id="campoBusqueda"]', 'index'); + await page.fill('input[id="valorBusqueda"]', '1'); + await page.click('button:class("buscarCampo")'); + + // Espera que al menos haya un elemento en la lista de videos después de la búsqueda + await page.waitForSelector('.movieList'); + const videos = await page.$$('.movieList'); + expect(videos.length).toBeGreaterThanOrEqual(1); +}); + +//---------------Verifica la funcionalidad de paginación--------------- +test('funcionalidad de paginación', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Espera que los botones de paginación estén presentes + await page.waitForSelector('PaginationLink'); + + // Haz clic en el botón "Página Siguiente" + await Promise.all([ + page.click('PaginationLink:class("SiguientePag")'), + page.waitForSelector('.movieList', { timeout: 30000 }), // Espera a que la lista de videos se actualice con la página siguiente + ]); + + // Haz clic en el botón "Página Anterior" + await page.click('PaginationLink:class("AnteriorPag")'); + + // Espera a que la lista de videos se actualice con la página anterior + await page.waitForSelector('.movieList', { timeout: 30000 }); +}); + +//---------------Verifica la funcionalidad del botón "Borrar todo"--------------- +test('funcionalidad "Borrar todo"', async ({ page }) => { + await page.goto('http://localhost:5173/movies-dataset'); + + // Haz clic en el botón "Borrar todo" + await page.click('button:text("Borrar Todo")'); + + // Espera a que se procese la eliminación de todos los datos + await page.waitForTimeout(2000); + + // Verifica que la lista de videos esté vacía después de borrar todo + const videos = await page.$$('.movieList'); + expect(videos.length).toBe(0); +}); + +*/ \ No newline at end of file diff --git a/tests/e2e/youtube-trends.spec.cjs b/tests/e2e/youtube-trends.spec.cjs index 2cd63d5..d028c70 100644 --- a/tests/e2e/youtube-trends.spec.cjs +++ b/tests/e2e/youtube-trends.spec.cjs @@ -3,7 +3,7 @@ const { test, expect } = require('@playwright/test'); //---------------Verifica si la página tiene un título esperado---------------- test('tiene título', async ({ page }) => { - await page.goto('http:/sos2324-14.appspot.com'); + await page.goto('http:/localhost:10002'); // Espera que el título "contenga" una subcadena. await expect(page).toHaveTitle(/APIs Grupo 14/); @@ -11,7 +11,7 @@ test('tiene título', async ({ page }) => { //---------------Verifica la funcionalidad de carga de datos iniciales--------------- test('cargar datos iniciales', async ({ page }) => { - await page.goto('http:/sos2324-14.appspot.com/youtube-trends'); + await page.goto('http:/localhost:10002/youtube-trends'); // Haz clic en el botón "Cargar Datos Iniciales" await page.click('button:text("Cargar Datos Iniciales")'); @@ -26,7 +26,7 @@ test('cargar datos iniciales', async ({ page }) => { //---------------Verifica la funcionalidad de búsqueda--------------- test('funcionalidad de búsqueda', async ({ page }) => { - await page.goto('http:/sos2324-14.appspot.com/youtube-trends'); + await page.goto('http:/localhost:10002/youtube-trends'); // Ingresa un término de búsqueda y espera que la lista se actualice await page.fill('input[type="text"]', 'Prueba'); @@ -40,7 +40,7 @@ test('funcionalidad de búsqueda', async ({ page }) => { //---------------Verifica la funcionalidad de paginación--------------- test('funcionalidad de paginación', async ({ page }) => { - await page.goto('http:/sos2324-14.appspot.com/youtube-trends'); + await page.goto('http:/localhost:10002/youtube-trends'); // Espera que los botones de paginación estén presentes await page.waitForSelector('button'); @@ -60,7 +60,7 @@ test('funcionalidad de paginación', async ({ page }) => { //---------------Verifica la funcionalidad del botón "Borrar todo"--------------- test('funcionalidad "Borrar todo"', async ({ page }) => { - await page.goto('http:/sos2324-14.appspot.com/youtube-trends'); + await page.goto('http:/localhost:10002/youtube-trends'); // Haz clic en el botón "Borrar todo" await page.click('button:text("Borrar todo")'); diff --git a/tests/integration/apiNRM-gcloud.json b/tests/integration/apiNRM-gcloud.json index c66196b..57f9a33 100644 --- a/tests/integration/apiNRM-gcloud.json +++ b/tests/integration/apiNRM-gcloud.json @@ -25,7 +25,7 @@ "method": "GET", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/loadInitialData", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/loadInitialData", "protocol": "https", "host": [ "sos2324-14", @@ -34,7 +34,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "loadInitialData" ] @@ -73,7 +73,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data", "protocol": "https", "host": [ "sos2324-14", @@ -82,7 +82,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data" ] } @@ -117,7 +117,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/", "protocol": "https", "host": [ "sos2324-14", @@ -126,7 +126,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "" ] @@ -162,7 +162,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data", "protocol": "https", "host": [ "sos2324-14", @@ -171,7 +171,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data" ] } @@ -206,7 +206,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data", "protocol": "https", "host": [ "sos2324-14", @@ -215,7 +215,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data" ] } @@ -241,7 +241,7 @@ "method": "GET", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/Lightweight", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/Lightweight", "protocol": "https", "host": [ "sos2324-14", @@ -250,7 +250,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "Lightweight" ] @@ -277,7 +277,7 @@ "method": "DELETE", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/Welterweight", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/Welterweight", "protocol": "https", "host": [ "sos2324-14", @@ -286,7 +286,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "Welterweight" ] @@ -323,7 +323,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", "protocol": "https", "host": [ "sos2324-14", @@ -332,7 +332,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "stats", "Arman%20Tsarukyan", @@ -362,7 +362,7 @@ "method": "GET", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/Welterweight", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/Welterweight", "protocol": "https", "host": [ "sos2324-14", @@ -371,7 +371,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "Welterweight" ] @@ -407,7 +407,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/Welterweight", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/Welterweight", "protocol": "https", "host": [ "sos2324-14", @@ -416,7 +416,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "Welterweight" ] @@ -453,7 +453,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", "protocol": "https", "host": [ "sos2324-14", @@ -462,7 +462,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "stats", "Arman%20Tsarukyan", @@ -493,7 +493,7 @@ "method": "GET", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", "protocol": "https", "host": [ "sos2324-14", @@ -502,7 +502,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "stats", "Arman%20Tsarukyan", @@ -533,7 +533,7 @@ "method": "DELETE", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", "protocol": "https", "host": [ "sos2324-14", @@ -542,7 +542,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "stats", "Arman%20Tsarukyan", @@ -573,7 +573,7 @@ "method": "GET", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", "protocol": "https", "host": [ "sos2324-14", @@ -582,7 +582,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "stats", "Arman%20Tsarukyan", @@ -613,7 +613,7 @@ "method": "DELETE", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data/stats/Arman%20Tsarukyan/Beneil%20Dariush/2-Dec-23", "protocol": "https", "host": [ "sos2324-14", @@ -622,7 +622,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data", "stats", "Arman%20Tsarukyan", @@ -661,7 +661,7 @@ } }, "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data", "protocol": "https", "host": [ "sos2324-14", @@ -670,7 +670,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data" ] } @@ -696,7 +696,7 @@ "method": "DELETE", "header": [], "url": { - "raw": "https://sos2324-14.appspot.com/api/v1/ufc-events-data", + "raw": "https://sos2324-14.appspot.com/api/v2/ufc-events-data", "protocol": "https", "host": [ "sos2324-14", @@ -705,7 +705,7 @@ ], "path": [ "api", - "v1", + "v2", "ufc-events-data" ] }