Skip to content

Commit 9e2a3b4

Browse files
committed
Tests e2e Playwright : Store logs in Project POM
Follow up #5204 Add a way to store and check logs in Project page.
1 parent ef362dc commit 9e2a3b4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

tests/end2end/playwright/pages/project.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { BasePage } from './base';
99
*/
1010

1111
/**
12-
* Playwright Page
12+
* Playwright Locator
1313
* @typedef {import('@playwright/test').Locator} Locator
1414
*/
1515

@@ -23,6 +23,17 @@ import { BasePage } from './base';
2323
* @typedef {number} int
2424
*/
2525

26+
/**
27+
* Console log message
28+
* @typedef {object} logMessage
29+
* @property {string} type - the log type :One of the following values:
30+
* 'log', 'debug', 'info', 'error', 'warning', 'dir', 'dirxml', 'table',
31+
* 'trace', 'clear', 'startGroup', 'startGroupCollapsed', 'endGroup',
32+
* 'assert', 'profile', 'profileEnd', 'count', 'timeEnd'.
33+
* @property {string} message - the log message text
34+
* @property {string} location - the log message location in one line
35+
* @see https://playwright.dev/docs/api/class-consolemessage
36+
*/
2637
export class ProjectPage extends BasePage {
2738
// Metadata
2839
/**
@@ -111,6 +122,12 @@ export class ProjectPage extends BasePage {
111122
*/
112123
warningMessage;
113124

125+
/**
126+
* Logs collected
127+
* @type {logMessage[]}
128+
*/
129+
logs = [];
130+
114131
/**
115132
* Path to the QGS file
116133
* @type {string}
@@ -200,6 +217,21 @@ export class ProjectPage extends BasePage {
200217
this.buttonEditing = page.locator('#button-edition');
201218
this.buttonMetadata = page.locator('#button-metadata');
202219
this.editionForm = page.locator('#jforms_view_edition');
220+
221+
const logs = this.logs;
222+
page.on('console', message => {
223+
// Default message from jQuery: JQMIGRATE: Migrate is installed, version 3.3.1
224+
// Do not stored it - will be removed when we are sure that this log will not appear
225+
if (message.type() == 'log' && message.text().startsWith('JQMIGRATE: Migrate is installed')) {
226+
return;
227+
}
228+
const location = message.location()
229+
logs.push({
230+
type: message.type(),
231+
message: message.text(),
232+
location: `${location.url}:${location.lineNumber}:${location.columnNumber}`
233+
})
234+
})
203235
}
204236

205237
/**

0 commit comments

Comments
 (0)