Skip to content

Commit

Permalink
feature(test): viewer user tests added (#121)
Browse files Browse the repository at this point in the history
feature(test): viewer user tests added
  • Loading branch information
chalapkoStanislav authored Nov 21, 2024
1 parent 13298db commit 593b552
Show file tree
Hide file tree
Showing 7 changed files with 392 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pages/dashboard/dashboard-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exports.DashboardPage = class DashboardPage extends BasePage {
'div[class*="dashboard-grid"] button[class*="create-new"]',
);
this.createFileButtonTitlePanel = page.getByTestId('project-new-file');
this.createFileButtonDraftsTab = page.getByTestId('new-file');
this.renameFileMenuItem = page.getByTestId('file-rename');
this.duplicateFileMenuItem = page.getByTestId('file-duplicate');
this.addFileAsSharedLibraryMenuItem = page.getByTestId('file-add-shared');
Expand Down Expand Up @@ -101,6 +102,10 @@ exports.DashboardPage = class DashboardPage extends BasePage {
//Fonts
this.fontsSidebarItem = page.getByTestId('fonts');
this.uploadFontSelector = page.locator('#font-upload');
this.addCustomFontButton = page.getByRole('button', {
name: 'Add custom font',
exact: true,
});
this.uploadFontButton = page.getByRole('button', {
name: 'Upload',
exact: true,
Expand Down Expand Up @@ -975,4 +980,28 @@ exports.DashboardPage = class DashboardPage extends BasePage {
async waitForCreateFilePlaceholderVisible() {
await this.createFileButtonPlaceholder.first().waitFor({ state: 'visible' });
}

async isOptionButtonFromDraftPageVisible(visible = true) {
visible
? await expect(this.headerOptionsMenuButton).toBeVisible()
: await expect(this.headerOptionsMenuButton).not.toBeVisible();
}

async isCreateFileOnDraftsTabButtonVisible(visible = true) {
visible
? await expect(this.createFileButtonDraftsTab.first()).toBeVisible()
: await expect(this.createFileButtonDraftsTab.first()).not.toBeVisible();
}

async isAddCustomFontButtonVisible(visible = true) {
visible
? await expect(this.addCustomFontButton).toBeVisible()
: await expect(this.addCustomFontButton).not.toBeVisible();
}

async isAddProjectButtonVisible(visible = true) {
visible
? await expect(this.addProjectButton).toBeVisible()
: await expect(this.addProjectButton).not.toBeVisible();
}
};
16 changes: 16 additions & 0 deletions pages/dashboard/team-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ exports.TeamPage = class TeamPage extends BasePage {
this.editorRoleSelector = page
.getByRole('listitem')
.filter({ hasText: 'Editor' });
this.viewerRoleSelector = page.getByRole('listitem').filter({ hasText: 'Viewer' });
this.ownerRoleSelector = page.getByRole('listitem').filter({ hasText: 'Owner' });
this.transferOwnershipButton = page.getByRole('button', {
name: 'Transfer ownership',
Expand Down Expand Up @@ -278,6 +279,9 @@ exports.TeamPage = class TeamPage extends BasePage {
case 'Editor':
await this.editorRoleSelector.click();
break;
case 'Viewer':
await this.viewerRoleSelector.click();
break;
}
}

Expand All @@ -290,6 +294,9 @@ exports.TeamPage = class TeamPage extends BasePage {
case 'Editor':
await this.editorRoleSelector.click();
break;
case 'Viewer':
await this.viewerRoleSelector.click();
break;
}
}

Expand All @@ -313,6 +320,9 @@ exports.TeamPage = class TeamPage extends BasePage {
case 'Owner':
await this.ownerRoleSelector.click();
break;
case 'Viewer':
await this.viewerRoleSelector.click();
break;
}
}

Expand All @@ -332,6 +342,9 @@ exports.TeamPage = class TeamPage extends BasePage {
case 'Owner':
roleLoc = await this.ownerRoleSelector;
break;
case 'Viewer':
roleLoc = await this.viewerRoleSelector;
break;
}
await expect(roleLoc).not.toBeVisible();
}
Expand All @@ -352,6 +365,9 @@ exports.TeamPage = class TeamPage extends BasePage {
case 'Owner':
roleLoc = await this.ownerRoleSelector;
break;
case 'Viewer':
roleLoc = await this.viewerRoleSelector;
break;
}
await expect(roleLoc).not.toBeVisible();
}
Expand Down
40 changes: 40 additions & 0 deletions pages/workspace/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ exports.MainPage = class MainPage extends BasePage {
this.deletePageOkButton = page.getByRole('button', { name: 'Ok' });

// Bottom palette
this.typographyButton = page.getByRole('button', { name: 'Typographies' });
this.bottomPaletteContentBlock = page.locator(
'div[class="main_ui_workspace_palette__palette"]',
);
Expand All @@ -183,6 +184,7 @@ exports.MainPage = class MainPage extends BasePage {
this.typographiesColorsBottomPanel = page.locator(
'div.main_ui_workspace_palette__wide',
);
this.workspaceMenu = page.locator('*[class*="workspace-context-menu"]');

//Header
this.unSavedChangesIcon = page.getByTitle('Unsaved changes', { exact: true });
Expand Down Expand Up @@ -923,6 +925,12 @@ exports.MainPage = class MainPage extends BasePage {
await this.designTab.click();
}

async isDesignTabVisible(visible = true) {
visible
? await expect(this.designTab).toBeVisible()
: await expect(this.designTab).not.toBeVisible();
}

async createComponentsMultipleShapesRightClick(singleComponent = true) {
const layerSel = this.page.locator(
'div[class*="viewport"] .main.viewport-selrect',
Expand Down Expand Up @@ -1052,4 +1060,36 @@ exports.MainPage = class MainPage extends BasePage {
await selectedElement.hover();
await selectedElement.dragTo(board);
}

async isToolBarVisible(visible = true) {
visible
? await expect(this.toolBarWindow).toBeVisible()
: await expect(this.toolBarWindow).not.toBeVisible();
}

async isPageRightClickMenuVisible(visible = true) {
await this.firstPageListItem.click({ button: 'right' });
visible
? await expect(this.renamePageMenuItem).toBeVisible()
: await expect(this.renamePageMenuItem).not.toBeVisible();
}

async checkViewerRightClickMenu() {
const layerSel = this.page.locator('.viewport-selrect');
await layerSel.last().click({ button: 'right', force: true });
await expect(this.copyOption).not.toBeVisible();
await expect(this.workspaceMenu).not.toBeVisible();
}

async isColorsPaletteButtonVisible(visible = true){
visible
? await expect(this.colorsPaletteButton).toBeVisible()
: await expect(this.colorsPaletteButton).not.toBeVisible();
}

async isTypographyButtonVisible(visible = true){
visible
? await expect(this.typographyButton).toBeVisible()
: await expect(this.typographyButton).not.toBeVisible();
}
};
Loading

0 comments on commit 593b552

Please sign in to comment.