-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E2E test: Positron editors POM (#5845)
Replace MS editors POM with one based solely on Playwright ### QA Notes All tests should pass.
- Loading branch information
1 parent
18a1951
commit bdc131e
Showing
9 changed files
with
118 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { expect } from '@playwright/test'; | ||
import { Code } from '../code'; | ||
|
||
|
||
export class PositronEditors { | ||
|
||
activeEditor = this.code.driver.page.locator('div.tab.tab-actions-right.active.selected'); | ||
editorIcon = this.code.driver.page.locator('.monaco-icon-label.file-icon'); | ||
editorPart = this.code.driver.page.locator('.split-view-view .part.editor'); | ||
|
||
constructor(private code: Code) { } | ||
|
||
async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<void> { | ||
await expect(this.code.driver.page.locator(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][data-resource-name$="${fileName}"]`)).toBeVisible(); | ||
} | ||
|
||
async newUntitledFile(): Promise<void> { | ||
if (process.platform === 'darwin') { | ||
await this.code.driver.page.keyboard.press('Meta+N'); | ||
} else { | ||
await this.code.driver.page.keyboard.press('Control+N'); | ||
} | ||
|
||
await this.waitForEditorFocus('Untitled-1'); | ||
} | ||
|
||
async waitForEditorFocus(fileName: string): Promise<void> { | ||
await this.waitForActiveTab(fileName, undefined); | ||
await this.waitForActiveEditor(fileName); | ||
} | ||
|
||
async waitForActiveEditor(fileName: string): Promise<any> { | ||
const selector = `.editor-instance .monaco-editor[data-uri$="${fileName}"] textarea`; | ||
await expect(this.code.driver.page.locator(selector)).toBeFocused(); | ||
} | ||
|
||
async selectTab(fileName: string): Promise<void> { | ||
|
||
// Selecting a tab and making an editor have keyboard focus | ||
// is critical to almost every test. As such, we try our | ||
// best to retry this task in case some other component steals | ||
// focus away from the editor while we attempt to get focus | ||
|
||
await expect(async () => { | ||
await this.code.driver.page.locator(`.tabs-container div.tab[data-resource-name$="${fileName}"]`).click(); | ||
await this.code.driver.page.keyboard.press(process.platform === 'darwin' ? 'Meta+1' : 'Control+1'); // make editor really active if click failed somehow | ||
await this.waitForEditorFocus(fileName); | ||
}).toPass(); | ||
} | ||
|
||
async waitForTab(fileName: string, isDirty: boolean = false): Promise<void> { | ||
await expect(this.code.driver.page.locator(`.tabs-container div.tab${isDirty ? '.dirty' : ''}[data-resource-name$="${fileName}"]`)).toBeVisible(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters