Skip to content

Commit b6560ea

Browse files
authored
V17 Cherry pick the test helper for workspace view and updated test helper to avoid flaky tests (#309)
* Updated test helper to avoid flaky tests * Cherry pick the test helper for workspace view * Bumped version * Format code
1 parent 872a1c0 commit b6560ea

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

lib/helpers/DataTypeUiHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ export class DataTypeUiHelper extends UiBaseLocators {
930930
async addBlockSettingsModel(elementName: string) {
931931
await expect(this.chooseSettingsModelBtn).toBeVisible();
932932
await this.chooseSettingsModelBtn.click();
933-
await this.clickButtonWithName(elementName);
933+
await this.clickModalMenuItemWithName(elementName);
934934
await this.clickChooseModalButton();
935935
}
936936

lib/helpers/RelationTypeUiHelper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class RelationTypeUiHelper extends UiBaseLocators{
4040
async goToRelationTypeWithName(name: string) {
4141
await expect(this.relationTypeCollection.getByText(name)).toBeVisible();
4242
await this.relationTypeCollection.getByText(name).click();
43+
await this.waitUntilUiLoaderIsNoLongerVisible();
4344
}
4445

4546
async clickRootFolderCaretButton() {

lib/helpers/UiBaseLocators.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export class UiBaseLocators {
151151
public readonly monacoEditor: Locator;
152152
public readonly createNewDocumentBlueprintBtn: Locator;
153153
public readonly openedModal: Locator;
154+
public readonly uiLoader: Locator;
154155
public readonly createDocumentBlueprintModal: Locator;
155156

156157
constructor(page: Page) {
@@ -307,6 +308,7 @@ export class UiBaseLocators {
307308
this.workspaceActionMenuBtn = page.getByTestId('workspace:action-menu-button');
308309
this.monacoEditor = page.locator('.monaco-editor');
309310
this.openedModal = page.locator('uui-modal-container[backdrop]');
311+
this.uiLoader = page.locator('uui-loader');
310312
}
311313

312314
async clickActionsMenuForNameInSectionSidebar(name: string) {
@@ -1155,9 +1157,10 @@ export class UiBaseLocators {
11551157
await this.mediaPickerModalSubmitBtn.click();
11561158
}
11571159

1158-
async selectMediaWithName(mediaName: string) {
1159-
await expect(this.mediaCardItems.filter({hasText: mediaName})).toBeVisible();
1160-
await this.mediaCardItems.filter({hasText: mediaName}).click({position: {x: 0.5, y: 0.5}});
1160+
async selectMediaWithName(mediaName: string, isForce: boolean = false) {
1161+
const mediaLocator = this.mediaCardItems.filter({hasText: mediaName});
1162+
await expect(mediaLocator).toBeVisible();
1163+
await mediaLocator.click({position: {x: 0.5, y: 0.5}, force: isForce});
11611164
}
11621165

11631166
async selectMediaWithTestId(mediaKey: string) {
@@ -1414,4 +1417,12 @@ export class UiBaseLocators {
14141417
await this.page.keyboard.press('Backspace');
14151418
await this.page.keyboard.insertText(value);
14161419
}
1420+
1421+
async waitUntilUiLoaderIsNoLongerVisible() {
1422+
await expect(this.uiLoader).toBeVisible({visible: false, timeout: 10000});
1423+
}
1424+
1425+
async isWorkspaceViewTabWithAliasVisible(alias: string, isVisible: boolean = true) {
1426+
await expect(this.page.getByTestId('workspace:view-link:' + alias)).toBeVisible({ visible: isVisible });
1427+
}
14171428
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@umbraco/playwright-testhelpers",
3-
"version": "17.0.0-beta.7",
3+
"version": "17.0.0-beta.8",
44
"description": "Test helpers for making playwright tests for Umbraco solutions",
55
"main": "dist/lib/index.js",
66
"files": [

0 commit comments

Comments
 (0)