-
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.
* update * use only one job * change workflow name * Add footer search test * Add test for clicking recipe in homepage going to recipe's page * Add search recipes through home search form test * add save recipe card test
- Loading branch information
Showing
9 changed files
with
89 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Node.js CI | ||
name: Build and tests | ||
|
||
on: | ||
pull_request: | ||
|
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ node_modules | |
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
test-results/ |
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
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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('homepage', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/'); | ||
}); | ||
|
||
test('can see list of recipes in homepage', async ({ page }) => { | ||
const recipeCardsCount = await page.getByTestId('recipe-card').count(); | ||
|
||
expect(recipeCardsCount).toEqual(4); | ||
}); | ||
|
||
test('can search for recipes in the footer', async ({ page }) => { | ||
const footerSearchBox = page.getByRole('searchbox', { name: 'Buscar' }); | ||
await footerSearchBox.fill('pasta'); | ||
await page.keyboard.press('Enter'); | ||
await page.waitForURL('**/recetas?nombre=pasta'); | ||
|
||
const recipeCardsCount = await page.getByRole('heading', { name: 'pasta' }).count(); | ||
|
||
expect(recipeCardsCount).toBeGreaterThan(0); | ||
}); | ||
|
||
test('can search for recipes in the form', async ({ page }) => { | ||
const form = page.getByRole('form', { name: 'Recipe search form' }); | ||
|
||
const nameTextBox = form.getByRole('textbox', { name: 'Nombre de la receta:' }); | ||
await nameTextBox.fill('pasta'); | ||
|
||
const ingredientsTextBox = form.getByRole('textbox', { | ||
name: 'Ingredientes (presiona enter luego de cada uno):' | ||
}); | ||
await ingredientsTextBox.fill('langostino'); | ||
await page.keyboard.press('Enter'); | ||
|
||
const mediumDiffCheckbox = form.getByRole('checkbox', { name: 'Intermedias' }); | ||
await mediumDiffCheckbox.check(); | ||
|
||
const vegetarianCheckbox = form.getByRole('checkbox', { name: 'Solo vegetarianas' }); | ||
await vegetarianCheckbox.check(); | ||
|
||
await page.keyboard.press('Enter'); | ||
await page.waitForURL('**/recetas?nombre=pasta&dificultad=Medium&ingredientes=langostino&soloVegetarianas=true&pagina=1&limit=9'); | ||
|
||
const recipeCardsCount = await page.getByRole('heading', { name: 'pasta' }).count(); | ||
|
||
expect(recipeCardsCount).toBeGreaterThan(0); | ||
}); | ||
|
||
test("clicking on recipe card takes user to recipe's page", async ({ page }) => { | ||
const recipeCard = page.getByTestId('recipe-card').first(); | ||
const recipeName = await recipeCard.getByRole('heading').innerText(); | ||
|
||
await recipeCard.click(); | ||
await page.waitForURL('**/recetas/**'); | ||
|
||
const recipeHeading = await page.getByRole('heading', { name: recipeName }).innerText(); | ||
expect(recipeHeading).toEqual(recipeName); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('recipe card', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/'); | ||
}); | ||
|
||
test('can save recipe to local storage', async ({ page }) => { | ||
const recipeCards = await page.getByTestId('recipe-card').all(); | ||
const saveRecipeButton = recipeCards[0].getByRole('button', { name: 'Guardar receta' }); | ||
await saveRecipeButton.click(); | ||
|
||
const recipesSaved = await page.evaluate(() => window.localStorage.getItem('recipesSaved')); | ||
const recipesSavedParsed = recipesSaved ? JSON.parse(recipesSaved) : []; | ||
|
||
expect(recipesSavedParsed).toHaveLength(1); | ||
}); | ||
}); |