Browse Source

test(playwright): signup and verify create project button exist or not based on role

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
ede2ca243b
  1. 4
      tests/playwright/pages/ProjectsPage/index.ts
  2. 26
      tests/playwright/tests/accountUserManagement.spec.ts

4
tests/playwright/pages/ProjectsPage/index.ts

@ -54,6 +54,10 @@ export class ProjectsPage extends BasePage {
await this.rootPage.waitForTimeout(2000);
}
async checkProjectCreateButton({ exists = true }) {
await expect(this.rootPage.locator('.nc-new-project-menu:visible')).toHaveCount(exists ? 1 : 0);
}
async reloadProjects() {
const reloadUiAction = this.get().locator('[data-testid="projects-reload-button"]').click();
await this.waitForResponse({

26
tests/playwright/tests/accountUserManagement.spec.ts

@ -1,6 +1,8 @@
import { test } from '@playwright/test';
import { AccountPage } from '../pages/Account';
import { AccountUsersPage } from '../pages/Account/Users';
import { ProjectsPage } from '../pages/ProjectsPage';
import { SignupPage } from '../pages/SignupPage';
import setup from '../setup';
const roleDb = [
@ -11,6 +13,8 @@ const roleDb = [
test.describe('User roles', () => {
let accountUsersPage: AccountUsersPage;
let accountPage: AccountPage;
let signupPage: SignupPage;
let projectsPage: ProjectsPage;
// @ts-ignore
let context: any;
@ -18,6 +22,9 @@ test.describe('User roles', () => {
context = await setup({ page });
accountPage = new AccountPage(page);
accountUsersPage = new AccountUsersPage(accountPage);
signupPage = new SignupPage(accountPage.rootPage);
projectsPage = new ProjectsPage(accountPage.rootPage);
});
test('Invite user, update role and delete user', async () => {
@ -32,6 +39,9 @@ test.describe('User roles', () => {
role: roleDb[i].role,
});
await accountUsersPage.closeInvite();
await signupAndVerify(i);
await accountPage.rootPage.reload({ waitUntil: 'networkidle' });
await accountUsersPage.goto();
}
// update role
@ -49,4 +59,20 @@ test.describe('User roles', () => {
});
}
});
// signup and verify create project button exist or not based on role
async function signupAndVerify(roleIdx: number) {
await accountPage.signOut();
await accountPage.rootPage.goto(roleDb[roleIdx].url);
await signupPage.signUp({
email: roleDb[roleIdx].email,
password: 'Password123.',
});
await projectsPage.checkProjectCreateButton({
exists: roleDb[roleIdx].role === 'Organization Level Creator',
});
}
});

Loading…
Cancel
Save