Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/end2end/playwright/pages/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Copy link
Member

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 ?

Copy link
Collaborator Author

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 simplify logs property description.

https://jsdoc.app/tags-typedef


export class ProjectPage {
/** @type {Page} */
page;
Expand Down Expand Up @@ -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
Expand All @@ -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}`
})
})
}

/**
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem of this open method, it's used only 3 times, versus 107 times for the function gotoMap.

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 gotoMap, while we are doing the transition.

If we want to keep it in POM, I think #5225 should be merged first, so it can be in the base class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

}

/**
Expand Down
Loading