Skip to content

Commit

Permalink
Tests - POM, switch from ts to spec.js file
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Jan 16, 2025
1 parent 65cca79 commit e900ff9
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tests/end2end/playwright/attribute-table.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { ProjectPage } from './pages/project';
import { ProjectPage } from './pages/project.spec';
import { gotoMap } from './globals';

test.describe('Attribute table', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/edition-form.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';
import {ProjectPage} from "./pages/project";
import {ProjectPage} from "./pages/project.spec";

test.describe('Edition Form Validation', () => {

Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/media.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';
import {ProjectPage} from "./pages/project";
import {ProjectPage} from "./pages/project.spec";

test.describe('Media', () => {
test('Tests media are deleted', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,92 @@
import {expect, type Locator, type Page} from '@playwright/test';
// @ts-check
import {expect, Locator, Page} from '@playwright/test';
import { gotoMap } from '../globals';

export class ProjectPage {
readonly page: Page;
/** @type {Page} */
page;

// Metadata
readonly project: string;
readonly repository: string;
/**
* Project name metadata
* @type {string}
*/
project;
/**
* Repository name metadata
* @type {string}
*/
repository;

// Menu
readonly switcher: Locator;
readonly buttonEditing: Locator;
/**
* Layer switcher menu
* @type {Locator}
*/
switcher;
/**
* Editing menu
* @type {Locator}
*/
buttonEditing: Locator;

// Docks
readonly attributeTable: Locator;
readonly dock: Locator;
readonly rightDock: Locator;
readonly bottomDock: Locator;
readonly miniDock: Locator;

readonly search: Locator;
/**
* Attribute table dock
* @type {Locator}
*/
attributeTable: Locator;
/**
* Main left dock
* @type {Locator}
*/
dock: Locator;
/**
* Right dock
* @type {Locator}
*/
rightDock: Locator;
/**
* Bottom dock
* @type {Locator}
*/
bottomDock: Locator;
/**
* Mini dock
* @type {Locator}
*/
miniDock: Locator;
/**
* Top search bar
* @type {Locator}
*/
search: Locator;

// Messages
readonly warningMessage: Locator;
/**
* Foreground message bar
* @type {Locator}
*/
warningMessage: Locator;

// Attribute table for the given layer name
readonly attributeTableHtml = (name: string) =>
/**
* Attribute table for the given layer name
* @param {string} name Name of the layer
* @returns {Locator}
*/
attributeTableHtml = (name) =>
this.page.locator(`#attribute-layer-table-${name}`);

constructor(page: Page, project: string) {
/**
* Constructor
* @param {Page} page The playwright page
* @param {string} project The project name
* @param {string} repository The repository name, default to testsrepository
*/
constructor(page, project, repository = 'testsrepository') {
this.page = page;
this.project = project;
this.repository = 'testsrepository';
this.repository = repository;
this.dock = page.locator('#dock');
this.rightDock = page.locator('#right-dock');
this.bottomDock = page.locator('#bottom-dock');
Expand All @@ -43,7 +99,7 @@ export class ProjectPage {

/**
* open function
* Open the project
* Open the URL for the given project and repository
*/
async open(){
await gotoMap(`/index.php/view/map?repository=${this.repository}&project=${this.project}`, this.page);
Expand Down Expand Up @@ -71,7 +127,7 @@ export class ProjectPage {
async editingSubmitForm(futureAction: string = 'close'){
await this.page.locator('#jforms_view_edition_liz_future_action').selectOption(futureAction);
await this.page.locator('#jforms_view_edition__submit_submit').click();
if (futureAction == 'close'){
if (futureAction === 'close'){
await expect(this.page.locator('#edition-form-container')).toBeHidden();
} else {
await expect(this.page.locator('#edition-form-container')).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/project_load_warning.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { ProjectPage } from './pages/project';
import { ProjectPage } from './pages/project.spec';

test.describe('Project warnings in CFG as admin', () => {
test.use({ storageState: 'playwright/.auth/admin.json' });
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/snap.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';
import {ProjectPage} from "./pages/project";
import {ProjectPage} from "./pages/project.spec";

test.describe('Snap on edition', () => {
test.beforeEach(async ({ page }) => {
Expand Down

0 comments on commit e900ff9

Please sign in to comment.