Browse Source

fix: corrections and playwright test(WIP)

pull/9807/head
Pranav C 1 week ago
parent
commit
0a0a634ed3
  1. 1
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
  2. 4
      packages/nocodb/src/services/grids.service.ts
  3. 2
      packages/nocodb/src/services/kanbans.service.ts
  4. 4
      packages/nocodb/src/services/views.service.ts
  5. 8
      tests/playwright/pages/Dashboard/Grid/columnHeader.ts
  6. 10
      tests/playwright/pages/Dashboard/Grid/index.ts
  7. 5
      tests/playwright/pages/Dashboard/common/Footbar/index.ts
  8. 8
      tests/playwright/pages/Dashboard/common/Toolbar/index.ts
  9. 111
      tests/playwright/tests/db/general/viewMenu.spec.ts
  10. 2
      tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts

1
packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts

@ -1529,7 +1529,6 @@ export class ImportService {
await this.gridsService.gridViewUpdate(context, {
viewId: gview.id,
grid: gridData,
ownedBy: vw.owned_by,
req,
});
}

4
packages/nocodb/src/services/grids.service.ts

@ -38,8 +38,8 @@ export class GridsService {
type: ViewTypes.GRID,
base_id: model.base_id,
source_id: model.source_id,
created_by: param.user.id,
owned_by: param.ownedBy || param.user.id,
created_by: param.req.user?.id,
owned_by: param.ownedBy || param.req.user?.id,
},
model,
);

2
packages/nocodb/src/services/kanbans.service.ts

@ -47,7 +47,7 @@ export class KanbansService {
type: ViewTypes.KANBAN,
base_id: model.base_id,
source_id: model.source_id,
owned_by: param.user?.id,
created_by: param.user?.id,
owned_by: param.ownedBy || param.user?.id,
},
model,

4
packages/nocodb/src/services/views.service.ts

@ -185,8 +185,8 @@ export class ViewsService {
// extract user roles and allow creator and owner to change to personal view
if (
param.user.id !== ownedBy &&
!param.user.base_roles?.[ProjectRoles.OWNER] &&
!param.user.base_roles?.[ProjectRoles.CREATOR]
!(param.user as any).base_roles?.[ProjectRoles.OWNER] &&
!(param.user as any).base_roles?.[ProjectRoles.CREATOR]
) {
NcError.unauthorized('Only owner/creator can transfer view ownership');
}

8
tests/playwright/pages/Dashboard/Grid/columnHeader.ts

@ -36,6 +36,14 @@ export class ColumnHeaderPageObject extends BasePage {
expect(await this.get().locator('.nc-ui-dt-dropdown').count()).toBe(0);
}
async verifyPersonalMode() {
// add column button
await expect(this.btn_addColumn).toBeVisible({ visible: false });
// column header context menu
expect(await this.get().locator('.nc-ui-dt-dropdown').count()).toBe(0);
}
async verifyCollaborativeMode() {
// add column button
await expect(this.btn_addColumn).toBeVisible({ visible: true });

10
tests/playwright/pages/Dashboard/Grid/index.ts

@ -77,6 +77,16 @@ export class GridPage extends BasePage {
await this.columnHeader.verifyCollaborativeMode();
}
async verifyPersonalMode() {
// add new row button
expect(await this.btn_addNewRow.count()).toBe(1);
// the behaviour is same as lock mode
await this.toolbar.verifyPersonalMode();
await this.footbar.verifyPersonalMode();
await this.columnHeader.verifyPersonalMode();
}
get() {
return this.dashboard.get().locator('[data-testid="nc-grid-wrapper"]');
}

5
tests/playwright/pages/Dashboard/common/Footbar/index.ts

@ -49,6 +49,11 @@ export class FootbarPage extends BasePage {
await expect(this.btn_addNewRow).toBeVisible({ visible: true });
}
async verifyPersonalMode() {
// add record button
await expect(this.btn_addNewRow).toBeVisible({ visible: true });
}
async verifyCollaborativeMode() {
// add record button
await expect(this.btn_addNewRow).toBeVisible({ visible: true });

8
tests/playwright/pages/Dashboard/common/Toolbar/index.ts

@ -256,6 +256,14 @@ export class ToolbarPage extends BasePage {
await expect(this.btn_rowHeight).toBeDisabled();
}
async verifyPersonalMode() {
await expect(this.btn_fields).toBeDisabled();
await expect(this.btn_filter).toBeDisabled();
await expect(this.btn_sort).toBeDisabled();
await expect(this.btn_groupBy).toBeDisabled();
await expect(this.btn_rowHeight).toBeDisabled();
}
async verifyCollaborativeMode() {
await expect(this.btn_fields).toBeEnabled();
await expect(this.btn_filter).toBeEnabled();

111
tests/playwright/tests/db/general/viewMenu.spec.ts

@ -2,6 +2,12 @@ import { test } from '@playwright/test';
import { DashboardPage } from '../../../pages/Dashboard';
import setup, { unsetup } from '../../../setup';
import { isPg } from '../../../setup/db';
import { getDefaultPwd } from '../../utils/general';
import { AccountPage } from '../../../pages/Account';
import { SignupPage } from '../../../pages/SignupPage';
import { Api } from 'nocodb-sdk';
import { LoginPage } from '../../../pages/LoginPage';
import { AccountUsersPage } from '../../../pages/Account/Users';
test.describe('Grid view locked', () => {
let dashboard: DashboardPage;
@ -39,6 +45,111 @@ test.describe('Grid view locked', () => {
await dashboard.grid.verifyCollaborativeMode();
});
test.describe('Personal mode', () => {
const user1 = {
email: 'view-test-user1@nocodb.com',
password: getDefaultPwd(),
role: 'Organization Level Creator',
};
const user2 = {
email: 'view-test-user2@nocodb.com',
password: getDefaultPwd(),
role: 'Organization Level Viewer',
};
const users = [user1, user2];
let loginPage;
let accountPage;
let accountUsersPage;
let api: Api<any>;
test.beforeEach(async ({ page }) => {
api = new Api({
baseURL: `http://localhost:8080/`,
headers: {
'xc-auth': context.token,
},
});
loginPage = new LoginPage(page);
accountPage = new AccountPage(page);
accountUsersPage = new AccountUsersPage(accountPage);
for (let i = 0; i < users.length; i++) {
try {
await api.auth.signup({
email: loginPage.prefixEmail(users[i].email),
password: users[i].password,
});
} catch (e) {
// ignore error even if user already exists
}
}
});
test.only('Personal mode', async () => {
await accountUsersPage.goto({ waitForResponse: true });
// invite user
for (let i = 0; i < users.length; i++) {
users[i].url = await accountUsersPage.invite({
email: users[i].email,
role: users[i].role,
});
await accountUsersPage.closeInvite();
}
await dashboard.treeView.openTable({ title: 'Country' });
// create a grid view since the default view cannot be marked as personal
await dashboard.viewSidebar.createGridView({ title: 'CountryGrid' });
await dashboard.viewSidebar.verifyView({ title: 'CountryGrid', index: 0 });
await dashboard.grid.verifyCollaborativeMode();
// enable personal view
await dashboard.grid.toolbar.viewsMenu.click({
menu: 'View Mode',
subMenu: 'Personal',
});
await dashboard.treeView.openTable({ title: 'Country' });
// create a grid view since the default view cannot be marked as personal
await dashboard.viewSidebar.createGridView({ title: 'CountryGrid' });
await dashboard.viewSidebar.verifyView({ title: 'CountryGrid', index: 0 });
await dashboard.grid.verifyCollaborativeMode();
// enable personal view
await dashboard.grid.toolbar.viewsMenu.click({
menu: 'View Mode',
subMenu: 'Personal',
});
// verify view lock
// await dashboard.grid.verifyPersonalMode();
await dashboard.signOut();
await loginPage.goto();
await loginPage.signIn({
email: user2.email,
password: user2.password,
});
await dashboard.signOut();
await dashboard.rootPage.goto('/#/signup');
await loginPage.signIn({
email: user1.email,
password: user1.password,
});
// verify view lock
await dashboard.grid.verifyPersonalMode();
});
});
test('Download CSV', async () => {
// close 'Team & Auth' tab
await dashboard.closeTab({ title: 'Team & Auth' });

2
tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts

@ -10,7 +10,7 @@ import { LoginPage } from '../../../pages/LoginPage';
import { isEE } from '../../../setup/db';
let api: Api<any>;
const roleDb = [
const xroleDb = [
{ email: `org_creator_@nocodb.com`, role: 'Organization Level Creator', url: '' },
{ email: `org_viewer_@nocodb.com`, role: 'Organization Level Viewer', url: '' },
];

Loading…
Cancel
Save