Browse Source

Merge branch 'develop' into feat/pnpm

pull/5903/head
Wing-Kam Wong 2 years ago
parent
commit
32ffd4a535
  1. 5
      packages/nc-gui/pages/index/index/index.vue
  2. 36
      tests/playwright/pages/ProjectsPage/index.ts
  3. 12
      tests/playwright/tests/db/rolesCreate.spec.ts

5
packages/nc-gui/pages/index/index/index.vue

@ -310,14 +310,15 @@ const copyProjectMeta = async () => {
:is="iconMap.edit"
v-if="isUIAllowed('projectUpdate', true) || isUIAllowed('projectUpdate', true, record.roles)"
v-e="['c:project:edit:rename']"
class="nc-action-btn"
class="nc-action-btn nc-edit-project"
:data-testid="`edit-project-${record.title}`"
@click.stop="navigateTo(`/${text}`)"
/>
<component
:is="iconMap.delete"
v-if="isUIAllowed('projectDelete', true) || isUIAllowed('projectDelete', true, record.roles)"
class="nc-action-btn"
class="nc-action-btn nc-delete-project"
:data-testid="`delete-project-${record.title}`"
@click.stop="deleteProject(record)"
/>

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

@ -1,10 +1,21 @@
import { expect, Page } from '@playwright/test';
import { expect, Locator, Page } from '@playwright/test';
import BasePage from '../Base';
import { DashboardPage } from '../Dashboard';
export class ProjectsPage extends BasePage {
readonly buttonEditProject: Locator;
readonly buttonDeleteProject: Locator;
readonly buttonMoreActions: Locator;
readonly buttonNewProject: Locator;
readonly buttonColorSelector: Locator;
constructor(rootPage: Page) {
super(rootPage);
this.buttonEditProject = this.get().locator('.nc-action-btn.nc-edit-project');
this.buttonDeleteProject = this.get().locator('.nc-action-btn.nc-delete-project');
this.buttonMoreActions = this.get().locator('.nc-import-menu');
this.buttonNewProject = this.get().locator('.nc-new-project-menu');
this.buttonColorSelector = this.get().locator('div.color-selector');
}
prefixTitle(title: string) {
@ -236,4 +247,27 @@ export class ProjectsPage extends BasePage {
async waitForRender() {
await this.rootPage.locator('.nc-project-page-title:has-text("My Projects")').waitFor();
}
async validateRoleAccess(param: { role: string }) {
// new user; by default org level permission is to viewer (can't create project)
await expect(await this.buttonNewProject).toBeVisible({ visible: false });
// role specific permissions
switch (param.role) {
case 'creator':
await expect(await this.buttonColorSelector).toBeVisible();
await expect(await this.buttonEditProject).toBeVisible();
await expect(await this.buttonDeleteProject).toBeVisible();
await expect(await this.buttonMoreActions).toBeVisible();
break;
case 'editor':
case 'commenter':
case 'viewer':
await expect(await this.buttonColorSelector).toBeVisible({ visible: false });
await expect(await this.buttonEditProject).toBeVisible({ visible: false });
await expect(await this.buttonDeleteProject).toBeVisible({ visible: false });
await expect(await this.buttonMoreActions).toBeVisible({ visible: false });
break;
}
}
}

12
tests/playwright/tests/db/rolesCreate.spec.ts

@ -103,6 +103,18 @@ test.describe('User roles', () => {
title: 'CustomerList',
exists: roleDb[roleIdx].role === 'creator' ? true : false,
});
// Project page validation
await dashboard.clickHome();
await projectsPage.validateRoleAccess({
role: roleDb[roleIdx].role,
});
await projectsPage.openProject({
title: context.project.title,
waitForAuthTab: roleDb[roleIdx].role === 'creator',
withoutPrefix: true,
});
}
async function roleSignup(roleIdx: number) {

Loading…
Cancel
Save