Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

test(pw): update toolbar test

Ramesh Mane110a7239134c
diff --git a/packages/nc-gui/components/smartsheet/toolbar/Export.vue b/packages/nc-gui/components/smartsheet/toolbar/Export.vue
index 04bac9fe32..d413177451 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/Export.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/Export.vue
@@ -1,6 +1,6 @@
<template>
<NcDropdown :trigger="['click']" overlay-class-name="nc-dropdown-actions-menu">
- <NcButton v-e="['c:actions']" class="nc-actions-menu-btn nc-toolbar-btn" size="xs" type="secondary">
+ <NcButton v-e="['c:actions']" class="nc-download-actions-menu-btn nc-toolbar-btn" size="xs" type="secondary">
<div class="flex gap-2 items-center text-gray-700">
<component :is="iconMap.download" class="group-hover:text-accent" />
<span class="text-capitalize !text-sm font-medium xs:hidden">{{ $t('general.download') }}</span>
diff --git a/tests/playwright/pages/Dashboard/Grid/index.ts b/tests/playwright/pages/Dashboard/Grid/index.ts
index a82a8d5117..b46f40b179 100644
--- a/tests/playwright/pages/Dashboard/Grid/index.ts
+++ b/tests/playwright/pages/Dashboard/Grid/index.ts
@@ -469,7 +469,7 @@ export class GridPage extends BasePage {
await expect(this.cell.get({ index: 0, columnHeader: 'Cities' }).locator('.nc-action-icon.nc-plus')).toBeVisible();
}
- async verifyRoleAccess(param: { role: string }) {
+ async verifyRoleAccess(param: { role: string; isToolbarOperationsRestricted?: boolean }) {
await this.column.verifyRoleAccess(param);
await this.cell.verifyRoleAccess(param);
await this.toolbar.verifyRoleAccess(param);
diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts
index a6fd9e2cb7..3cd5873452 100644
--- a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts
+++ b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts
@@ -4,7 +4,6 @@ import { ToolbarFieldsPage } from './Fields';
import { ToolbarSortPage } from './Sort';
import { ToolbarFilterPage } from './Filter';
import { ToolbarViewMenuPage } from './ViewMenu';
-import * as fs from 'fs';
import { GridPage } from '../../Grid';
import { ToolbarActionsPage } from './Actions';
import { GalleryPage } from '../../Gallery';
@@ -212,14 +211,14 @@ export class ToolbarPage extends BasePage {
}
async verifyDownloadDisabled() {
- await this.get().locator(`.nc-toolbar-btn.nc-actions-menu-btn`).waitFor({ state: 'hidden' });
+ await this.get().locator(`.nc-toolbar-btn.nc-download-actions-menu-btn`).waitFor({ state: 'hidden' });
}
async clickAddEditStack() {
await this.get().locator(`.nc-kanban-stacked-by-menu-btn`).click();
}
- async validateViewsMenu(param: { role: string; mode?: string }) {
+ async validateViewsMenu(param: { role: string; mode?: string; isToolbarOperationsRestricted?: boolean }) {
const menuItems = {
creator: ['Download', 'Upload'],
editor: ['Download', 'Upload'],
@@ -228,24 +227,39 @@ export class ToolbarPage extends BasePage {
};
const vMenu = this.rootPage.locator('.nc-dropdown-actions-menu:visible');
for (const item of menuItems[param.role.toLowerCase()]) {
- await expect(vMenu).toContainText(item);
+ if (param.isToolbarOperationsRestricted) {
+ await expect(vMenu).not.toContainText(item);
+ } else {
+ await expect(vMenu).toContainText(item);
+ }
+ }
+
+ // If toolbar operations are restricted, then only VIEW ID should be visible
+ if (param.isToolbarOperationsRestricted) {
+ await expect(vMenu).toContainText('VIEW ID');
}
}
- async verifyRoleAccess(param: { role: string; mode?: string }) {
+ async verifyRoleAccess(param: { role: string; mode?: string; isToolbarOperationsRestricted?: boolean }) {
const role = param.role.toLowerCase();
await this.clickActions();
await this.validateViewsMenu({
role: role,
mode: param.mode,
+ isToolbarOperationsRestricted: param.isToolbarOperationsRestricted,
});
await this.clickActions();
- expect(await this.btn_fields.count()).toBe(1);
- expect(await this.btn_filter.count()).toBe(1);
- expect(await this.btn_sort.count()).toBe(1);
- expect(await this.btn_rowHeight.count()).toBe(1);
+ expect(await this.btn_fields.count()).toBe(param.isToolbarOperationsRestricted ? 0 : 1);
+ expect(await this.btn_filter.count()).toBe(param.isToolbarOperationsRestricted ? 0 : 1);
+ expect(await this.btn_sort.count()).toBe(param.isToolbarOperationsRestricted ? 0 : 1);
+ expect(await this.btn_rowHeight.count()).toBe(param.isToolbarOperationsRestricted ? 0 : 1);
+
+ // If toolbar operations are restricted, then download button should be visible
+ expect(await this.get().locator(`.nc-toolbar-btn.nc-download-actions-menu-btn`).count()).toBe(
+ param.isToolbarOperationsRestricted ? 1 : 0
+ );
}
getToolbarBtns() {
diff --git a/tests/playwright/pages/Dashboard/common/Topbar/index.ts b/tests/playwright/pages/Dashboard/common/Topbar/index.ts
index 4fc201ae34..a9d61bcafd 100644
--- a/tests/playwright/pages/Dashboard/common/Topbar/index.ts
+++ b/tests/playwright/pages/Dashboard/common/Topbar/index.ts
@@ -111,7 +111,7 @@ export class TopbarPage extends BasePage {
}
async clickDownload(type: string, verificationFile = 'expectedData.txt') {
- await this.get().locator(`.nc-toolbar-btn.nc-actions-menu-btn`).click();
+ await this.get().locator(`.nc-toolbar-btn.nc-download-actions-menu-btn`).click();
const [download] = await Promise.all([
// Start waiting for the download
diff --git a/tests/playwright/tests/db/general/tableOperations.spec.ts b/tests/playwright/tests/db/general/tableOperations.spec.ts
index a2e36ce279..21319a1e05 100644
--- a/tests/playwright/tests/db/general/tableOperations.spec.ts
+++ b/tests/playwright/tests/db/general/tableOperations.spec.ts
@@ -4,7 +4,6 @@ import { DashboardPage } from '../../../pages/Dashboard';
import { deepCompare } from '../../../tests/utils/objectCompareUtil';
import setup, { unsetup } from '../../../setup';
import { BaseInfoApiUtil, TableInfo } from '../../../tests/utils/baseInfoApiUtil';
-import { isEE } from '../../../setup/db';
import { AuditPage } from '../../../pages/Dashboard/ProjectView/Audit';
test.describe('Table Operations', () => {
diff --git a/tests/playwright/tests/db/usersAccounts/rolesCreate.spec.ts b/tests/playwright/tests/db/usersAccounts/rolesCreate.spec.ts
index d2496c3c8e..34d6dd0b1f 100644
--- a/tests/playwright/tests/db/usersAccounts/rolesCreate.spec.ts
+++ b/tests/playwright/tests/db/usersAccounts/rolesCreate.spec.ts
@@ -7,10 +7,10 @@ import { getDefaultPwd } from '../../../tests/utils/general';
import { isEE } from '../../../setup/db';
const roleDb = [
- { email: '[email protected]', role: 'creator', url: '' },
- { email: '[email protected]', role: 'editor', url: '' },
- { email: '[email protected]', role: 'commenter', url: '' },
- { email: '[email protected]', role: 'viewer', url: '' },
+ { email: '[email protected]', role: 'creator', url: '', isToolbarOperationsRestricted: false },
+ { email: '[email protected]', role: 'editor', url: '', isToolbarOperationsRestricted: false },
+ { email: '[email protected]', role: 'commenter', url: '', isToolbarOperationsRestricted: true },
+ { email: '[email protected]', role: 'viewer', url: '', isToolbarOperationsRestricted: true },
];
test.describe.skip('User roles', () => {
@@ -69,10 +69,12 @@ test.describe.skip('User roles', () => {
await dashboard.treeView.validateRoleAccess({
role: roleDb[roleIdx].role,
+ context,
});
await dashboard.grid.verifyRoleAccess({
role: roleDb[roleIdx].role,
+ isToolbarOperationsRestricted: roleDb[roleIdx].isToolbarOperationsRestricted,
});
await dashboard.grid.openExpandedRow({ index: 0 });