From 662be2c890e8951cd754c6f6e8d3599a3d964834 Mon Sep 17 00:00:00 2001 From: Chris Mead Date: Tue, 17 Dec 2024 16:30:02 -0700 Subject: [PATCH 1/2] E2E tests: deprecate positron base element --- test/automation/src/index.ts | 1 - .../src/positron/positronBaseElement.ts | 57 ------------------- .../src/positron/positronDataExplorer.ts | 7 +-- .../src/positron/positronExplorer.ts | 10 +--- .../src/positron/positronTopActionBar.ts | 14 ++--- 5 files changed, 13 insertions(+), 76 deletions(-) delete mode 100644 test/automation/src/positron/positronBaseElement.ts diff --git a/test/automation/src/index.ts b/test/automation/src/index.ts index 2e4adf28c49..bc4c8dcb2bd 100644 --- a/test/automation/src/index.ts +++ b/test/automation/src/index.ts @@ -37,7 +37,6 @@ export * from './positron/positronPlots'; export * from './positron/fixtures/positronPythonFixtures'; export * from './positron/fixtures/positronRFixtures'; export * from './positron/fixtures/positronUserSettingsFixtures'; -export * from './positron/positronBaseElement'; export * from './positron/positronNotebooks'; export * from './positron/positronNewProjectWizard'; export * from './positron/positronConnections'; diff --git a/test/automation/src/positron/positronBaseElement.ts b/test/automation/src/positron/positronBaseElement.ts deleted file mode 100644 index 52530372e46..00000000000 --- a/test/automation/src/positron/positronBaseElement.ts +++ /dev/null @@ -1,57 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (C) 2024 Posit Software, PBC. All rights reserved. - * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Page } from '@playwright/test'; -import { Code } from '../code'; - -/* - * Base class for Positron elements similar to a PageObject - * This uses the Code class to interact with the UI - */ -export class PositronBaseElement { - myselector: string; - - constructor(myselector: string, protected code: Code = this.code) { - this.myselector = myselector; - } - - async click(): Promise { - await this.code.driver.page.locator(this.myselector).click(); - } - - async isNotVisible(retryCount: number = 200): Promise { - await this.code.waitForElement(this.myselector, (result) => !result, retryCount); - } - - async waitforVisible(): Promise { - await this.code.waitForElement(this.myselector); - } - - async hover(): Promise { - await this.code.driver.getLocator(this.myselector).hover(); - } - - async isDisabled(): Promise { - return await this.code.driver.getLocator(this.myselector).isDisabled(); - } - - async isEnabled(): Promise { - return await this.code.driver.getLocator(this.myselector).isEnabled(); - } - - getPage(): Page { - return this.code.driver.getLocator(this.myselector).page(); - } -} - -export class PositronTextElement extends PositronBaseElement { - constructor(myselector: string, code: Code) { - super(myselector, code); - } - - async waitForText(expectedText: string): Promise { - return await this.code.waitForTextContent(this.myselector, expectedText); - } -} diff --git a/test/automation/src/positron/positronDataExplorer.ts b/test/automation/src/positron/positronDataExplorer.ts index d334263e701..cb34c0926ba 100644 --- a/test/automation/src/positron/positronDataExplorer.ts +++ b/test/automation/src/positron/positronDataExplorer.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ -import { expect } from '@playwright/test'; +import { expect, Locator } from '@playwright/test'; import { Code } from '../code'; -import { PositronBaseElement } from './positronBaseElement'; import { Workbench } from '../workbench'; const COLUMN_HEADERS = '.data-explorer-panel .right-column .data-grid-column-headers'; @@ -48,10 +47,10 @@ export interface ColumnProfile { */ export class PositronDataExplorer { - clearSortingButton: PositronBaseElement; + clearSortingButton: Locator; constructor(private code: Code, private workbench: Workbench) { - this.clearSortingButton = new PositronBaseElement(CLEAR_SORTING_BUTTON, this.code); + this.clearSortingButton = this.code.driver.page.locator(CLEAR_SORTING_BUTTON); } /* diff --git a/test/automation/src/positron/positronExplorer.ts b/test/automation/src/positron/positronExplorer.ts index daf78db16c9..67d033413d8 100644 --- a/test/automation/src/positron/positronExplorer.ts +++ b/test/automation/src/positron/positronExplorer.ts @@ -4,10 +4,8 @@ *--------------------------------------------------------------------------------------------*/ -import { expect } from '@playwright/test'; +import { expect, Locator } from '@playwright/test'; import { Code } from '../code'; -// import { QuickAccess } from '../quickaccess'; -import { PositronTextElement } from './positronBaseElement'; const POSITRON_EXPLORER_PROJECT_TITLE = 'div[id="workbench.view.explorer"] h3.title'; const POSITRON_EXPLORER_PROJECT_FILES = 'div[id="workbench.view.explorer"] span[class="monaco-highlighted-label"]'; @@ -17,12 +15,10 @@ const POSITRON_EXPLORER_PROJECT_FILES = 'div[id="workbench.view.explorer"] span[ * Reuseable Positron explorer functionality for tests to leverage. */ export class PositronExplorer { - explorerProjectTitle: PositronTextElement; + explorerProjectTitle: Locator = this.code.driver.page.locator(POSITRON_EXPLORER_PROJECT_TITLE); explorerProjectTitleLocator = this.code.driver.page.locator(POSITRON_EXPLORER_PROJECT_TITLE); - constructor(protected code: Code) { - this.explorerProjectTitle = new PositronTextElement(POSITRON_EXPLORER_PROJECT_TITLE, this.code); - } + constructor(protected code: Code) { } /** * Constructs a string array of the top-level project files/directories in the explorer. diff --git a/test/automation/src/positron/positronTopActionBar.ts b/test/automation/src/positron/positronTopActionBar.ts index d97117f04cf..1e478deed6b 100644 --- a/test/automation/src/positron/positronTopActionBar.ts +++ b/test/automation/src/positron/positronTopActionBar.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ +import { Locator } from '@playwright/test'; import { Code } from '../code'; -import { PositronBaseElement } from './positronBaseElement'; const POSITRON_TOP_ACTION_BAR = 'div[id="workbench.parts.positron-top-action-bar"]'; const POSITRON_TOP_ACTION_SAVE_BUTTON = 'div[id="workbench.parts.positron-top-action-bar"] .action-bar-region-left .action-bar-button[aria-label="Save"]'; @@ -15,13 +15,13 @@ const POSITRON_TOP_ACTION_SAVE_ALL_BUTTON = 'div[id="workbench.parts.positron-to * Reuseable Positron top action bar functionality for tests to leverage. */ export class PositronTopActionBar { - topActionBar: PositronBaseElement; - saveButton: PositronBaseElement; - saveAllButton: PositronBaseElement; + topActionBar: Locator; + saveButton: Locator; + saveAllButton: Locator; constructor(private code: Code) { - this.topActionBar = new PositronBaseElement(POSITRON_TOP_ACTION_BAR, this.code); - this.saveButton = new PositronBaseElement(POSITRON_TOP_ACTION_SAVE_BUTTON, this.code); - this.saveAllButton = new PositronBaseElement(POSITRON_TOP_ACTION_SAVE_ALL_BUTTON, this.code); + this.topActionBar = this.code.driver.page.locator(POSITRON_TOP_ACTION_BAR); + this.saveButton = this.code.driver.page.locator(POSITRON_TOP_ACTION_SAVE_BUTTON); + this.saveAllButton = this.code.driver.page.locator(POSITRON_TOP_ACTION_SAVE_ALL_BUTTON); } } From 89d28639293e2501c93c1c4df503d5ec9bfc1092 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Wed, 18 Dec 2024 06:19:42 -0600 Subject: [PATCH 2/2] clear console --- test/e2e/areas/variables/variables-expanded.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/areas/variables/variables-expanded.test.ts b/test/e2e/areas/variables/variables-expanded.test.ts index f860d5e8ada..e57ce885279 100644 --- a/test/e2e/areas/variables/variables-expanded.test.ts +++ b/test/e2e/areas/variables/variables-expanded.test.ts @@ -13,6 +13,7 @@ test.describe('Variables - Expanded View', { tag: [tags.WEB, tags.VARIABLES] }, test.afterEach(async function ({ app }) { await app.workbench.positronLayouts.enterLayout('stacked'); + await app.workbench.positronConsole.barClearButton.click(); await app.workbench.positronConsole.barRestartButton.click(); });