-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests - Extends base class for testing admin pages and landing page
- Loading branch information
Showing
8 changed files
with
164 additions
and
37 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
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,45 @@ | ||
// @ts-check | ||
|
||
import {expect, Locator, Page} from '@playwright/test'; | ||
import { BasePage } from './base'; | ||
|
||
export class AdminPage extends BasePage { | ||
/** | ||
* Main administrator menu | ||
* @type {Locator} | ||
*/ | ||
menu; | ||
|
||
/** | ||
* Main administrator message bar | ||
* @type {Locator} | ||
*/ | ||
warningMessage; | ||
|
||
/** | ||
* Constructor for an administrator page | ||
* @param {Page} page The playwright page | ||
*/ | ||
constructor(page) { | ||
super(page); | ||
this.menu = page.locator('#menu'); | ||
this.warningMessage = page.locator('.alert'); | ||
} | ||
|
||
/** | ||
* Navigate in the administrator menu by clicking in the menu | ||
* @param {string} expected Name of the page | ||
*/ | ||
async openPage(expected){ | ||
await this.page.getByRole('link', { name: expected }).click(); | ||
await this.checkPage(expected); | ||
} | ||
|
||
/** | ||
* Check that the menu is OK | ||
* @param {string} expected Name of the page | ||
*/ | ||
async checkPage(expected){ | ||
await expect(this.menu.locator('li.active')).toHaveText(expected); | ||
} | ||
} |
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,42 @@ | ||
// @ts-check | ||
|
||
import {expect, Locator, Page} from '@playwright/test'; | ||
|
||
export class BasePage { | ||
/** @type {Page} */ | ||
page; | ||
|
||
/** | ||
* Header menu | ||
* @type {Locator} | ||
*/ | ||
headerMenu; | ||
|
||
/** | ||
* Top message bar | ||
* @type {Locator} | ||
*/ | ||
alert; | ||
|
||
/** | ||
* Constructor for a base page | ||
* @param {Page} page The playwright page | ||
*/ | ||
constructor(page) { | ||
this.page = page; | ||
this.headerMenu = page.locator('#headermenu'); | ||
this.alert = page.locator('.alert'); | ||
} | ||
|
||
/** | ||
* Check main alert message : level and content if necessary | ||
* @param {string} level Name of the CSS class for the level | ||
* @param {string} message Content of the message, if necessary | ||
*/ | ||
async checkAlert(level, message) { | ||
await expect(this.alert).toHaveClass(new RegExp(level, "g")); | ||
if (message) { | ||
await expect(this.alert).toHaveText(message); | ||
} | ||
} | ||
} |
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,35 @@ | ||
// @ts-check | ||
|
||
import {Locator, Page} from '@playwright/test'; | ||
import { BasePage } from './base'; | ||
|
||
export class HomePage extends BasePage { | ||
/** | ||
* Search project locator | ||
* @type {Locator} | ||
*/ | ||
search; | ||
|
||
/** | ||
* Top text locator | ||
* @type {Locator} | ||
*/ | ||
topContent; | ||
|
||
/** | ||
* Bottom text locator | ||
* @type {Locator} | ||
*/ | ||
bottomContent; | ||
|
||
/** | ||
* Constructor for main landing page of Lizmap | ||
* @param {Page} page The playwright page | ||
*/ | ||
constructor(page) { | ||
super(page); | ||
this.topContent = page.locator('#landingPageContent'); | ||
this.bottomContent = page.locator('#landingPageContentBottom'); | ||
this.search = page.locator('#search'); | ||
} | ||
} |
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