Skip to content

Commit

Permalink
fix(test): tests fix 18.11.2024 (#120)
Browse files Browse the repository at this point in the history
fix(tests) tests fix and update snapshots
  • Loading branch information
chalapkoStanislav authored Nov 19, 2024
1 parent 1c27628 commit 53377e0
Show file tree
Hide file tree
Showing 56 changed files with 176 additions and 154 deletions.
54 changes: 29 additions & 25 deletions pages/dashboard/dashboard-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ exports.DashboardPage = class DashboardPage extends BasePage {
this.moveToOtherTeamMenuItem = page
.getByRole('menuitem')
.filter({ hasText: 'Move to other team' });
this.dashboardLibraryItem = page.locator(
`button[title="New File 1"] div[class*="dashboard_grid__library"]`,
);
this.dashboardLibraryItem = page
.getByRole('button', { name: 'New File 1' })
.locator(`div[class*="dashboard_grid__library"]`);
this.downloadFilePenpotMenuItem = page.getByTestId('download-binary-file');
this.downloadFileStandardMenuItem = page.getByTestId('download-standard-file');
this.dashboardSection = page.locator('[class="main_ui_dashboard__dashboard"]');
Expand Down Expand Up @@ -129,7 +129,7 @@ exports.DashboardPage = class DashboardPage extends BasePage {
);

//Libraries & Templates
this.noLibrariesPlacelder = page.getByTestId('empty-placeholder');
this.noLibrariesPlacelder = page.getByText('No libraries yet.');

// Onboarding
this.onboardingContinueBtn = page.locator(
Expand Down Expand Up @@ -164,7 +164,9 @@ exports.DashboardPage = class DashboardPage extends BasePage {
this.onboardingContinueCreateTeamBtn = page.locator(
'button[label="Continue creating team"]',
);
this.onboardingContinueWithoutTeamBtn = page.getByRole('button').filter({hasText: 'Continue without team'});
this.onboardingContinueWithoutTeamBtn = page
.getByRole('button')
.filter({ hasText: 'Continue without team' });
this.onboardingInviteInput = page.locator(
'input[class*="components_forms__inside-input"]',
);
Expand Down Expand Up @@ -458,9 +460,7 @@ exports.DashboardPage = class DashboardPage extends BasePage {
}

async checkNoLibrariesExist() {
await expect(this.noLibrariesPlacelder).toContainText(
'Files added to Libraries will appear here.',
);
await expect(this.noLibrariesPlacelder).toContainText('No libraries yet.');
}

async clickUnpinProjectButton() {
Expand Down Expand Up @@ -598,17 +598,17 @@ exports.DashboardPage = class DashboardPage extends BasePage {
await this.openFile();
}
async openFileWithName(name) {
const fileTitle = this.page.locator(`button[title="${name}"]`);
const fileTitle = this.page.getByRole('button', { name: name });
await fileTitle.first().dblclick();
}

async isFileVisibleByName(name) {
const elem = this.page.locator(`button[title="${name}"]`);
const elem = this.page.getByRole('button', { name: name });
await expect(elem.first()).toBeVisible();
}

async deleteFileWithNameViaRightClick(name) {
const elem = this.page.locator(`button[title="${name}"]`).first();
const elem = this.page.getByRole('button', { name: name }).first();
await elem.click({ button: 'right' });
await this.deleteFileMenuItem.click();
}
Expand All @@ -618,7 +618,7 @@ exports.DashboardPage = class DashboardPage extends BasePage {
}

async moveFileToOtherTeamViaRightClick(fileName, otherTeamName) {
const elem = this.page.locator(`button[title="${fileName}"]`).first();
const elem = this.page.getByRole('button', { name: fileName }).first();
await elem.click({ button: 'right' });
await expect(this.moveToFileMenuItem).toBeVisible();
await this.moveToFileMenuItem.click();
Expand All @@ -631,21 +631,21 @@ exports.DashboardPage = class DashboardPage extends BasePage {
}

async addFileWithNameAsSharedLibraryViaRightClick(fileName) {
const elem = this.page.locator(`button[title="${fileName}"]`).first();
const elem = this.page.getByRole('button', { name: fileName }).first();
await elem.click({ button: 'right' });
await this.addFileAsSharedLibraryMenuItem.click();
await this.addFileAsSharedLibraryButton.click();
}

async isFilePresentWithName(fileName) {
const fileNameTitle = this.page.locator(
`button[title="${fileName}"] div[class*="item-info"] h3`,
);
const fileNameTitle = this.page
.getByRole('button', { name: fileName })
.locator(`div[class*="item-info"] h3`);
await expect(fileNameTitle).toHaveText(fileName);
}

async renameFileWithNameViaRightClick(oldFileName, newFileName) {
const fileTitle = this.page.locator(`button[title="${oldFileName}"]`).first();
const fileTitle = this.page.getByRole('button', { name: oldFileName }).first();
let text = await fileTitle.textContent();
await fileTitle.click({ button: 'right' });
await this.renameFileMenuItem.click();
Expand All @@ -660,9 +660,11 @@ exports.DashboardPage = class DashboardPage extends BasePage {

async clickOnOnboardingContinueBtn() {
await this.onboardingContinueBtn.click();
await this.page.waitForResponse(response =>
response.url() === `${process.env.BASE_URL}api/rpc/command/push-audit-events` &&
response.status() === 200
await this.page.waitForResponse(
(response) =>
response.url() ===
`${process.env.BASE_URL}api/rpc/command/push-audit-events` &&
response.status() === 200,
);
}

Expand Down Expand Up @@ -875,11 +877,13 @@ exports.DashboardPage = class DashboardPage extends BasePage {
}

async clickOnOnboardingContinueWithoutTeamButton() {
if(await this.onboardingContinueWithoutTeamBtn.isVisible()) {
await this.onboardingContinueWithoutTeamBtn.click()
await this.page.waitForResponse(response =>
response.url() === `${process.env.BASE_URL}api/rpc/command/push-audit-events` &&
response.status() === 200
if (await this.onboardingContinueWithoutTeamBtn.isVisible()) {
await this.onboardingContinueWithoutTeamBtn.click();
await this.page.waitForResponse(
(response) =>
response.url() ===
`${process.env.BASE_URL}api/rpc/command/push-audit-events` &&
response.status() === 200,
);
}
}
Expand Down
14 changes: 6 additions & 8 deletions pages/workspace/assets-panel-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ exports.AssetsPanelPage = class AssetsPanelPage extends BasePage {
this.fileLibraryGroupTitle = page.locator('div[class*="group-title"]');
this.fileLibraryListViewButton = page.getByTitle('List view', { exact: true });
this.fileLibraryGridViewButton = page.getByTitle('Grid view', { exact: true });
this.addFileLibraryColorButton = page.locator(
'button[class*="assets_colors__assets-btn"]',
);
this.addFileLibraryColorButton = page.getByRole('button', { name: 'Add color' });
this.fileLibraryColorsColorBullet = page.locator(
'div[class*="assets_colors__bullet-block"]',
);
this.fileLibraryColorsColorTitle = page.locator('div[class*="name-block"]');
this.fileLibraryColorsColorNameInput = page.locator(
'input[class*="element-name"]',
);
this.addFileLibraryTypographyButton = page.locator(
'button[class*="typographies__assets-btn"]',
);
this.addFileLibraryTypographyButton = page.getByRole('button', {
name: 'Add typography',
});
this.minimizeFileLibraryTypographyButton = page.locator(
'div[class*="typography__action-btn"]',
);
Expand All @@ -83,8 +81,8 @@ exports.AssetsPanelPage = class AssetsPanelPage extends BasePage {
this.assetsTypeDropdown = page.locator('ul[class*="context-menu-items"]');
this.assetsTypeAll = page.locator('#section-all');
this.assetsTypeComponents = page.locator('#section-components');
this.assetsTypeColors = page.locator('#section-color');
this.assetsTypeTypographies = page.locator('#section-typography');
this.assetsTypeColors = page.locator('#section-colors');
this.assetsTypeTypographies = page.locator('#section-typographies');
this.duplicateMainComponentMenuItem = page
.getByRole('menuitem')
.filter({ hasText: 'Duplicate main' });
Expand Down
7 changes: 4 additions & 3 deletions pages/workspace/comments-panel-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ exports.CommentsPanelPage = class CommentsPanelPage extends BasePage {
'div[class*="comments-container"] div.main_ui_comments__resolved',
);
this.commentReplyInput = page.getByPlaceholder('Reply');
this.commentOptionsButton = page.locator(
'div[class*="comments__options"] svg[class="icon-menu"]',
);
this.commentOptionsButton = page
.locator('div[class*="comments__threads"]')
.first()
.getByRole('button', { name: 'Options' });
this.commentEditOptionMenuItem = page
.getByRole('listitem')
.filter({ hasText: 'Edit' });
Expand Down
82 changes: 34 additions & 48 deletions pages/workspace/design-panel-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {
this.fillOpacityInput = page.locator(
'div[class*="fill__element-content"] div[class*="opacity-element-wrapper"] input',
);
this.addFillButton = page.locator('button[class*="fill__add-fill"]');
this.removeFillButton = page.locator(
'div[class*="fill__element-content"] svg[class="icon-remove"]',
);
this.addFillButton = page.getByRole('button', { name: 'Add fill color' });
this.removeFillButton = page
.locator('div[class*="fill__element-content"]')
.getByRole('button', { name: 'Remove color' });
this.componentColorInput = page.locator(
`input[class*='rows_color_row__color-input']`,
);

//Design panel - Shadow section
this.shadowSection = page.getByText('Shadow', { exact: true });
this.groupShadowSection = page.getByText('Group shadow', { exact: true });
this.addShadowButton = page.getByTestId('add-shadow');
this.addShadowButton = page.getByRole('button', { name: 'Add shadow' });
this.shadowActionsButton = page.locator('button[class*="shadow__more-options"]');
this.shadowXInput = page.locator(
'div[class*="shadow-advanced-options"] div[title="X"] input',
Expand All @@ -74,15 +74,9 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {
this.shadowOpacityInput = page.locator(
'div[class*="shadow-advanced-options"] div[class*="color_row__opacity"] input',
);
this.shadowShowIcon = page.locator(
'div[class*="shadow__actions"] svg[class="icon-shown"]',
);
this.shadowUnhideIcon = page.locator(
'div[class*="shadow__actions"] svg[class="icon-hide"]',
);
this.shadowRemoveIcon = page.locator(
'div[class*="shadow__actions"] svg[class="icon-remove"]',
);
this.shadowShowIcon = page.getByRole('button', { name: 'Toggle shadow' });
this.shadowUnhideIcon = page.getByRole('button', { name: 'Toggle shadow' });
this.shadowRemoveIcon = page.getByRole('button', { name: 'Remove shadow' });
this.shadowTypeField = page.locator('div[class*="shadow-type-select"]');

//Design panel - Flex Layout section
Expand Down Expand Up @@ -132,12 +126,8 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {
this.autoMenuItem = page.getByRole('listitem').filter({ hasText: 'AUTO' });
this.fixedMenuItem = page.getByRole('listitem').filter({ hasText: 'PX' });
this.percentMenuItem = page.getByRole('listitem').filter({ hasText: '%' });
this.layoutRemoveButton = page.locator(
'div[class*="layout_container__element-title"] button[class*="remove-layout"]',
);
this.layoutAddButton = page.locator(
'div[class*="layout_container__element-title"] button[class*="add-layout"]',
);
this.layoutRemoveButton = page.getByRole('button', { name: 'Remove layout' });
this.layoutAddButton = page.getByRole('button', { name: 'Add layout' });
this.layoutDirectRowBtn = page.getByTitle('Row', { exact: true });
this.layoutDirectRowReverseBtn = page.getByTitle('Row reverse', { exact: true });
this.layoutDirectColumnBtn = page.getByTitle('Column', { exact: true });
Expand Down Expand Up @@ -209,28 +199,22 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {

//Design panel - Blur section
this.blurSection = page.getByText('Blur', { exact: true });
this.addBlurButton = page.getByTestId('add-blur');
this.addBlurButton = page.getByRole('button', { name: 'Add blur' });
this.blurMoreOptions = page.locator('button[class*="blur__show-more"]');
this.blurValueInput = page.locator('#blur-input-sidebar');
this.blurHideIcon = page.locator(
'div[class*="blur__actions"] svg[class="icon-shown"]',
);
this.blurUnhideIcon = page.locator(
'div[class*="blur__actions"] svg[class="icon-hide"]',
);
this.blurRemoveIcon = page.locator(
'div[class*="blur__actions"] svg[class="icon-remove"]',
);
this.blurHideIcon = page.getByRole('button', { name: 'Toggle blur' });
this.blurUnhideIcon = page.getByRole('button', { name: 'Toggle blur' });
this.blurRemoveIcon = page.getByRole('button', { name: 'Remove blur' });

//Design panel - Stroke section
this.addStrokeButton = page.getByTestId('add-stroke');
this.addStrokeButton = page.getByRole('button', { name: 'Add stroke color' });
this.strokeSection = page.getByText('Stroke', { exact: true });
this.strokeColorBullet = page.locator(
'div[class*="bullet-wrapper"] div[class*="color_bullet__is-not-library-color"]',
);
this.strokeRemoveIcon = page.locator(
'div[class*="stroke-data"] button[class*="remove-btn"]',
);
this.strokeRemoveIcon = page
.locator('div[class*="stroke__element-content"]')
.getByRole('button', { name: 'Remove color' });
this.strokeColorInput = page.locator(
'div[class*="stroke-data"] input[class*="color-input"]',
);
Expand All @@ -253,7 +237,9 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {
this.textUpperCaseIcon = page.locator('svg.icon-text-uppercase');
this.textLowerCaseIcon = page.locator('svg.icon-text-lowercase');
this.textTitleCaseIcon = page.locator('svg.icon-text-mixed');
this.textMoreOptionsIcon = page.locator('button[class*="text__more-options"]');
this.textMoreOptionsIcon = page
.locator('div[class*="text__element-content"]')
.getByRole('button', { name: 'Options' });
this.textVerticalOptionsBlock = page.locator(
'div[class*="vertical-align-options"]',
);
Expand All @@ -271,26 +257,21 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {

//Design panel - Export section
this.exportSection = page.getByText('Export', { exact: true });
this.addExportButton = page.locator('button[class*="exports__add-export"]');
this.removeExportButton = page.locator(
'button[class*="exports__action-btn"] svg[class="icon-remove"]',
this.addExportButton = page.getByRole('button', { name: 'Add export' });
this.addExportVieverButton = page.locator(
'button[class*="exports__add-export"]',
);
this.removeExportButton = page.getByRole('button', { name: 'Remove export' });
this.exportElementButton = page.getByRole('button', {
name: /Export \d+ element/,
});

//Design panel - Grid section
this.gridSection = page.getByText('Guides', { exact: true });
this.addGridButton = page.locator('button[class*="grid__add-grid"]');
this.removeGridButton = page.locator(
'div[class*="grid__actions"] svg[class="icon-remove"]',
);
this.hideGridButton = page.locator(
'div[class*="grid__actions"] svg[class="icon-shown"]',
);
this.unhideGridButton = page.locator(
'div[class*="grid__actions"] svg[class="icon-hide"]',
);
this.addGridButton = page.getByRole('button', { name: 'Add guide' });
this.removeGridButton = page.getByRole('button', { name: 'Remove guide' });
this.hideGridButton = page.getByRole('button', { name: 'Toggle guide' });
this.unhideGridButton = page.getByRole('button', { name: 'Toggle guide' });
this.gridTypeField = page.locator(
'div[class*="grid__option-row"] div[class*="type-select-wrapper"]',
);
Expand Down Expand Up @@ -987,6 +968,11 @@ exports.DesignPanelPage = class DesignPanelPage extends BasePage {
await this.addExportButton.click();
}

async clickAddExportButtonForViewMode() {
await this.exportSection.waitFor();
await this.addExportVieverButton.click();
}

async clickRemoveExportButton() {
await this.removeExportButton.click();
}
Expand Down
4 changes: 4 additions & 0 deletions pages/workspace/inspect-panel-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ exports.InspectPanelPage = class InspectPanelPage extends BasePage {
async openCodeTab() {
await this.codeTabButton.click();
}

async waitForCodeButtonVisible() {
await this.codeTabButton.waitFor({ state: 'visible', timeout: 10000 });
}
};
15 changes: 8 additions & 7 deletions pages/workspace/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ exports.MainPage = class MainPage extends BasePage {
this.nodePanelToCurveButton = page.locator('button[title^="To curve"]');

// Main menu - first level
this.mainMenuButton = page.locator('#left-sidebar-aside svg.icon-menu');
this.mainMenuButton = page.getByRole('button', { name: 'Main menu' });
this.mainMenuList = page.locator(
'ul[class*="main_ui_workspace_main_menu__menu"]',
);
Expand Down Expand Up @@ -134,12 +134,8 @@ exports.MainPage = class MainPage extends BasePage {

//Zoom
this.zoomButton = page.getByTitle('Zoom', { exact: true });
this.zoomPlusButton = page.locator(
'button[class*="header__zoom-btn"] svg[class="icon-add"]',
);
this.zoomMinusButton = page.locator(
'button[class*="header__zoom-btn"] svg[class="icon-remove"]',
);
this.zoomPlusButton = page.getByRole('button', { name: 'Zoom in' });
this.zoomMinusButton = page.getByRole('button', { name: 'Zoom out' });
this.zoomResetButton = page.getByRole('button', { name: 'Reset' });
this.zoomToFitAllMenuItem = page
.getByRole('listitem')
Expand Down Expand Up @@ -196,6 +192,7 @@ exports.MainPage = class MainPage extends BasePage {

//History panel
this.historyPanelButton = page.getByRole('button', { name: /History/ });
this.historyActionsTab = page.getByRole('tab', { name: 'Actions' });
this.historyPanelActionRecord = page.locator(
'div[class*="history-entry-summary-text"]',
);
Expand Down Expand Up @@ -766,6 +763,10 @@ exports.MainPage = class MainPage extends BasePage {
await this.historyPanelButton.click();
}

async clickHistoryActionsButton() {
await this.historyActionsTab.click();
}

async isActionDisplayedOnHistoryPanel(actionName) {
await expect(this.historyPanelActionRecord).toHaveText(actionName);
}
Expand Down
Loading

0 comments on commit 53377e0

Please sign in to comment.