Skip to content

Commit

Permalink
Fix hiding toast messages in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvonen committed Dec 13, 2024
1 parent 6bc593a commit 431429a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 5 additions & 6 deletions e2e/log.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ test('logs veggies', async ({page}) => {
'This Week 2 Veggies',
);

let elements = await page.getByTestId('toast-message').all();
for (const element of elements) {
await element.click();
const toastLocator = page.getByTestId('toast-message');

while ((await toastLocator.count()) > 0) {
await toastLocator.nth(0).click(); // Click the first toast message
}

elements = await page.getByTestId('toast-message').all();
expect(elements).toHaveLength(0);
await page.getByTestId('navbar-link-settings').click();
await page.getByTestId('navbar-link-log').click();
await expect(page.getByTestId('category-status-chart-center-label')).toHaveText(
Expand Down Expand Up @@ -75,7 +74,7 @@ test('achievement notifications work', async ({page}) => {
await expect(page.getByTestId('dialog')).toBeHidden();
});

test('weekly achievement works', async ({page}) => {
test.only('weekly achievement works', async ({page}) => {

Check failure on line 77 in e2e/log.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected focused test
await page.goto('/');
await page.getByTestId('home-start-button').click();
await page.getByTestId('veggie-search-button').click();
Expand Down
7 changes: 4 additions & 3 deletions e2e/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ test("shows current week's veggies", async ({page}) => {
await page.getByText(/^apple$/).click();
await page.getByText('Apricot').click();
await page.getByText('Avocado').click();
const elements = await page.getByTestId('toast-message').all();
for (const element of elements) {
await element.click();
const toastLocator = page.getByTestId('toast-message');

while ((await toastLocator.count()) > 0) {
await toastLocator.nth(0).click(); // Click the first toast message
}
await page.getByTestId('navbar-link-stats').click();
await expect(page.getByTestId('tag-apple')).toBeVisible();
Expand Down

0 comments on commit 431429a

Please sign in to comment.