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

test: commonjs build #5

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 10 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';
let loginPage = require('@pages/BO/login');

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Expected 1 empty line after require statement not followed by another require

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

'loginPage' is never reassigned. Use 'const' instead

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Require statement not part of import statement

Check failure on line 3 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

`@pages/BO/login` import should occur after type import of `@playwright/test`
import dashboardPage from '@pages/BO/dashboard';

Check failure on line 4 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Import in body of module; reorder to top

import {expect} from '@playwright/test';

Check failure on line 6 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Import in body of module; reorder to top
import type {Page} from 'playwright';
import type {TestInfo} from '@playwright/test';
import type {Page, TestInfo} from '@playwright/test';

Check failure on line 7 in src/common/BO/loginBO.ts

View workflow job for this annotation

GitHub Actions / ESLint

Import in body of module; reorder to top

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

console.log(loginPage);
console.log(loginPage.goTo);

await loginPage.goTo(page, global.BO.URL);
await loginPage.successLogin(page, email, password);
Expand All @@ -24,11 +26,11 @@
},

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);
},
};
4 changes: 3 additions & 1 deletion src/interfaces/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export interface DashboardPageInterface {
import { BOBasePagePageInterface } from "@interfaces/BO";

Check failure on line 1 in src/interfaces/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

There should be no space after '{'

Check failure on line 1 in src/interfaces/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

There should be no space before '}'

Check failure on line 1 in src/interfaces/BO/dashboard/index.ts

View workflow job for this annotation

GitHub Actions / ESLint

Strings must use singlequote

export interface DashboardPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;
}
6 changes: 6 additions & 0 deletions src/interfaces/BO/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { CommonPageInterface } from "@interfaces/index";
import type { Page } from "@playwright/test";

export interface BOBasePagePageInterface extends CommonPageInterface {
logoutBO(page: Page): Promise<void>;
}
5 changes: 4 additions & 1 deletion src/interfaces/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { BOBasePagePageInterface } from "@interfaces/BO";

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

export interface LoginPageInterface {

export interface LoginPageInterface extends BOBasePagePageInterface {
readonly pageTitle: string;

successLogin(page: Page, email: string, password: string): Promise<void>;
Expand Down
7 changes: 7 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Page } from "@playwright/test";

export interface CommonPageInterface {
getPageTitle(page: Page): Promise<string>;

goTo(page: Page, url: string): Promise<void>;
}
12 changes: 6 additions & 6 deletions src/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { DashboardPageInterface } from '@interfaces/BO/dashboard';
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: DashboardPageInterface;
if (semver.gte(psVersion, '8.0.0')) {
Dashboard = require('@versions/8.0.0/pages/BO/dashboard');
} else {
file = '@versions/8.0.0/pages/BO/dashboard';
Dashboard = require('@versions/8.0.0/pages/BO/dashboard');
}

const Dashboard = await import(file);
export default Dashboard;
12 changes: 6 additions & 6 deletions src/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { LoginPageInterface } from '@interfaces/BO/login';
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: LoginPageInterface;
if (semver.gte(psVersion, '8.0.0')) {
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;
2 changes: 1 addition & 1 deletion src/versions/8.0.0/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,4 +625,4 @@ class Dashboard extends BOBasePage implements DashboardPageInterface {
}
}

export default new Dashboard();
export default new Dashboard();
2 changes: 1 addition & 1 deletion src/versions/8.0.0/pages/BO/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ class Login extends BOBasePage implements LoginPageInterface {
}
}

export default new Login();
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"
]
}