Browse Source

test(playwrite): add basic tests

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
c1ff9bb87b
  1. 1
      tests/playwright/package.json
  2. 0
      tests/playwright/pages/Account/AppStore.ts
  3. 0
      tests/playwright/pages/Account/PasswordReset.ts
  4. 33
      tests/playwright/pages/Account/Settings.ts
  5. 118
      tests/playwright/pages/Account/Token.ts
  6. 106
      tests/playwright/pages/Account/Users.ts
  7. 155
      tests/playwright/tests/accountTokenManagement.spec.ts
  8. 144
      tests/playwright/tests/accountUserManagement.spec.ts
  9. 159
      tests/playwright/tests/accountUserSettings.spec.ts

1
tests/playwright/package.json

@ -11,6 +11,7 @@
"test:repeat": "TRACE=true npx playwright test --workers=4 --repeat-each=12",
"test:quick": "TRACE=true PW_QUICK_TEST=1 npx playwright test --workers=4",
"test:debug": "./startPlayWrightServer.sh; PW_TEST_REUSE_CONTEXT=1 PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:31000/ PWDEBUG=console npx playwright test -c playwright.config.ts --headed --project=chromium --retries 0 --timeout 0 --workers 1 --max-failures=1",
"test:debug:watch": "npx nodemon -e ts -w ./ -x \"npm run test:debug\"",
"test:debug:quick:sqlite": "./startPlayWrightServer.sh; PW_QUICK_TEST=1 PW_TEST_REUSE_CONTEXT=1 PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:31000/ PWDEBUG=console npx playwright test -c playwright.config.ts --headed --project=chromium --retries 0 --timeout 5 --workers 1 --max-failures=1",
"ci:test": "npx playwright test --workers=2",
"ci:test:shard:1": "npx playwright test --workers=2 --shard=1/2",

0
tests/playwright/pages/Account/AppStore.ts

0
tests/playwright/pages/Account/PasswordReset.ts

33
tests/playwright/pages/Account/Settings.ts

@ -0,0 +1,33 @@
import { expect } from '@playwright/test';
import BasePage from '../Base';
import { AccountPage } from './index';
export class AccountSettingsPage extends BasePage {
private accountPage: AccountPage;
constructor(accountPage: AccountPage) {
super(accountPage.rootPage);
this.accountPage = accountPage;
}
async goto() {
await this.rootPage.goto('/?dummy=settings#/account/users/settings');
}
get() {
return this.accountPage.get().locator(`[data-testid="nc-app-settings"]`);
}
getInviteOnlyCheckbox() {
return this.get().locator(`.nc-invite-only-signup-checkbox`);
}
async checkInviteOnlySignupCheckbox(value: boolean) {
return expect(await this.get().locator(`.nc-invite-only-signup-checkbox`).isChecked()).toBe(value);
}
async toggleInviteOnlyCheckbox() {
await this.getInviteOnlyCheckbox().click();
await this.verifyToast({ message: 'Settings saved successfully' });
}
}

118
tests/playwright/pages/Account/Token.ts

@ -1,4 +1,4 @@
import { Locator } from '@playwright/test';
import { Locator } from '@playwright/test';
import BasePage from '../Base';
import { AccountPage } from './index';
@ -10,7 +10,7 @@ export class AccountTokenPage extends BasePage {
constructor(accountPage: AccountPage) {
super(accountPage.rootPage);
this.accountPage = accountPage;
this.createBtn = this.get().locator(`[data-cy="nc-token-create"]`);
this.createBtn = this.get().locator(`[data-testid="nc-token-create"]`);
this.createModal = accountPage.rootPage.locator(`.nc-modal-generate-token`);
}
@ -19,113 +19,25 @@ export class AccountTokenPage extends BasePage {
}
get() {
return this.accountPage.get().locator(`[data-cy="nc-token-list"]`);
return this.accountPage.get().locator(`[data-testid="nc-token-list"]`);
}
async createToken({ description }: { description:string }) {
async createToken({ description }: { description: string }) {
await this.createBtn.click();
await this.createModal.locator(`input[placeholder="Description"]`).fill(description);
await this.createModal.locator(`[data-cy="nc-token-modal-save"]`).click();
await this.createModal.locator(`[data-testid="nc-token-modal-save"]`).click();
await this.verifyToast({ message: 'Token generated successfully' });
// return await this.inviteTeamModal.locator(`.ant-alert-message`).innerText();
}
//
// prefixEmail(email: string) {
// const parallelId = process.env.TEST_PARALLEL_INDEX ?? '0';
// return `nc_test_${parallelId}_${email}`;
// }
//
// async closeInvite() {
// // two btn-icon-only in invite modal: close & copy url
// await this.inviteTeamModal.locator(`button.ant-btn-icon-only:visible`).first().click();
// }
//
// getUserRow({ email: _email }: { email: string }) {
// const email = this.prefixEmail(_email);
// return this.get().locator(`tr:has-text("${email}")`);
// }
//
// async updateRole({ email: _email, role }: { email: string; role: string }) {
// const email = this.prefixEmail(_email);
// const userRow = this.getUserRow({ email });
// await userRow.locator(`.nc-user-roles`).click();
// await this.rootPage.locator(`.nc-role-option:has-text("${role}")`).click();
// await this.verifyToast({ message: 'Successfully updated the user details' });
// }
/*
getSharedBaseSubModal() {
return this.rootPage.locator(`[data-nc="nc-share-base-sub-modal"]`);
}
async invite({ email, role }: { email: string; role: string }) {
email = this.prefixEmail(email);
await this.inviteTeamBtn.click();
await this.inviteTeamModal.locator(`input[placeholder="E-mail"]`).fill(email);
await this.inviteTeamModal.locator(`.nc-user-roles`).click();
const userRoleModal = this.rootPage.locator(`.nc-dropdown-user-role`);
await userRoleModal.locator(`.nc-role-option:has-text("${role}")`).click();
await this.inviteTeamModal.locator(`button:has-text("Invite")`).click();
await this.verifyToast({ message: 'Successfully updated the user details' });
return await this.inviteTeamModal.locator(`.ant-alert-message`).innerText();
}
async closeInvite() {
// two btn-icon-only in invite modal: close & copy url
await this.inviteTeamModal.locator(`button.ant-btn-icon-only:visible`).first().click();
}
async inviteMore() {
await this.inviteTeamModal.locator(`button:has-text("Invite More")`).click();
}
async toggleSharedBase({ toggle }: { toggle: boolean }) {
const toggleBtn = await this.getSharedBaseSubModal().locator(`.nc-disable-shared-base`);
const toggleBtnText = await toggleBtn.first().innerText();
const disabledBase = toggleBtnText.includes('Disable');
if (disabledBase) {
if (toggle) {
// if share base was disabled && request was to enable
await toggleBtn.click();
const modal = await this.rootPage.locator(`.nc-dropdown-shared-base-toggle`);
await modal.locator(`.ant-dropdown-menu-title-content`).click();
}
} else {
if (!toggle) {
// if share base was enabled && request was to disable
await toggleBtn.click();
const modal = await this.rootPage.locator(`.nc-dropdown-shared-base-toggle`);
await modal.locator(`.ant-dropdown-menu-title-content`).click();
}
}
}
async getSharedBaseUrl() {
const url = await this.getSharedBaseSubModal().locator(`.nc-url:visible`).innerText();
return url;
}
async sharedBaseActions({ action }: { action: string }) {
const actionMenu = ['reload', 'copy url', 'open tab', 'copy embed code'];
const index = actionMenu.indexOf(action);
await this.getSharedBaseSubModal().locator(`button.ant-btn-icon-only`).nth(index).click();
}
async openRowActionMenu({ description }: { description: string }) {
const userRow = this.get().locator(`tr:has-text("${description}")`);
return userRow.locator(`.nc-token-menu`).click();
}
async sharedBaseRole({ role }: { role: string }) {
// editor | viewer
// await this.getSharedBaseSubModal()
// .locator(`.nc-shared-base-role`)
// .waitFor();
await this.getSharedBaseSubModal().locator(`.nc-shared-base-role:visible`).click();
const userRoleModal = await this.rootPage.locator(`.nc-dropdown-share-base-role:visible`);
await userRoleModal.locator(`.ant-select-item-option-content:has-text("${role}"):visible`).click();
}
*/
async deleteToken({ description }: { description: string }) {
await this.openRowActionMenu({ description });
await this.rootPage.locator('[data-testid="nc-token-row-action-icon"] .nc-delete-token').click();
await this.rootPage.locator('.ant-modal-confirm-confirm button:has-text("Ok")').click();
await this.verifyToast({ message: 'Token deleted successfully' });
}
}

106
tests/playwright/pages/Account/Users.ts

@ -1,4 +1,4 @@
import { Locator } from '@playwright/test';
import { Locator } from '@playwright/test';
import BasePage from '../Base';
import { AccountPage } from './index';
@ -10,7 +10,7 @@ export class AccountUsersPage extends BasePage {
constructor(accountPage: AccountPage) {
super(accountPage.rootPage);
this.accountPage = accountPage;
this.inviteTeamBtn = this.get().locator(`[data-cy="nc-super-user-invite"]`);
this.inviteTeamBtn = this.get().locator(`[data-testid="nc-super-user-invite"]`);
this.inviteTeamModal = accountPage.rootPage.locator(`.nc-modal-invite-user`);
}
@ -19,7 +19,7 @@ export class AccountUsersPage extends BasePage {
}
get() {
return this.accountPage.get().locator(`[data-cy="nc-super-user-list"]`);
return this.accountPage.get().locator(`[data-testid="nc-super-user-list"]`);
}
async invite({ email: _email, role }: { email: string; role: string }) {
@ -46,90 +46,36 @@ export class AccountUsersPage extends BasePage {
await this.inviteTeamModal.locator(`button.ant-btn-icon-only:visible`).first().click();
}
getUserRow({ email: _email }: { email: string }) {
getUserRow({ email: _email }: { email: string }) {
const email = this.prefixEmail(_email);
return this.get().locator(`tr:has-text("${email}")`);
}
async updateRole({ email: _email, role }: { email: string; role: string }) {
const email = this.prefixEmail(_email);
async updateRole({ email, role }: { email: string; role: string }) {
const userRow = this.getUserRow({ email });
await userRow.locator(`.nc-user-roles`).click();
await this.rootPage.locator(`.nc-role-option:has-text("${role}")`).click();
// todo: replace delay with waitForSelector
await new Promise(resolve => setTimeout(resolve, 400));
await this.rootPage.locator(`.nc-users-list-role-option:visible:has-text("${role}")`).click();
await this.verifyToast({ message: 'Successfully updated the user details' });
}
/*
getSharedBaseSubModal() {
return this.rootPage.locator(`[data-nc="nc-share-base-sub-modal"]`);
}
async invite({ email, role }: { email: string; role: string }) {
email = this.prefixEmail(email);
await this.inviteTeamBtn.click();
await this.inviteTeamModal.locator(`input[placeholder="E-mail"]`).fill(email);
await this.inviteTeamModal.locator(`.nc-user-roles`).click();
const userRoleModal = this.rootPage.locator(`.nc-dropdown-user-role`);
await userRoleModal.locator(`.nc-role-option:has-text("${role}")`).click();
await this.inviteTeamModal.locator(`button:has-text("Invite")`).click();
await this.verifyToast({ message: 'Successfully updated the user details' });
return await this.inviteTeamModal.locator(`.ant-alert-message`).innerText();
}
async closeInvite() {
// two btn-icon-only in invite modal: close & copy url
await this.inviteTeamModal.locator(`button.ant-btn-icon-only:visible`).first().click();
}
async inviteMore() {
await this.inviteTeamModal.locator(`button:has-text("Invite More")`).click();
}
async toggleSharedBase({ toggle }: { toggle: boolean }) {
const toggleBtn = await this.getSharedBaseSubModal().locator(`.nc-disable-shared-base`);
const toggleBtnText = await toggleBtn.first().innerText();
const disabledBase = toggleBtnText.includes('Disable');
if (disabledBase) {
if (toggle) {
// if share base was disabled && request was to enable
await toggleBtn.click();
const modal = await this.rootPage.locator(`.nc-dropdown-shared-base-toggle`);
await modal.locator(`.ant-dropdown-menu-title-content`).click();
}
} else {
if (!toggle) {
// if share base was enabled && request was to disable
await toggleBtn.click();
const modal = await this.rootPage.locator(`.nc-dropdown-shared-base-toggle`);
await modal.locator(`.ant-dropdown-menu-title-content`).click();
}
}
}
async getSharedBaseUrl() {
const url = await this.getSharedBaseSubModal().locator(`.nc-url:visible`).innerText();
return url;
}
async sharedBaseActions({ action }: { action: string }) {
const actionMenu = ['reload', 'copy url', 'open tab', 'copy embed code'];
const index = actionMenu.indexOf(action);
await this.getSharedBaseSubModal().locator(`button.ant-btn-icon-only`).nth(index).click();
}
async sharedBaseRole({ role }: { role: string }) {
// editor | viewer
// await this.getSharedBaseSubModal()
// .locator(`.nc-shared-base-role`)
// .waitFor();
await this.getSharedBaseSubModal().locator(`.nc-shared-base-role:visible`).click();
const userRoleModal = await this.rootPage.locator(`.nc-dropdown-share-base-role:visible`);
await userRoleModal.locator(`.ant-select-item-option-content:has-text("${role}"):visible`).click();
}
*/
async inviteMore() {
await this.inviteTeamModal.locator(`button:has-text("Invite More")`).click();
}
async openRowActionMenu({ email }: { email: string }) {
const userRow = this.getUserRow({ email });
return userRow.locator(`.nc-user-row-action`).click();
}
async deleteUser({ email }: { email: string }) {
await this.openRowActionMenu({ email });
await this.rootPage.locator('[data-testid="nc-super-user-delete"]:visible').click();
await this.rootPage.locator('.ant-modal-confirm-confirm button:has-text("Ok")').click();
await this.verifyToast({ message: 'User deleted successfully' });
}
}

155
tests/playwright/tests/accountTokenManagement.spec.ts

@ -1,139 +1,24 @@
import { test } from '@playwright/test'
import { AccountPage } from '../pages/Account'
import { AccountTokenPage } from '../pages/Account/Token'
import { AccountUsersPage } from '../pages/Account/Users'
import setup from '../setup'
const roleDb = [
{ email: 'creator@nocodb.com', role: 'Organization level creator', url: '' },
{ email: 'viewer@nocodb.com', role: 'Organization level viewer', url: '' },
]
import { test } from '@playwright/test';
import { AccountPage } from '../pages/Account';
import { AccountTokenPage } from '../pages/Account/Token';
import setup from '../setup';
test.describe('User roles', () => {
// let dashboard: DashboardPage;
// let settings: SettingsPage;
// let signupPage: SignupPage;
let accountTokenPage: AccountTokenPage
let accountPage: AccountPage
let context: any
let accountTokenPage: AccountTokenPage;
let accountPage: AccountPage;
// @ts-ignore
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page })
accountPage = new AccountPage(page)
accountTokenPage = new AccountTokenPage(accountPage)
})
test('Invite user', async () => {
test.slow()
await accountTokenPage.goto()
await accountTokenPage.createToken({description: 'test token'})
// for (let i = 0; i < roleDb.length; i++) {
// roleDb[i].url = await accountTokenPage.invite({
// email: roleDb[i].email,
// role: roleDb[i].role,
// });
// await accountTokenPage.closeInvite();
// }
// for (let i = 0; i < roleDb.length; i++) {
// await accountTokenPage.getUserRow({
// email: roleDb[i].email,
// })
// }
// close 'Team & Auth' tab
// await dashboard.gotoSettings();
// await settings.selectTab({ tab: SettingTab.TeamAuth });
// for (let i = 0; i < roleDb.length; i++) {
// roleDb[i].url = await settings.teams.invite({
// email: roleDb[i].email,
// role: roleDb[i].role,
// });
// await settings.teams.closeInvite();
// }
// await settings.close();
//
// // configure access control
// await dashboard.gotoSettings();
// await settings.selectTab({
// tab: SettingTab.ProjectMetadata,
// subTab: SettingsSubTab.ACL,
// });
// await settings.acl.toggle({ table: 'Language', role: 'editor' });
// await settings.acl.toggle({ table: 'Language', role: 'commenter' });
// await settings.acl.toggle({ table: 'Language', role: 'viewer' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'editor' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'commenter' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'viewer' });
// await settings.acl.save();
// await settings.close();
//
// // Role test
// for (let i = 0; i < roleDb.length; i++) {
// await roleTest(i);
// }
})
//
// async function roleTest(roleIdx: number) {
// await roleSignup(roleIdx);
// await dashboard.validateProjectMenu({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.treeView.openTable({ title: 'Country' });
//
// await dashboard.viewSidebar.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.toolbar.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.treeView.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.openExpandedRow({ index: 0 });
// await dashboard.expandedForm.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// // Access control validation
// await dashboard.treeView.verifyTable({
// title: 'Language',
// exists: roleDb[roleIdx].role === 'creator' ? true : false,
// });
// await dashboard.treeView.verifyTable({
// title: 'CustomerList',
// exists: roleDb[roleIdx].role === 'creator' ? true : false,
// });
// }
//
// async function roleSignup(roleIdx: number) {
// await dashboard.signOut();
//
// await dashboard.rootPage.goto(roleDb[roleIdx].url);
// await signupPage.signUp({
// email: roleDb[roleIdx].email,
// password: 'Password123.',
// });
//
// await projectsPage.openProject({
// title: context.project.title,
// waitForAuthTab: roleDb[roleIdx].role === 'creator',
// withoutPrefix: true,
// });
//
// // close 'Team & Auth' tab
// if (roleDb[roleIdx].role === 'creator') {
// await dashboard.closeTab({ title: 'Team & Auth' });
// }
// }
})
context = await setup({ page });
accountPage = new AccountPage(page);
accountTokenPage = new AccountTokenPage(accountPage);
});
test('Create and Delete token', async () => {
test.slow();
await accountTokenPage.goto();
await accountTokenPage.createToken({ description: 'test token' });
await accountTokenPage.deleteToken({ description: 'test token' });
});
});

144
tests/playwright/tests/accountUserManagement.spec.ts

@ -1,35 +1,31 @@
import { test } from '@playwright/test'
import { AccountPage } from '../pages/Account'
import { AccountUsersPage } from '../pages/Account/Users'
import { DashboardPage } from '../pages/Dashboard'
import setup from '../setup'
import { SettingsPage, SettingsSubTab, SettingTab } from '../pages/Dashboard/Settings'
import { SignupPage } from '../pages/SignupPage'
import { test } from '@playwright/test';
import { AccountPage } from '../pages/Account';
import { AccountUsersPage } from '../pages/Account/Users';
import setup from '../setup';
const roleDb = [
{ email: 'creator@nocodb.com', role: 'Organization level creator', url: '' },
{ email: 'viewer@nocodb.com', role: 'Organization level viewer', url: '' },
]
];
test.describe('User roles', () => {
// let dashboard: DashboardPage;
// let settings: SettingsPage;
// let signupPage: SignupPage;
let accountUsersPage: AccountUsersPage
let accountPage: AccountPage
let context: any
let accountUsersPage: AccountUsersPage;
let accountPage: AccountPage;
// @ts-ignore
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page })
accountPage = new AccountPage(page)
accountUsersPage = new AccountUsersPage(accountPage)
})
context = await setup({ page });
accountPage = new AccountPage(page);
accountUsersPage = new AccountUsersPage(accountPage);
});
test.only('Invite user', async () => {
test.slow()
test('Invite user, update role and delete user', async () => {
test.slow();
await accountUsersPage.goto()
await accountUsersPage.goto();
// invite user
for (let i = 0; i < roleDb.length; i++) {
roleDb[i].url = await accountUsersPage.invite({
email: roleDb[i].email,
@ -37,104 +33,20 @@ test.describe('User roles', () => {
});
await accountUsersPage.closeInvite();
}
// update role
for (let i = 0; i < roleDb.length; i++) {
await accountUsersPage.updateRole({
email: roleDb[i].email,
role: 'Organization level viewer',
})
});
}
// close 'Team & Auth' tab
// await dashboard.gotoSettings();
// await settings.selectTab({ tab: SettingTab.TeamAuth });
// for (let i = 0; i < roleDb.length; i++) {
// roleDb[i].url = await settings.teams.invite({
// email: roleDb[i].email,
// role: roleDb[i].role,
// });
// await settings.teams.closeInvite();
// }
// await settings.close();
//
// // configure access control
// await dashboard.gotoSettings();
// await settings.selectTab({
// tab: SettingTab.ProjectMetadata,
// subTab: SettingsSubTab.ACL,
// });
// await settings.acl.toggle({ table: 'Language', role: 'editor' });
// await settings.acl.toggle({ table: 'Language', role: 'commenter' });
// await settings.acl.toggle({ table: 'Language', role: 'viewer' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'editor' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'commenter' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'viewer' });
// await settings.acl.save();
// await settings.close();
//
// // Role test
// for (let i = 0; i < roleDb.length; i++) {
// await roleTest(i);
// }
})
//
// async function roleTest(roleIdx: number) {
// await roleSignup(roleIdx);
// await dashboard.validateProjectMenu({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.treeView.openTable({ title: 'Country' });
//
// await dashboard.viewSidebar.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.toolbar.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.treeView.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.openExpandedRow({ index: 0 });
// await dashboard.expandedForm.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// // Access control validation
// await dashboard.treeView.verifyTable({
// title: 'Language',
// exists: roleDb[roleIdx].role === 'creator' ? true : false,
// });
// await dashboard.treeView.verifyTable({
// title: 'CustomerList',
// exists: roleDb[roleIdx].role === 'creator' ? true : false,
// });
// }
//
// async function roleSignup(roleIdx: number) {
// await dashboard.signOut();
//
// await dashboard.rootPage.goto(roleDb[roleIdx].url);
// await signupPage.signUp({
// email: roleDb[roleIdx].email,
// password: 'Password123.',
// });
//
// await projectsPage.openProject({
// title: context.project.title,
// waitForAuthTab: roleDb[roleIdx].role === 'creator',
// withoutPrefix: true,
// });
//
// // close 'Team & Auth' tab
// if (roleDb[roleIdx].role === 'creator') {
// await dashboard.closeTab({ title: 'Team & Auth' });
// }
// }
})
// delete user
for (let i = 0; i < roleDb.length; i++) {
await accountUsersPage.deleteUser({
email: roleDb[i].email,
});
}
});
});

159
tests/playwright/tests/accountUserSettings.spec.ts

@ -1,137 +1,28 @@
import { test } from '@playwright/test'
import { AccountPage } from '../pages/Account'
import { AccountUsersPage } from '../pages/Account/Users'
import setup from '../setup'
import { test } from '@playwright/test';
import { AccountPage } from '../pages/Account';
import { AccountSettingsPage } from '../pages/Account/Settings';
import setup from '../setup';
const roleDb = [
{ email: 'creator@nocodb.com', role: 'Organization level creator', url: '' },
{ email: 'viewer@nocodb.com', role: 'Organization level viewer', url: '' },
]
test.describe('User roles', () => {
// let dashboard: DashboardPage;
// let settings: SettingsPage;
// let signupPage: SignupPage;
let accountUsersPage: AccountUsersPage
let accountPage: AccountPage
let context: any
test.describe('App settings', () => {
let accountSettingsPage: AccountSettingsPage;
let accountPage: AccountPage;
// @ts-ignore
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page })
accountPage = new AccountPage(page)
accountUsersPage = new AccountUsersPage(accountPage)
})
test('Invite user', async () => {
test.slow()
await accountUsersPage.goto()
for (let i = 0; i < roleDb.length; i++) {
roleDb[i].url = await accountUsersPage.invite({
email: roleDb[i].email,
role: roleDb[i].role,
});
await accountUsersPage.closeInvite();
}
for (let i = 0; i < roleDb.length; i++) {
await accountUsersPage.getUserRow({
email: roleDb[i].email,
})
}
// close 'Team & Auth' tab
// await dashboard.gotoSettings();
// await settings.selectTab({ tab: SettingTab.TeamAuth });
// for (let i = 0; i < roleDb.length; i++) {
// roleDb[i].url = await settings.teams.invite({
// email: roleDb[i].email,
// role: roleDb[i].role,
// });
// await settings.teams.closeInvite();
// }
// await settings.close();
//
// // configure access control
// await dashboard.gotoSettings();
// await settings.selectTab({
// tab: SettingTab.ProjectMetadata,
// subTab: SettingsSubTab.ACL,
// });
// await settings.acl.toggle({ table: 'Language', role: 'editor' });
// await settings.acl.toggle({ table: 'Language', role: 'commenter' });
// await settings.acl.toggle({ table: 'Language', role: 'viewer' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'editor' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'commenter' });
// await settings.acl.toggle({ table: 'CustomerList', role: 'viewer' });
// await settings.acl.save();
// await settings.close();
//
// // Role test
// for (let i = 0; i < roleDb.length; i++) {
// await roleTest(i);
// }
})
//
// async function roleTest(roleIdx: number) {
// await roleSignup(roleIdx);
// await dashboard.validateProjectMenu({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.treeView.openTable({ title: 'Country' });
//
// await dashboard.viewSidebar.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.toolbar.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.treeView.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// await dashboard.grid.openExpandedRow({ index: 0 });
// await dashboard.expandedForm.validateRoleAccess({
// role: roleDb[roleIdx].role,
// });
//
// // Access control validation
// await dashboard.treeView.verifyTable({
// title: 'Language',
// exists: roleDb[roleIdx].role === 'creator' ? true : false,
// });
// await dashboard.treeView.verifyTable({
// title: 'CustomerList',
// exists: roleDb[roleIdx].role === 'creator' ? true : false,
// });
// }
//
// async function roleSignup(roleIdx: number) {
// await dashboard.signOut();
//
// await dashboard.rootPage.goto(roleDb[roleIdx].url);
// await signupPage.signUp({
// email: roleDb[roleIdx].email,
// password: 'Password123.',
// });
//
// await projectsPage.openProject({
// title: context.project.title,
// waitForAuthTab: roleDb[roleIdx].role === 'creator',
// withoutPrefix: true,
// });
//
// // close 'Team & Auth' tab
// if (roleDb[roleIdx].role === 'creator') {
// await dashboard.closeTab({ title: 'Team & Auth' });
// }
// }
})
context = await setup({ page });
accountPage = new AccountPage(page);
accountSettingsPage = new AccountSettingsPage(accountPage);
});
test('Toggle invite only signup', async () => {
test.slow();
await accountSettingsPage.goto();
await accountSettingsPage.checkInviteOnlySignupCheckbox(false);
await accountSettingsPage.toggleInviteOnlyCheckbox();
await accountSettingsPage.checkInviteOnlySignupCheckbox(true);
await accountSettingsPage.toggleInviteOnlyCheckbox();
await accountSettingsPage.checkInviteOnlySignupCheckbox(false);
});
});

Loading…
Cancel
Save