|
|
@ -3,23 +3,77 @@ import { DashboardPage } from '../../../pages/Dashboard'; |
|
|
|
import setup, { unsetup } from '../../../setup'; |
|
|
|
import setup, { unsetup } from '../../../setup'; |
|
|
|
import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar'; |
|
|
|
import { ToolbarPage } from '../../../pages/Dashboard/common/Toolbar'; |
|
|
|
import { SettingsPage, SettingTab } from '../../../pages/Dashboard/Settings'; |
|
|
|
import { SettingsPage, SettingTab } from '../../../pages/Dashboard/Settings'; |
|
|
|
|
|
|
|
import { Api } from 'nocodb-sdk'; |
|
|
|
|
|
|
|
import { AccountUsersPage } from '../../../pages/Account/Users'; |
|
|
|
|
|
|
|
import { AccountPage } from '../../../pages/Account'; |
|
|
|
|
|
|
|
import { LoginPage } from '../../../pages/LoginPage'; |
|
|
|
|
|
|
|
import { isEE } from '../../../setup/db'; |
|
|
|
|
|
|
|
let api: Api<any>; |
|
|
|
|
|
|
|
|
|
|
|
const roles = ['Editor', 'Commenter', 'Viewer']; |
|
|
|
const roles = ['Editor', 'Commenter', 'Viewer']; |
|
|
|
|
|
|
|
|
|
|
|
test.describe.skip('Preview Mode', () => { |
|
|
|
test.describe('Preview Mode', () => { |
|
|
|
test.slow(); |
|
|
|
test.slow(); |
|
|
|
|
|
|
|
|
|
|
|
let dashboard: DashboardPage; |
|
|
|
let dashboard: DashboardPage; |
|
|
|
let toolbar: ToolbarPage; |
|
|
|
let toolbar: ToolbarPage; |
|
|
|
let settings: SettingsPage; |
|
|
|
let settings: SettingsPage; |
|
|
|
|
|
|
|
let accountPage: AccountPage; |
|
|
|
|
|
|
|
let accountUsersPage: AccountUsersPage; |
|
|
|
|
|
|
|
let loginPage: LoginPage; |
|
|
|
|
|
|
|
|
|
|
|
let context: any; |
|
|
|
let context: any; |
|
|
|
|
|
|
|
let userEmail = ''; |
|
|
|
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => { |
|
|
|
test.beforeEach(async ({ page }) => { |
|
|
|
context = await setup({ page, isEmptyProject: false }); |
|
|
|
context = await setup({ page, isEmptyProject: false }); |
|
|
|
dashboard = new DashboardPage(page, context.base); |
|
|
|
dashboard = new DashboardPage(page, context.base); |
|
|
|
toolbar = dashboard.grid.toolbar; |
|
|
|
toolbar = dashboard.grid.toolbar; |
|
|
|
settings = dashboard.settings; |
|
|
|
settings = dashboard.settings; |
|
|
|
|
|
|
|
accountPage = new AccountPage(page); |
|
|
|
|
|
|
|
accountUsersPage = new AccountUsersPage(accountPage); |
|
|
|
|
|
|
|
loginPage = new LoginPage(accountPage.rootPage); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
api = new Api({ |
|
|
|
|
|
|
|
baseURL: `http://localhost:8080/`, |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-auth': context.token, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userEmail = accountUsersPage.prefixEmail('uiACL@nocodb.com'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// check if user already exists; if so- remove them
|
|
|
|
|
|
|
|
const user = await api.auth.baseUserList(context.base.id); |
|
|
|
|
|
|
|
if (user.users.list.length > 0) { |
|
|
|
|
|
|
|
const u = user.users.list.find((u: any) => u.email === userEmail); |
|
|
|
|
|
|
|
if (u) { |
|
|
|
|
|
|
|
await api.auth.baseUserRemove(context.base.id, u.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create user if not exists
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
await api.auth.signup({ |
|
|
|
|
|
|
|
email: userEmail, |
|
|
|
|
|
|
|
password: '12345678', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await api.auth.baseUserAdd(context.base.id, { |
|
|
|
|
|
|
|
roles: 'editor', |
|
|
|
|
|
|
|
email: userEmail, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
// ignore error
|
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test.afterEach(async () => { |
|
|
|
test.afterEach(async () => { |
|
|
@ -27,6 +81,8 @@ test.describe.skip('Preview Mode', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Preview Mode', async () => { |
|
|
|
test('Preview Mode', async () => { |
|
|
|
|
|
|
|
if (!isEE()) test.skip(); |
|
|
|
|
|
|
|
|
|
|
|
// close 'Team & Auth' tab
|
|
|
|
// close 'Team & Auth' tab
|
|
|
|
await dashboard.closeTab({ title: 'Team & Auth' }); |
|
|
|
await dashboard.closeTab({ title: 'Team & Auth' }); |
|
|
|
|
|
|
|
|
|
|
@ -36,7 +92,7 @@ test.describe.skip('Preview Mode', () => { |
|
|
|
await settings.selectTab({ |
|
|
|
await settings.selectTab({ |
|
|
|
tab: SettingTab.DataSources, |
|
|
|
tab: SettingTab.DataSources, |
|
|
|
}); |
|
|
|
}); |
|
|
|
await settings.dataSources.openAcl(); |
|
|
|
await settings.dataSources.openAcl({ dataSourceName: 'Default' }); |
|
|
|
await settings.dataSources.acl.toggle({ table: 'Language', role: 'editor' }); |
|
|
|
await settings.dataSources.acl.toggle({ table: 'Language', role: 'editor' }); |
|
|
|
await settings.dataSources.acl.toggle({ table: 'Language', role: 'commenter' }); |
|
|
|
await settings.dataSources.acl.toggle({ table: 'Language', role: 'commenter' }); |
|
|
|
await settings.dataSources.acl.toggle({ table: 'Language', role: 'viewer' }); |
|
|
|
await settings.dataSources.acl.toggle({ table: 'Language', role: 'viewer' }); |
|
|
@ -46,64 +102,39 @@ test.describe.skip('Preview Mode', () => { |
|
|
|
await settings.dataSources.acl.save(); |
|
|
|
await settings.dataSources.acl.save(); |
|
|
|
await settings.close(); |
|
|
|
await settings.close(); |
|
|
|
|
|
|
|
|
|
|
|
// Role test
|
|
|
|
await dashboard.gotoSettings(); |
|
|
|
for (let i = 0; i < roles.length; i++) { |
|
|
|
await settings.selectTab({ |
|
|
|
await roleTest(roles[i]); |
|
|
|
tab: SettingTab.DataSources, |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function roleTest(role: string) { |
|
|
|
|
|
|
|
await dashboard.grid.workspaceMenu.toggle(); |
|
|
|
|
|
|
|
await dashboard.grid.workspaceMenu.click({ |
|
|
|
|
|
|
|
menu: 'Preview as', |
|
|
|
|
|
|
|
subMenu: role, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wait for preview mode to be enabled
|
|
|
|
|
|
|
|
await dashboard.rootPage.locator('.nc-preview-btn-exit-to-app').waitFor(); |
|
|
|
|
|
|
|
// todo: Otherwise grid will be stuck at loading even tho the data is loaded
|
|
|
|
|
|
|
|
await dashboard.rootPage.waitForTimeout(2500); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await dashboard.validateWorkspaceMenu({ |
|
|
|
|
|
|
|
role: role.toLowerCase(), |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
await settings.dataSources.openAcl({ dataSourceName: 'Default' }); |
|
|
|
|
|
|
|
|
|
|
|
await dashboard.rootPage.waitForTimeout(1500); |
|
|
|
await settings.dataSources.acl.verify({ table: 'Language', role: 'editor', expectedValue: false }); |
|
|
|
|
|
|
|
await settings.dataSources.acl.verify({ table: 'Language', role: 'commenter', expectedValue: false }); |
|
|
|
|
|
|
|
await settings.dataSources.acl.verify({ table: 'Language', role: 'viewer', expectedValue: false }); |
|
|
|
|
|
|
|
await settings.dataSources.acl.verify({ table: 'CustomerList', role: 'editor', expectedValue: false }); |
|
|
|
|
|
|
|
await settings.dataSources.acl.verify({ table: 'CustomerList', role: 'commenter', expectedValue: false }); |
|
|
|
|
|
|
|
await settings.dataSources.acl.verify({ table: 'CustomerList', role: 'viewer', expectedValue: false }); |
|
|
|
|
|
|
|
|
|
|
|
await dashboard.treeView.openTable({ title: 'Country', networkResponse: false }); |
|
|
|
await settings.close(); |
|
|
|
|
|
|
|
await dashboard.signOut(); |
|
|
|
await dashboard.viewSidebar.validateRoleAccess({ |
|
|
|
|
|
|
|
role: role.toLowerCase(), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await toolbar.verifyRoleAccess({ |
|
|
|
|
|
|
|
role: role.toLowerCase(), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await dashboard.treeView.validateRoleAccess({ |
|
|
|
|
|
|
|
role: role.toLowerCase(), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await dashboard.grid.verifyRoleAccess({ |
|
|
|
await loginPage.signIn({ |
|
|
|
role: role.toLowerCase(), |
|
|
|
email: userEmail, |
|
|
|
|
|
|
|
password: '12345678', |
|
|
|
|
|
|
|
withoutPrefix: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await dashboard.grid.openExpandedRow({ index: 0 }); |
|
|
|
await dashboard.treeView.verifyTable({ |
|
|
|
await dashboard.expandedForm.verifyRoleAccess({ |
|
|
|
title: 'Actor', |
|
|
|
role: role.toLowerCase(), |
|
|
|
exists: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Access control validation
|
|
|
|
|
|
|
|
await dashboard.treeView.verifyTable({ |
|
|
|
await dashboard.treeView.verifyTable({ |
|
|
|
title: 'Language', |
|
|
|
title: 'Language', |
|
|
|
exists: role.toLowerCase() === 'creator' ? true : false, |
|
|
|
exists: false, |
|
|
|
}); |
|
|
|
}); |
|
|
|
await dashboard.treeView.verifyTable({ |
|
|
|
await dashboard.treeView.verifyTable({ |
|
|
|
title: 'CustomerList', |
|
|
|
title: 'CustomerList', |
|
|
|
exists: role.toLowerCase() === 'creator' ? true : false, |
|
|
|
exists: false, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// close preview mode
|
|
|
|
|
|
|
|
await dashboard.rootPage.locator('.nc-preview-btn-exit-to-app').click(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|