test: migrate apps folder to playwright (#1201)
This commit is contained in:
12
packages/e2e-tests/fixtures/applications-page.js
Normal file
12
packages/e2e-tests/fixtures/applications-page.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const path = require('node:path');
|
||||
const { BasePage } = require('./base-page');
|
||||
|
||||
export class ApplicationsPage extends BasePage {
|
||||
async screenshot(options = {}) {
|
||||
const { path: plainPath, ...restOptions } = options;
|
||||
|
||||
const computedPath = path.join('applications', plainPath);
|
||||
|
||||
return await super.screenshot({ path: computedPath, ...restOptions });
|
||||
}
|
||||
}
|
34
packages/e2e-tests/fixtures/base-page.js
Normal file
34
packages/e2e-tests/fixtures/base-page.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const path = require('node:path');
|
||||
|
||||
export class BasePage {
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
constructor(page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
async clickAway() {
|
||||
await this.page.locator('body').click({ position: { x: 0, y: 0 } });
|
||||
}
|
||||
|
||||
async screenshot(options = {}) {
|
||||
const { path: plainPath, ...restOptions } = options;
|
||||
|
||||
const computedPath = path.join('output/screenshots', plainPath);
|
||||
|
||||
return await this.page.screenshot({ path: computedPath, ...restOptions });
|
||||
}
|
||||
|
||||
async login() {
|
||||
await this.page.goto('/login');
|
||||
await this.page
|
||||
.getByTestId('email-text-field')
|
||||
.fill(process.env.LOGIN_EMAIL);
|
||||
await this.page
|
||||
.getByTestId('password-text-field')
|
||||
.fill(process.env.LOGIN_PASSWORD);
|
||||
|
||||
await this.page.getByTestId('login-button').click();
|
||||
}
|
||||
}
|
9
packages/e2e-tests/fixtures/index.js
Normal file
9
packages/e2e-tests/fixtures/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const base = require('@playwright/test');
|
||||
const { ApplicationsPage } = require('./applications-page');
|
||||
|
||||
exports.test = base.test.extend({
|
||||
applicationsPage: async ({ page }, use) => {
|
||||
await use(new ApplicationsPage(page));
|
||||
},
|
||||
});
|
||||
exports.expect = base.expect;
|
Reference in New Issue
Block a user