mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
2 years ago
|
import { expect, Page } from '@playwright/test';
|
||
|
import BasePage from '../Base';
|
||
2 years ago
|
|
||
|
export class LoginPage extends BasePage {
|
||
|
constructor(rootPage: Page) {
|
||
|
super(rootPage);
|
||
|
}
|
||
|
|
||
2 years ago
|
prefixEmail(email: string) {
|
||
2 years ago
|
const parallelId = process.env.TEST_PARALLEL_INDEX ?? '0';
|
||
2 years ago
|
return `nc_test_${parallelId}_${email}`;
|
||
|
}
|
||
|
|
||
2 years ago
|
goto() {
|
||
2 years ago
|
return this.rootPage.goto('/#/signin');
|
||
2 years ago
|
}
|
||
|
|
||
|
get() {
|
||
2 years ago
|
return this.rootPage.locator('html');
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async fillEmail({ email, withoutPrefix }: { email: string; withoutPrefix?: boolean }) {
|
||
|
if (!withoutPrefix) email = this.prefixEmail(email);
|
||
2 years ago
|
|
||
2 years ago
|
await this.get().locator(`[data-testid="nc-form-signin__email"]`).waitFor();
|
||
|
await this.get().locator(`[data-testid="nc-form-signin__email"]`).fill(email);
|
||
2 years ago
|
}
|
||
|
|
||
|
async fillPassword(password: string) {
|
||
2 years ago
|
await this.get().locator(`[data-testid="nc-form-signin__password"]`).fill(password);
|
||
2 years ago
|
}
|
||
|
|
||
|
async submit() {
|
||
2 years ago
|
await this.get().locator(`[data-testid="nc-form-signin__submit"]`).click();
|
||
2 years ago
|
|
||
2 years ago
|
// todo: Login api can take some time to respond if server is under load
|
||
2 years ago
|
await expect(this.rootPage).toHaveURL('http://localhost:3000/#/', {
|
||
2 years ago
|
timeout: 15000,
|
||
|
});
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
async signIn({ email, password, withoutPrefix }: { email: string; password: string; withoutPrefix?: boolean }) {
|
||
2 years ago
|
await this.goto();
|
||
2 years ago
|
|
||
|
// todo: Login page is sometimes not loaded. Probably because of lazy loading
|
||
|
await this.rootPage.waitForTimeout(1500);
|
||
2 years ago
|
await this.fillEmail({ email, withoutPrefix });
|
||
2 years ago
|
await this.fillPassword(password);
|
||
|
await this.submit();
|
||
|
}
|
||
2 years ago
|
}
|