Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d7fcf7
commit 8a12342
Showing
5 changed files
with
59 additions
and
10 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
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,41 @@ | ||
import { expect, test } from "./test"; | ||
|
||
test.describe("User authentication", () => { | ||
test.beforeEach(async ({ bookPage }) => { | ||
await bookPage.gotoList(); | ||
}); | ||
|
||
test("I can log in Admin @login", async ({ userPage, page }) => { | ||
await expect(page.getByText("Log in")).toBeVisible(); | ||
await expect(page.getByText("Sign out")).toHaveCount(0); | ||
|
||
await page.getByText("Log in").click(); | ||
await page.getByText("Log in").waitFor({ state: "hidden" }); | ||
// @ts-ignore assert declared on test.ts | ||
await expect(page).toBeOnLoginPage(); | ||
await expect(page.locator("#kc-header-wrapper")).toContainText("API Platform - Demo"); | ||
await expect(page.locator("#kc-form-login")).toContainText("Login as user: john.doe@example.com"); | ||
await expect(page.locator("#kc-form-login")).toContainText("Login as admin: chuck.norris@example.com"); | ||
await userPage.login(); | ||
|
||
await expect(page.getByText("Log in")).toHaveCount(0); | ||
await expect(page.getByText("Sign out")).toBeVisible(); | ||
}); | ||
|
||
test("I can sign out of Admin @login", async ({ userPage, page }) => { | ||
await page.getByText("Log in").click(); | ||
await userPage.login(); | ||
await page.getByText("Sign out").click(); | ||
|
||
await expect(page.getByText("Log in")).toBeVisible(); | ||
await expect(page.getByText("Sign out")).toHaveCount(0); | ||
|
||
// I should be logged out from Keycloak also | ||
await page.getByText("Log in").click(); | ||
// @ts-ignore assert declared on test.ts | ||
await expect(page).toBeOnLoginPage(); | ||
await expect(page.locator("#kc-header-wrapper")).toContainText("API Platform - Demo"); | ||
await expect(page.locator("#kc-form-login")).toContainText("Login as user: john.doe@example.com"); | ||
await expect(page.locator("#kc-form-login")).toContainText("Login as admin: chuck.norris@example.com"); | ||
}); | ||
}); |
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,4 @@ | ||
import { AbstractPage } from "./AbstractPage"; | ||
|
||
export class UserPage extends AbstractPage { | ||
} |
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