Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucaspains committed Dec 18, 2024
1 parent 8ae4212 commit 5772149
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion tests/add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ test('import from code', async ({ page, browserName }) => {
await expect(page.getByLabel('Title')).toHaveValue("New Bread Recipe");
await expect(page.getByPlaceholder('1 cup flour')).toHaveValue("142g whole wheat flour");
await expect(page.getByPlaceholder('Preheat oven to 350 F')).toHaveValue("Mix together the dry ingredients");
expect(await page.locator('.list-images').getByRole("img").count()).toBe(1);
await expect(page.locator('.list-images').getByRole("img")).toHaveCount(1);
});
22 changes: 11 additions & 11 deletions tests/categories.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ test.beforeEach(async ({ page }) => {

test('add new category', async ({ page }) => {
await createCategory(page, 1, "Category 1");
expect(await page.locator('.category-item').count()).toBe(1);
expect(await page.getByText('Category 1').first()).toBeVisible();
await expect(page.locator('.category-item')).toHaveCount(1);
await expect(page.getByText('Category 1')).toHaveCount(1);
});

test('add multiple category', async ({ page }) => {
await createCategory(page, 1, "Category 1");
await createCategory(page, 2, "Category 2");
await createCategory(page, 3, "Category 3");
await createCategory(page, 4, "Category 4");
expect(await page.locator('.category-item').count()).toBe(4);
expect(await page.getByText('Category 1').count()).toBe(1);
expect(await page.getByText('Category 2').count()).toBe(1);
expect(await page.getByText('Category 3').count()).toBe(1);
expect(await page.getByText('Category 4').count()).toBe(1);
await expect(page.locator('.category-item')).toHaveCount(4);
await expect(page.getByText('Category 1')).toHaveCount(1);
await expect(page.getByText('Category 2')).toHaveCount(1);
await expect(page.getByText('Category 3')).toHaveCount(1);
await expect(page.getByText('Category 4')).toHaveCount(1);
});

test('edit category', async ({ page }) => {
Expand All @@ -32,8 +32,8 @@ test('edit category', async ({ page }) => {
await page.getByRole('menuitem', { name: 'Edit...' }).click();
await page.getByTestId('edit-category-name').fill('Category 2');
await page.getByRole('button', { name: 'OK' }).click();
expect(await page.locator('.category-item').count()).toBe(1);
expect(await page.getByText('Category 2').count()).toBe(1);
await expect(page.locator('.category-item')).toHaveCount(1);
await expect(page.getByText('Category 2')).toHaveCount(1);
});

test('delete category', async ({ page }) => {
Expand All @@ -43,6 +43,6 @@ test('delete category', async ({ page }) => {
await page.getByRole('menuitem', { name: 'Delete...' }).click();
await page.getByRole('button', { name: 'Yes, delete' }).click();
await page.waitForTimeout(500);
expect(await page.locator('.category-item').count()).toBe(0);
expect(await page.getByText('Category 1').count()).toBe(0);
await expect(page.locator('.category-item')).toHaveCount(0);
await expect(page.getByText('Category 1')).toHaveCount(0);
});
18 changes: 9 additions & 9 deletions tests/category-recipes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('title is Category 1', async ({ page }) => {
test('open recipe', async ({ page }) => {
await createRecipe(page, 2, "recipe", 1, ["1 cup flour"], ["Preheat oven to 350 F"], false, "Category 1");
await goToCategory(page, "Category 1");
await page.getByTestId('recipe-title').click();
await page.getByTestId('recipe-title').first().click();
await expect(page).toHaveURL(/.*\/recipe\/2/);
});

Expand Down Expand Up @@ -101,7 +101,7 @@ test('add manually', async ({ page }) => {
await page.getByRole('menuitem', { name: 'Add manually' }).click();

await expect(page).toHaveURL(/.*\/recipe\/0\/edit/);
expect(await page.getByLabel('Category').inputValue()).toBe("1");
await expect(page.getByLabel('Category')).toHaveValue("1");
});

test('import from website', async ({ page }) => {
Expand Down Expand Up @@ -134,7 +134,7 @@ test('search simple', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("Cookie");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -146,7 +146,7 @@ test('search advanced by typing title', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("title: Cookie");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -158,7 +158,7 @@ test('search advanced by typing ingredient', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("ingredients: dough");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -170,7 +170,7 @@ test('search advanced by typing step', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("steps: 354F");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -184,7 +184,7 @@ test('search advanced by selecting title', async ({ page, isMobile }) => {
await page.getByTestId('search-input').pressSequentially("cookie");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -197,7 +197,7 @@ test('search advanced by selecting ingredient', async ({ page, isMobile }) => {
await page.getByTestId('search-input').pressSequentially("dough");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -210,6 +210,6 @@ test('search advanced by selecting step', async ({ page, isMobile }) => {
await page.getByTestId('search-input').pressSequentially("354F");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});
30 changes: 15 additions & 15 deletions tests/display-detail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,43 @@ test('Show ingredient detail gram', async ({ page, browserName, isMobile }) => {
await createRecipe(page, 2, "New Bread", 5, ["100g flour"], ["Bake it for 30 min"]);
await page.goto('#/recipe/2');
await page.getByText('100g flour').click();
expect(await page.getByText('Quantity: 100').count()).toBe(1);
expect(await page.getByText('UOM: gram').count()).toBe(1);
expect(await page.getByText('Ingredient: flour').count()).toBe(1);
expect(await page.getByText('100000milligram').count()).toBe(1);
await expect(page.getByText('Quantity: 100')).toHaveCount(1);
await expect(page.getByText('UOM: gram')).toHaveCount(1);
await expect(page.getByText('Ingredient: flour')).toHaveCount(1);
await expect(page.getByText('100000milligram')).toHaveCount(1);
});

test('Show ingredient detail cup', async ({ page, browserName, isMobile }) => {
await createRecipe(page, 2, "New Bread", 5, ["1 cup flour"], ["Bake it for 30 min"]);
await page.goto('#/recipe/2');
await page.getByText('1 cup flour').click();
expect(await page.getByText('Quantity: 1').count()).toBe(1);
expect(await page.getByText('UOM: cup').count()).toBe(1);
expect(await page.getByText('Ingredient: flour').count()).toBe(1);
expect(await page.getByText('16tablespoon').count()).toBe(1);
expect(await page.getByText('0.25quart').count()).toBe(1);
expect(await page.getByText('48teaspoon').count()).toBe(1);
await expect(page.getByText('Quantity: 1')).toHaveCount(1);
await expect(page.getByText('UOM: cup')).toHaveCount(1);
await expect(page.getByText('Ingredient: flour')).toHaveCount(1);
await expect(page.getByText('16tablespoon')).toHaveCount(1);
await expect(page.getByText('0.25quart')).toHaveCount(1);
await expect(page.getByText('48teaspoon')).toHaveCount(1);
});

test('Show step detail time', async ({ page, browserName, isMobile }) => {
await createRecipe(page, 2, "New Bread", 5, ["1 cup flour"], ["Bake it for 30 min"]);
await page.goto('#/recipe/2');
await page.getByText('Bake it for 30 min').click();
expect(await page.getByText('Time: 30 minutes').count()).toBe(1);
await expect(page.getByText('Time: 30 minutes')).toHaveCount(1);
});

test('Show step detail temperature F', async ({ page, browserName, isMobile }) => {
await createRecipe(page, 2, "New Bread", 5, ["1 cup flour"], ["Bake it at 450F for 30 min"]);
await page.goto('#/recipe/2');
await page.getByText('Bake it at 450F for 30 min').click();
expect(await page.getByText('Time: 30 minutes').count()).toBe(1);
expect(await page.getByText('232.2222celsius').count()).toBe(1);
await expect(page.getByText('Time: 30 minutes')).toHaveCount(1);
await expect(page.getByText('232.2222celsius')).toHaveCount(1);
});

test('Show step detail temperature C', async ({ page, browserName, isMobile }) => {
await createRecipe(page, 2, "New Bread", 5, ["1 cup flour"], ["Bake it at 232C for 30 min"]);
await page.goto('#/recipe/2');
await page.getByText('Bake it at 232C for 30 min').click();
expect(await page.getByText('Time: 30 minutes').count()).toBe(1);
expect(await page.getByText('449.6fahrenheit').count()).toBe(1);
await expect(page.getByText('Time: 30 minutes')).toHaveCount(1);
await expect(page.getByText('449.6fahrenheit')).toHaveCount(1);
});
2 changes: 1 addition & 1 deletion tests/display.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('change size', async ({ page }) => {
await page.getByTestId('multiplier-button').click();
await page.getByTestId('multiplier-value').fill("2");
await page.getByRole('button').getByText("OK").click();
expect(await page.getByText('200g flour').textContent()).toBe('200g flour');
await expect(page.getByText('200g flour')).toHaveText('200g flour');
});

test('change time', async ({ page, browserName }) => {
Expand Down
12 changes: 6 additions & 6 deletions tests/edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test('add image', async ({ page, browserName, isMobile }) => {
await page.getByText('Sourdough Bread').first().click();
await page.getByTestId('edit-button').click();
await page.getByTestId('add-image-button').click();
expect(await page.locator('.list-images').getByRole("img").count()).toBe(2);
await expect(page.locator('.list-images').getByRole("img")).toHaveCount(2);
});

test('add video', async ({ page, browserName, isMobile }) => {
Expand All @@ -106,7 +106,7 @@ test('remove media', async ({ page }) => {
await page.getByText('Sourdough Bread').first().click();
await page.getByTestId('edit-button').click();
await page.getByTestId('remove-image-button').click();
expect(await page.locator('.list-images').getByRole("img").count()).toBe(0);
await expect(page.locator('.list-images').getByRole("img")).toHaveCount(0);
});

test('crop image cancel', async ({ page }) => {
Expand All @@ -116,7 +116,7 @@ test('crop image cancel', async ({ page }) => {
const original = await page.locator('.list-images').getByRole("img").first().getAttribute("src");
await page.getByTestId('crop-button').click();
await page.getByTestId('cancel-crop-button').click();
expect(await page.locator('.list-images').getByRole("img").count()).toBe(1);
await expect(page.locator('.list-images').getByRole("img")).toHaveCount(1);
const afterCropCancel = await page.locator('.list-images').getByRole("img").first().getAttribute("src");
expect(original).toBe(afterCropCancel);
});
Expand All @@ -138,14 +138,14 @@ test('change language', async ({ page }) => {
await page.getByText('Sourdough Bread').first().click();
await page.getByTestId('edit-button').click();
await page.getByTestId('change-lang-button').click();

expect(page.getByLabel('American English')).toBeChecked();

await page.getByLabel('Brazilian Portuguese').check();
await page.getByRole('button', { name: 'OK' }).click();

await page.getByTestId("topbar-single-button").click();

await page.goto('/');
await page.getByText('Sourdough Bread').first().click();
await page.getByTestId('edit-button').click();
Expand Down
14 changes: 7 additions & 7 deletions tests/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ test('search simple', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("Cookie");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -128,7 +128,7 @@ test('search advanced by typing title', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("title: Cookie");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -140,7 +140,7 @@ test('search advanced by typing ingredient', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("ingredients: dough");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -152,7 +152,7 @@ test('search advanced by typing step', async ({ page, isMobile }) => {
await page.getByTestId('search-input').fill("steps: 354F");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -166,7 +166,7 @@ test('search advanced by selecting title', async ({ page, isMobile }) => {
await page.getByTestId('search-input').pressSequentially("cookie");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -179,7 +179,7 @@ test('search advanced by selecting ingredient', async ({ page, isMobile }) => {
await page.getByTestId('search-input').pressSequentially("dough");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});

Expand All @@ -192,6 +192,6 @@ test('search advanced by selecting step', async ({ page, isMobile }) => {
await page.getByTestId('search-input').pressSequentially("354F");
await page.waitForTimeout(500);
const names = page.getByTestId('recipe-title');
expect(await names.count()).toBe(1);
await expect(names).toHaveCount(1);
await expect(names.first()).toHaveText('Favorite cookie');
});
Loading

0 comments on commit 5772149

Please sign in to comment.