diff --git a/lib/helpers/PartialViewUiHelper.ts b/lib/helpers/PartialViewUiHelper.ts index 96b1a82f..babf346e 100644 --- a/lib/helpers/PartialViewUiHelper.ts +++ b/lib/helpers/PartialViewUiHelper.ts @@ -60,14 +60,9 @@ export class PartialViewUiHelper extends UiBaseLocators { async enterPartialViewContent(partialViewContent: string) { // The waits in this method is currently needed as the test will fail with expects await this.waitUntilPartialViewLoaderIsNoLongerVisible(); - await expect(this.textAreaInputArea).toBeVisible(); - await this.textAreaInputArea.click({force: true}); - await this.page.waitForTimeout(500); - await this.textAreaInputArea.clear(); - await this.page.waitForTimeout(500); - await expect(this.textAreaInputArea).toHaveValue(''); - await this.textAreaInputArea.fill(partialViewContent); - await this.page.waitForTimeout(500); + await this.enterMonacoEditorValue(partialViewContent); + // We need this wait, to be sure that the partial view content is loaded. + await this.page.waitForTimeout(200); } async openPartialViewAtRoot(partialViewName: string) { diff --git a/lib/helpers/ScriptUiHelper.ts b/lib/helpers/ScriptUiHelper.ts index edff8b81..3f4dd3b4 100644 --- a/lib/helpers/ScriptUiHelper.ts +++ b/lib/helpers/ScriptUiHelper.ts @@ -62,9 +62,7 @@ export class ScriptUiHelper extends UiBaseLocators{ } async enterScriptContent(scriptContent: string) { - await expect(this.textAreaInputArea).toBeVisible(); - await this.textAreaInputArea.clear(); - await this.textAreaInputArea.fill(scriptContent); + await this.enterMonacoEditorValue(scriptContent); } async openScriptAtRoot(scriptName: string) { diff --git a/lib/helpers/StylesheetUiHelper.ts b/lib/helpers/StylesheetUiHelper.ts index 4bd6a565..92ec2935 100644 --- a/lib/helpers/StylesheetUiHelper.ts +++ b/lib/helpers/StylesheetUiHelper.ts @@ -56,8 +56,7 @@ export class StylesheetUiHelper extends UiBaseLocators{ } async enterStylesheetContent(stylesheetContent: string) { - await this.textAreaInputArea.clear(); - await this.textAreaInputArea.fill(stylesheetContent); + await this.enterMonacoEditorValue(stylesheetContent); } async openStylesheetByNameAtRoot(stylesheetName: string) { diff --git a/lib/helpers/TemplateUiHelper.ts b/lib/helpers/TemplateUiHelper.ts index c587a7f6..4054e105 100644 --- a/lib/helpers/TemplateUiHelper.ts +++ b/lib/helpers/TemplateUiHelper.ts @@ -75,8 +75,7 @@ export class TemplateUiHelper extends UiBaseLocators { async enterTemplateContent(templateContent: string) { // We need this wait, to be sure that the template content is loaded. await this.page.waitForTimeout(200); - await this.textAreaInputArea.clear(); - await this.textAreaInputArea.fill(templateContent); + await this.enterMonacoEditorValue(templateContent); } async isMasterTemplateNameVisible(templateName: string, isVisible: boolean = true) { diff --git a/lib/helpers/UiBaseLocators.ts b/lib/helpers/UiBaseLocators.ts index ee2d126d..bf7901e2 100644 --- a/lib/helpers/UiBaseLocators.ts +++ b/lib/helpers/UiBaseLocators.ts @@ -148,6 +148,7 @@ export class UiBaseLocators { public readonly openEntityAction: Locator; public readonly caretBtn: Locator; public readonly workspaceActionMenuBtn: Locator; + public readonly monacoEditor: Locator; constructor(page: Page) { this.page = page; @@ -166,7 +167,7 @@ export class UiBaseLocators { this.queryBuilderOrderedBy = page.locator('#property-alias-dropdown').getByLabel('Property alias'); this.queryBuilderCreateDate = page.locator('#property-alias-dropdown').getByText('CreateDate').locator(".."); this.folderNameTxt = page.getByLabel('Enter a folder name'); - this.textAreaInputArea = page.locator('textarea.inputarea'); + this.textAreaInputArea = page.locator('textarea.ime-text-area'); this.wherePropertyAliasBtn = page.locator('#property-alias-dropdown'); this.whereOperatorBtn = page.locator('#operator-dropdown'); this.whereConstrainValueTxt = page.getByLabel('constrain value'); @@ -299,6 +300,7 @@ export class UiBaseLocators { this.openEntityAction = page.locator('#action-modal[open]').locator(this.entityAction); // Workspace Entity Action this.workspaceActionMenuBtn = page.getByTestId('workspace:action-menu-button'); + this.monacoEditor = page.locator('.monaco-editor'); } async clickActionsMenuForNameInSectionSidebar(name: string) { @@ -1398,4 +1400,12 @@ export class UiBaseLocators { async clickLockActionMenuOption() { await this.clickEntityActionWithName('Lock'); } + + async enterMonacoEditorValue(value: string) { + await expect(this.monacoEditor).toBeVisible(); + await this.monacoEditor.click(); + await this.page.keyboard.press('Control+A'); + await this.page.keyboard.press('Backspace'); + await this.page.keyboard.insertText(value); + } } diff --git a/package-lock.json b/package-lock.json index e702fa9c..978c480f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@umbraco/playwright-testhelpers", - "version": "16.0.49", + "version": "16.0.50", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@umbraco/playwright-testhelpers", - "version": "16.0.49", + "version": "16.0.50", "license": "MIT", "dependencies": { "@umbraco/json-models-builders": "2.0.40", diff --git a/package.json b/package.json index b0884604..994200f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@umbraco/playwright-testhelpers", - "version": "16.0.49", + "version": "16.0.50", "description": "Test helpers for making playwright tests for Umbraco solutions", "main": "dist/lib/index.js", "files": [