-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { expect, Page, test } from '@playwright/test' | ||
|
||
test('flujo principal: buscamos un país y al hacer click nos dirige a la página con la información de dicho país', async ({ | ||
page | ||
}) => { | ||
async function irAPaisYVolver(page: Page, codigoPais: string, nombrePais: string) { | ||
const unPais = await page.getByTestId(`pais-${codigoPais}`) | ||
await expect(unPais).toBeVisible() | ||
unPais.click() | ||
await expect(page).toHaveURL(`/pais/${codigoPais}`) | ||
await expect(page.locator('h2')).toHaveText(nombrePais) | ||
// podríamos eventualmente testear otros atributos | ||
await page.getByTestId('volver').click() | ||
await expect(page).toHaveURL('/') | ||
await expect(page.getByTestId('paisBusqueda')).toHaveText('') | ||
} | ||
|
||
await page.goto('/') | ||
await expect(page.locator('h2')).toBeVisible() | ||
|
||
// Probamos la búsqueda disparada por el botón | ||
await page.getByTestId('paisBusqueda').fill('ARGENTINA') | ||
await page.getByTestId('buscar').click() | ||
const unPais = await page.getByTestId('pais-0') | ||
await expect(unPais).toBeVisible() | ||
unPais.click() | ||
await expect(page).toHaveURL('/pais/ARG') | ||
await expect(page.locator('h2')).toHaveText('Argentina') | ||
// podríamos eventualmente testear otros atributos | ||
await page.getByTestId('volver').click() | ||
await expect(page).toHaveURL('/') | ||
await expect(page.getByTestId('paisBusqueda')).toHaveText('') | ||
await irAPaisYVolver(page, 'ARG', 'Argentina') | ||
|
||
// Probamos la búsqueda automática desde el input | ||
await page.getByTestId('busquedaAutomatica').check() | ||
await page.getByTestId('paisBusqueda').fill('ARGEN') | ||
// necesitamos disparar el evento keyup | ||
await page.keyboard.up('T') | ||
await irAPaisYVolver(page, 'ARG', 'Argentina') | ||
}) |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters