Skip to content

Commit

Permalink
(test) Fix flaky Login E2E test (#1072)
Browse files Browse the repository at this point in the history
* Fix flaky Login E2E test

* Update e2e/specs/login.spec.ts
  • Loading branch information
jayasanka-sack authored Jul 5, 2024
1 parent f71125c commit d98a188
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions e2e/specs/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test.use({ storageState: { cookies: [], origins: [] } });

test('Login as Admin user', async ({ page }) => {
const loginPage = new LoginPage(page);
const userPanel = page.locator('[data-extension-slot-name="user-panel-slot"]');

await test.step('When I navigate to the login page', async () => {
await loginPage.goto();
Expand Down Expand Up @@ -34,10 +35,19 @@ test('Login as Admin user', async ({ page }) => {
await expect(page).toHaveURL(`${process.env.E2E_BASE_URL}/spa/home`);
});

await test.step('And I should be able to see various elements on the page', async () => {
await test.step('When I click on the my account button', async () => {
await page.getByRole('button', { name: /My Account/i }).click();
await expect(page.getByText(/super user/i)).toBeVisible();
await expect(page.getByText(/outpatient clinic/i)).toBeVisible();
});

await test.step('Then I should see the user details', async () => {
await expect(userPanel.getByText(/super user/i)).toBeVisible();
});

await test.step('And I should see the location details', async () => {
await expect(userPanel.getByText(/outpatient clinic/i)).toBeVisible();
});

await test.step('And I should see the logout button', async () => {
await expect(page.getByRole('button', { name: /logout/i })).toBeVisible();
});
});

0 comments on commit d98a188

Please sign in to comment.