|
|
@ -1,32 +1,55 @@ |
|
|
|
import { test } from '@playwright/test'; |
|
|
|
import { expect, test } from '@playwright/test'; |
|
|
|
import { AccountPage } from '../../../pages/Account'; |
|
|
|
import { AccountPage } from '../../../pages/Account'; |
|
|
|
import { AccountUsersPage } from '../../../pages/Account/Users'; |
|
|
|
import { AccountUsersPage } from '../../../pages/Account/Users'; |
|
|
|
import { SignupPage } from '../../../pages/SignupPage'; |
|
|
|
import { SignupPage } from '../../../pages/SignupPage'; |
|
|
|
import setup, { unsetup } from '../../../setup'; |
|
|
|
import setup, { unsetup } from '../../../setup'; |
|
|
|
import { WorkspacePage } from '../../../pages/WorkspacePage'; |
|
|
|
|
|
|
|
import { getDefaultPwd } from '../../../tests/utils/general'; |
|
|
|
import { getDefaultPwd } from '../../../tests/utils/general'; |
|
|
|
|
|
|
|
import { Api } from 'nocodb-sdk'; |
|
|
|
|
|
|
|
import { DashboardPage } from '../../../pages/Dashboard'; |
|
|
|
import { LoginPage } from '../../../pages/LoginPage'; |
|
|
|
import { LoginPage } from '../../../pages/LoginPage'; |
|
|
|
|
|
|
|
let api: Api<any>; |
|
|
|
|
|
|
|
|
|
|
|
const roleDb = [ |
|
|
|
const roleDb = [ |
|
|
|
{ email: 'creator@nocodb.com', role: 'Organization Level Creator', url: '' }, |
|
|
|
{ email: 'org_creator@nocodb.com', role: 'Organization Level Creator', url: '' }, |
|
|
|
{ email: 'viewer@nocodb.com', role: 'Organization Level Viewer', url: '' }, |
|
|
|
{ email: 'org_viewer@nocodb.com', role: 'Organization Level Viewer', url: '' }, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
test.describe.skip('User roles', () => { |
|
|
|
test.describe('User roles', () => { |
|
|
|
let accountUsersPage: AccountUsersPage; |
|
|
|
let accountUsersPage: AccountUsersPage; |
|
|
|
let accountPage: AccountPage; |
|
|
|
let accountPage: AccountPage; |
|
|
|
let signupPage: SignupPage; |
|
|
|
let signupPage: SignupPage; |
|
|
|
let workspacePage: WorkspacePage; |
|
|
|
let loginPage: LoginPage; |
|
|
|
|
|
|
|
let dashboard: DashboardPage; |
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
let context: any; |
|
|
|
let context: any; |
|
|
|
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => { |
|
|
|
test.beforeEach(async ({ page }) => { |
|
|
|
context = await setup({ page, isEmptyProject: true }); |
|
|
|
context = await setup({ page, isEmptyProject: true, isSuperUser: true }); |
|
|
|
|
|
|
|
dashboard = new DashboardPage(page, context.project); |
|
|
|
accountPage = new AccountPage(page); |
|
|
|
accountPage = new AccountPage(page); |
|
|
|
accountUsersPage = new AccountUsersPage(accountPage); |
|
|
|
accountUsersPage = new AccountUsersPage(accountPage); |
|
|
|
|
|
|
|
|
|
|
|
signupPage = new SignupPage(accountPage.rootPage); |
|
|
|
signupPage = new SignupPage(accountPage.rootPage); |
|
|
|
workspacePage = new WorkspacePage(accountPage.rootPage); |
|
|
|
loginPage = new LoginPage(accountPage.rootPage); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
api = new Api({ |
|
|
|
|
|
|
|
baseURL: `http://localhost:8080/`, |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-auth': context.token, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if user already exists; if so- remove them
|
|
|
|
|
|
|
|
for (let i = 0; i < roleDb.length; i++) { |
|
|
|
|
|
|
|
const user = await api.orgUsers.list(); |
|
|
|
|
|
|
|
if (user.list.length > 0) { |
|
|
|
|
|
|
|
const u = user.list.find((u: any) => u.email === roleDb[i].email); |
|
|
|
|
|
|
|
if (u) await api.orgUsers.delete(u.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test.afterEach(async () => { |
|
|
|
test.afterEach(async () => { |
|
|
@ -45,18 +68,21 @@ test.describe.skip('User roles', () => { |
|
|
|
role: roleDb[i].role, |
|
|
|
role: roleDb[i].role, |
|
|
|
}); |
|
|
|
}); |
|
|
|
await accountUsersPage.closeInvite(); |
|
|
|
await accountUsersPage.closeInvite(); |
|
|
|
await signupAndVerify(i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await accountPage.signOut(); |
|
|
|
|
|
|
|
const loginPage = new LoginPage(accountPage.rootPage); |
|
|
|
|
|
|
|
await loginPage.fillEmail({ email: 'user@nocodb.com', withoutPrefix: true }); |
|
|
|
|
|
|
|
await loginPage.fillPassword(getDefaultPwd()); |
|
|
|
|
|
|
|
await loginPage.submit(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// update role
|
|
|
|
await signupAndVerify(0); |
|
|
|
await accountUsersPage.goto(); |
|
|
|
await accountUsersPage.goto(); |
|
|
|
|
|
|
|
await signupAndVerify(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await dashboard.signOut(); |
|
|
|
|
|
|
|
await loginPage.signIn({ |
|
|
|
|
|
|
|
email: 'user@nocodb.com', |
|
|
|
|
|
|
|
password: getDefaultPwd(), |
|
|
|
|
|
|
|
withoutPrefix: true, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await accountUsersPage.goto(); |
|
|
|
|
|
|
|
// change role
|
|
|
|
for (let i = 0; i < roleDb.length; i++) { |
|
|
|
for (let i = 0; i < roleDb.length; i++) { |
|
|
|
await accountUsersPage.updateRole({ |
|
|
|
await accountUsersPage.updateRole({ |
|
|
|
email: roleDb[i].email, |
|
|
|
email: roleDb[i].email, |
|
|
@ -81,10 +107,16 @@ test.describe.skip('User roles', () => { |
|
|
|
await signupPage.signUp({ |
|
|
|
await signupPage.signUp({ |
|
|
|
email: roleDb[roleIdx].email, |
|
|
|
email: roleDb[roleIdx].email, |
|
|
|
password: getDefaultPwd(), |
|
|
|
password: getDefaultPwd(), |
|
|
|
|
|
|
|
withoutPrefix: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await workspacePage.checkWorkspaceCreateButton({ |
|
|
|
// wait for page rendering to complete after sign up
|
|
|
|
exists: roleDb[roleIdx].role === 'Organization Level Creator', |
|
|
|
await dashboard.rootPage.waitForTimeout(1000); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (roleDb[roleIdx].role === 'Organization Level Creator') { |
|
|
|
|
|
|
|
expect(await dashboard.leftSidebar.btn_newProject.isVisible()).toBeTruthy(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
expect(await dashboard.leftSidebar.btn_newProject.isVisible()).toBeFalsy(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|