-
Notifications
You must be signed in to change notification settings - Fork 0
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
b3e0952
commit 525095c
Showing
4 changed files
with
50 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { test as baseTest } from '@playwright/test'; | ||
import LoginPage from '../../pages/login-page'; | ||
import AdminHeaderPage from '../../pages/admin-header-page'; | ||
import Homepage from '../../pages/homepage'; | ||
import RoomsPage from '../../pages/rooms-page'; | ||
|
||
type Fixtures = { | ||
loginPage: LoginPage; | ||
adminHeaderPage: AdminHeaderPage; | ||
homepage: Homepage; | ||
roomsPage: RoomsPage; | ||
}; | ||
|
||
const test = baseTest.extend<Fixtures>({ | ||
|
||
loginPage: async ({ page }, use) => { | ||
await use(new LoginPage(page)) | ||
await page.close(); | ||
{ scope: 'test' } | ||
}, | ||
adminHeaderPage: async ({ page }, use) => { | ||
await use(new AdminHeaderPage(page)) | ||
await page.close(); | ||
{ scope: 'test' } | ||
}, | ||
homepage: async ({ page }, use) => { | ||
await use(new Homepage(page)) | ||
|
||
await page.close(); | ||
{ scope: 'test' } | ||
}, | ||
roomsPage: async ({ page }, use) => { | ||
await use(new RoomsPage(page)) | ||
await page.close(); | ||
{ scope: 'test' } | ||
} | ||
}) | ||
|
||
export default test | ||
export { expect } from '@playwright/test' |
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 |
---|---|---|
@@ -1,28 +1,14 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import LoginPage from '../../pages/login-page'; | ||
import AdminHeaderPage from '../../pages/admin-header-page' | ||
import test, { expect } from "../../helpers/fixtures/test-fixture"; | ||
import Env from '../../helpers/env'; | ||
|
||
let loginPage: LoginPage; | ||
let adminHeaderPage: AdminHeaderPage; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
loginPage = new LoginPage(page); | ||
adminHeaderPage = new AdminHeaderPage(page); | ||
}); | ||
|
||
const testCases = [ | ||
{ username: Env.ADMIN_USERNAME, password: Env.ADMIN_PASSWORD, isLoggedIn: true }, | ||
{ username: 'invalidUser', password: 'invalidPassword', isLoggedIn: false }, | ||
]; | ||
|
||
for (const { username, password, isLoggedIn } of testCases) | ||
test(`Login as user ${username}`, async ({ page }) => { | ||
test(`Login as user ${username}`, async ({ page, loginPage, adminHeaderPage }) => { | ||
await page.goto(Env.ADMIN_URL!); | ||
await loginPage.login(username, password); | ||
await expect(await adminHeaderPage.isLogoutButtonDisplayed()).toBe(isLoggedIn); | ||
expect(await adminHeaderPage.isLogoutButtonDisplayed()).toBe(isLoggedIn); | ||
}); | ||
|
||
test.afterEach(async ({ page }) => { | ||
await page.close(); | ||
}); |
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