Skip to content

Commit

Permalink
Few more general fixes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucaspains committed Dec 19, 2024
1 parent 5772149 commit b219345
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
12 changes: 6 additions & 6 deletions tests/add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ test.beforeEach(async ({ page }) => {
test('add new recipe', async ({ page }) => {
await createRecipe(page, 2, "Bread 1", 5);
await page.goto('/');
expect(await page.getByText('Bread 1').textContent()).toEqual('Bread 1');
await expect(page.getByText('Bread 1')).toHaveText('Bread 1');
});

test('create many recipes', async ({ page }) => {
test.setTimeout(60000);
await createRecipe(page, 2, "Bread 2", 5);
await page.goto('/');
expect(await page.getByText('Bread 2').textContent()).toEqual('Bread 2');
await expect(page.getByText('Bread 2')).toHaveText('Bread 2');

await createRecipe(page, 3, "Bread 3", 5);
await page.goto('/');
expect(await page.getByText('Bread 3').textContent()).toEqual('Bread 3');
await expect(page.getByText('Bread 3')).toHaveText('Bread 3');

await createRecipe(page, 4, "Bread 4", 5);
await page.goto('/');
expect(await page.getByText('Bread 4').textContent()).toEqual('Bread 4');
await expect(page.getByText('Bread 4')).toHaveText('Bread 4');
});

test('import from website', async ({ page }) => {
Expand Down Expand Up @@ -72,7 +72,7 @@ test('import from url', async ({ page, browserName }) => {

test('import from code', async ({ page, browserName }) => {
test.skip(browserName === 'webkit', 'this test doesnt work in webkit');

const response = `
{
"title": "New Bread Recipe",
Expand All @@ -87,7 +87,7 @@ test('import from code', async ({ page, browserName }) => {
const json = JSON.parse(response);
await route.fulfill({ json });
});

await page.goto('/');

await page.getByTestId('add-menu-button').click();
Expand Down
13 changes: 0 additions & 13 deletions tests/display.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ test('print recipe', async ({ page }) => {
await page.waitForEvent("console", item => item.text() == "Print was triggered")
});

// test('change time webkit', async ({ page, browserName }) => {
// test.skip(browserName !== 'webkit', 'not applicable');

// await createRecipe(page, 2, "New Bread", 5, ["100g flour"], ["Bake it for 30 min"]);
// await page.goto('/');
// await page.getByText('New Bread').first().click();
// await page.getByTestId('time-button').click();
// await page.getByTestId('time-value-input').clear();
// await page.getByTestId('time-value-input').type("10:00");
// await page.getByRole('button').getByText("OK").click();
// expect(await page.getByText('10:35 AM').textContent()).toMatch(/10:35.*/);
// });

test('delete', async ({ page }) => {
await createRecipe(page, 2, "New Bread", 5, ["100g flour"], ["Bake it for 30 min"]);
await page.goto('/');
Expand Down
20 changes: 10 additions & 10 deletions tests/edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('title', async ({ page }) => {
await page.getByTestId("topbar-single-button").click();
await page.waitForTimeout(500);
await page.goto('/');
expect(await page.getByText('Changed Recipe').textContent()).toEqual("Changed Recipe");
await expect(page.getByText('Changed Recipe')).toHaveText("Changed Recipe");
});

test('add ingredient', async ({ page }) => {
Expand All @@ -37,7 +37,7 @@ test('add ingredient', async ({ page }) => {
await page.getByTestId("topbar-single-button").click();
await page.waitForTimeout(500);
await page.goto('#/recipe/1');
expect(await page.getByText('New Ingredient').textContent()).toEqual("New Ingredient");
await expect(page.getByText('New Ingredient')).toHaveText("New Ingredient");
});

test('add step', async ({ page }) => {
Expand All @@ -49,7 +49,7 @@ test('add step', async ({ page }) => {
await page.getByTestId("topbar-single-button").click();
await page.waitForTimeout(500);
await page.goto('#/recipe/1');
expect(await page.getByText('New Step').textContent()).toEqual("New Step");
await expect(page.getByText('New Step')).toHaveText("New Step");
});

test('add image', async ({ page, browserName, isMobile }) => {
Expand Down Expand Up @@ -97,7 +97,7 @@ test('add video', async ({ page, browserName, isMobile }) => {
await page.getByTestId('add-video-url').fill("https://www.youtube.com/watch?v=0YY7K7Xa5rE");
await page.getByRole("button").getByText("OK").click();

expect(page.locator("iframe"))
await expect(page.locator("iframe"))
.toHaveAttribute("src", "https://www.youtube.com/embed/0YY7K7Xa5rE");
});

Expand Down Expand Up @@ -164,10 +164,10 @@ test('edit ingredients and steps in single text area', async ({ page }) => {
await page.getByTestId("topbar-single-button").click();
await page.waitForTimeout(500);
await page.goto('#/recipe/1');
expect(await page.getByText('New Ingredient 1').textContent()).toEqual("New Ingredient 1");
expect(await page.getByText('New Ingredient 2').textContent()).toEqual("New Ingredient 2");
expect(await page.getByText('New Step 1').textContent()).toEqual("New Step 1");
expect(await page.getByText('New Step 2').textContent()).toEqual("New Step 2");
await expect(page.getByText('New Ingredient 1')).toHaveText("New Ingredient 1");
await expect(page.getByText('New Ingredient 2')).toHaveText("New Ingredient 2");
await expect(page.getByText('New Step 1')).toHaveText("New Step 1");
await expect(page.getByText('New Step 2')).toHaveText("New Step 2");
});

test('edit ingredients and steps in multiple text boxes', async ({ page }) => {
Expand All @@ -181,6 +181,6 @@ test('edit ingredients and steps in multiple text boxes', async ({ page }) => {
await page.getByTestId("topbar-single-button").click();
await page.waitForTimeout(500);
await page.goto('#/recipe/1');
expect(await page.getByText('New Ingredient').textContent()).toEqual("New Ingredient");
expect(await page.getByText('New Step').textContent()).toEqual("New Step");
await expect(page.getByText('New Ingredient')).toHaveText("New Ingredient");
await expect(page.getByText('New Step')).toHaveText("New Step");
});
13 changes: 6 additions & 7 deletions tests/import-backup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('Restore v1 json backup old format', async ({ page }) => {
await page.getByTestId("import-button").click();
await page.getByTestId("topbar-single-button").click();
await page.goto('#/recipe/1');
expect(await page.getByText('New Bread Recipe').textContent()).toEqual("New Bread Recipe");
await expect(page.getByText('New Bread Recipe')).toHaveText("New Bread Recipe");
});

test('Restore v1 json backup new format', async ({ page }) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ test('Restore v1 json backup new format', async ({ page }) => {
await page.getByTestId("import-button").click();
await page.getByTestId("topbar-single-button").click();
await page.goto('#/recipe/1');
expect(await page.getByText('New Bread Recipe').textContent()).toEqual("New Bread Recipe");
await expect(page.getByText('New Bread Recipe')).toHaveText("New Bread Recipe");
});

test('Restore v1 json backup with video', async ({ page }) => {
Expand Down Expand Up @@ -122,13 +122,12 @@ test('Restore v1 json backup with video', async ({ page }) => {
await page.getByTestId("import-button").click();
await page.getByTestId("topbar-single-button").click();
await page.goto('#/recipe/1');
expect(await page.getByText('New Bread Recipe').textContent()).toEqual("New Bread Recipe");
await expect(page.getByText('New Bread Recipe')).toHaveText("New Bread Recipe");
await page.waitForTimeout(1000);
expect(await page.locator("iframe"))
await expect(page.locator("iframe"))
.toHaveAttribute("src", "https://www.youtube.com/embed/0YY7K7Xa5rE");
});


test('Restore v2 json backup new format', async ({ page }) => {
await page.addInitScript(() => {

Expand Down Expand Up @@ -197,8 +196,8 @@ test('Restore v2 json backup new format', async ({ page }) => {
await page.getByTestId("topbar-single-button").click();

await page.goto('/');
expect(await page.getByText('Bread').textContent()).toEqual("Bread");
await expect(page.getByText('Bread')).toHaveText("Bread");

await page.getByText('Bread').click();
expect(await page.getByText('New Bread Recipe').textContent()).toEqual("New Bread Recipe");
await expect(page.getByText('New Bread Recipe')).toHaveText("New Bread Recipe");
});

0 comments on commit b219345

Please sign in to comment.