Skip to content

Commit

Permalink
test: commonjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
boubkerbribri authored and Progi1984 committed Jan 18, 2024
1 parent e58dc32 commit 1912e17
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 50 deletions.
15 changes: 7 additions & 8 deletions src/common/BO/loginBO.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import testContext from '@utils/testContext';
//import testContext from '@utils/testContext';

import loginPage from '@pages/BO/login';
import dashboardPage from '@pages/BO/dashboard';

import {expect} from '@playwright/test';
import type {Page} from 'playwright';
import type {TestInfo} from '@playwright/test';
import type {Page, TestInfo} from '@playwright/test';

export default {
async loginBO(
Expand All @@ -14,21 +13,21 @@ export default {
email: string = global.BO.EMAIL,
password: string = global.BO.PASSWD,
): Promise<void> {
await testContext.addContextItem(testInfo, 'testIdentifier', 'loginBO');
//await testContext.addContextItem(testInfo, 'testIdentifier', 'loginBO');

await loginPage.goTo(page, global.BO.URL);
//await loginPage.goTo(page, global.BO.URL);
await loginPage.successLogin(page, email, password);

const pageTitle = await dashboardPage.getPageTitle(page);
expect(pageTitle).toContain(dashboardPage.pageTitle);
},

async logoutBO(testInfo: TestInfo, page: Page): Promise<void> {
await testContext.addContextItem(testInfo, 'testIdentifier', 'logoutBO');
//await testContext.addContextItem(testInfo, 'testIdentifier', 'logoutBO');

await dashboardPage.logoutBO(page);

const pageTitle = await loginPage.getPageTitle(page);
expect(pageTitle).toContain(loginPage.pageTitle);
//const pageTitle = await loginPage.getPageTitle(page);
//expect(pageTitle).toContain(loginPage.pageTitle);
},
};
13 changes: 6 additions & 7 deletions src/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import semver from 'semver';

let file: string;
const psVersion = process.env.PS_VERSION ?? '99.99.99';

if (semver.gte(process.env.PS_VERSION as string, '8.0.0')) {
file = '@versions/8.0.0/pages/BO/dashboard';
let Dashboard: any;
if (semver.gte(psVersion, '8.0.0')) {

Check failure on line 6 in src/pages/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

Expected blank line before this statement
Dashboard = require('@versions/8.0.0/pages/BO/dashboard');

Check failure on line 7 in src/pages/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected require()
} else {
file = '@versions/8.0.0/pages/BO/dashboard';
Dashboard = require('@versions/8.0.0/pages/BO/dashboard');

Check failure on line 9 in src/pages/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected require()
}

const Dashboard = await import(file);
export default Dashboard;
export default Dashboard.constructor();
13 changes: 6 additions & 7 deletions src/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import semver from 'semver';

let file: string;
const psVersion = process.env.PS_VERSION ?? '99.99.99';

if (semver.gte(process.env.PS_VERSION as string, '8.0.0')) {
file = '@versions/8.0.0/pages/BO/login';
let Login: any;
if (semver.gte(psVersion, '8.0.0')) {=

Check failure on line 6 in src/pages/BO/login/index.ts

View workflow job for this annotation

GitHub Actions / TypeScript Check

Declaration or statement expected.
Login = require('@versions/8.0.0/pages/BO/login');
} else {
file = '@versions/8.0.0/pages/BO/login';
Login = require('@versions/8.0.0/pages/BO/login');
}

const Login = await import(file);
export default Login;
export default Login.constructor();
4 changes: 1 addition & 3 deletions src/versions/8.0.0/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {DashboardPageInterface} from '@interfaces/BO/dashboard';
* @class
* @extends BOBasePage
*/
class Dashboard extends BOBasePage implements DashboardPageInterface {
export default class Dashboard extends BOBasePage implements DashboardPageInterface {
public readonly pageTitle: string;

private readonly demoModeButton: string;
Expand Down Expand Up @@ -624,5 +624,3 @@ class Dashboard extends BOBasePage implements DashboardPageInterface {
return this.getTextContent(page, this.helpCardDocumentTitle);
}
}

export default new Dashboard();
4 changes: 1 addition & 3 deletions src/versions/8.0.0/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {Page} from 'playwright';
* @class
* @extends BOBasePage
*/
class Login extends BOBasePage implements LoginPageInterface {
export default class Login extends BOBasePage implements LoginPageInterface {
public readonly pageTitle: string;

public readonly loginErrorText: string;
Expand Down Expand Up @@ -183,5 +183,3 @@ class Login extends BOBasePage implements LoginPageInterface {
return this.getTextContent(page, this.resetPasswordSuccessConfirmationText);
}
}

export default new Login();
71 changes: 49 additions & 22 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,58 @@
{
"compilerOptions": {
"noImplicitAny": true,
"noImplicitThis": true,
"module": "es2022",
"target": "es2022",
"strict": true,
"moduleResolution": "node",
"listEmittedFiles": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowJs": true,
"downlevelIteration": true,
"baseUrl": "./",
"outDir": "dist",
"target": "es6",
"module": "commonjs",
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitThis": false,
"strict": true,
"strictFunctionTypes": true,
"isolatedModules": true,
"declaration": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"baseUrl": "./",
"outDir": "./dist",
"paths": {
"@interfaces/*": ["src/interfaces/*"],
"@pages/*": ["src/pages/*"],
"@common/*": ["src/common/*"],
"@data/*": ["src/data/*"],
"@types/*": ["src/types/*"],
"@utils/*": ["src/utils/*"],
"@versions/*": ["src/versions/*"]
"@interfaces/*": [
"src/interfaces/*"
],
"@pages/*": [
"src/pages/*"
],
"@common/*": [
"src/common/*"
],
"@data/*": [
"src/data/*"
],
"@types/*": [
"src/types/*"
],
"@utils/*": [
"src/utils/*"
],
"@versions/*": [
"src/versions/*"
]
},
"typeRoots": ["types", "node_modules/@types"],
"skipLibCheck": true
"typeRoots": [
"types",
"node_modules/@types"
],
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
}

0 comments on commit 1912e17

Please sign in to comment.