-
-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests e2e Playwright : Store logs in Project POM #5226
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,17 @@ | |
import {expect, Locator, Page} from '@playwright/test'; | ||
import { gotoMap } from '../globals'; | ||
|
||
/** | ||
* @typedef {Object} logMessage | ||
* @property {string} type - the log type :One of the following values: | ||
* 'log', 'debug', 'info', 'error', 'warning', 'dir', 'dirxml', 'table', | ||
* 'trace', 'clear', 'startGroup', 'startGroupCollapsed', 'endGroup', | ||
* 'assert', 'profile', 'profileEnd', 'count', 'timeEnd'. | ||
* @property {string} message - the log message text | ||
* @property {string} location - the log message location in one line | ||
* @see https://playwright.dev/docs/api/class-consolemessage | ||
*/ | ||
|
||
export class ProjectPage { | ||
/** @type {Page} */ | ||
page; | ||
|
@@ -69,6 +80,12 @@ export class ProjectPage { | |
*/ | ||
warningMessage; | ||
|
||
/** | ||
* Logs collected | ||
* @type {logMessage[]} | ||
*/ | ||
logs = []; | ||
|
||
/** | ||
* Attribute table for the given layer name | ||
* @param {string} name Name of the layer | ||
|
@@ -95,6 +112,21 @@ export class ProjectPage { | |
this.search = page.locator('#search-query'); | ||
this.switcher = page.locator('#button-switcher'); | ||
this.buttonEditing = page.locator('#button-edition'); | ||
|
||
const logs = this.logs; | ||
page.on('console', message => { | ||
// Default message from jQuery: JQMIGRATE: Migrate is installed, version 3.3.1 | ||
// Do not stored it - will be removed when we are sure that this log will not appear | ||
if (message.type() == 'log' && message.text().startsWith('JQMIGRATE: Migrate is installed')) { | ||
return; | ||
} | ||
const location = message.location() | ||
logs.push({ | ||
type: message.type(), | ||
message: message.text(), | ||
location: `${location.url}:${location.lineNumber}:${location.columnNumber}` | ||
}) | ||
}) | ||
} | ||
|
||
/** | ||
|
@@ -103,6 +135,7 @@ export class ProjectPage { | |
*/ | ||
async open(){ | ||
await gotoMap(`/index.php/view/map?repository=${this.repository}&project=${this.project}`, this.page); | ||
expect(this.logs).toHaveLength(0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This problem of this What don't we move it to a "standalone function" instead of a method of this class ? So it can be called at the end of If we want to keep it in POM, I think #5225 should be merged first, so it can be in the base class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a draft to test it. I don't know how we will have to use it. |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure to understand the purpose of this block ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done to describe
logMessage
object to simplifylogs
property description.https://jsdoc.app/tags-typedef