| 1 | import { TextEditor, WebView } from "vscode-extension-tester"; |
| 2 | |
| 3 | import { EditSelectors } from "../selectors/Edit.selectors"; |
| 4 | import { TestUtils } from "../TestUtils"; |
| 5 | |
| 6 | export class EditActions { |
| 7 | static async invokeEditShortcut(editor: TextEditor) { |
| 8 | editor |
| 9 | .getDriver() |
| 10 | .actions() |
| 11 | .keyDown(TestUtils.osControlKey) |
| 12 | .sendKeys("i") |
| 13 | .keyUp(TestUtils.osControlKey) |
| 14 | .perform(); |
| 15 | } |
| 16 | |
| 17 | static async acceptEditInGUI(view: WebView): Promise<void> { |
| 18 | await TestUtils.waitForSuccess(async () => |
| 19 | (await EditSelectors.getEditAcceptButton(view)).click(), |
| 20 | ); |
| 21 | await view.switchBack(); |
| 22 | } |
| 23 | |
| 24 | static async rejectEditInGUI(view: WebView): Promise<void> { |
| 25 | await TestUtils.waitForSuccess(async () => |
| 26 | (await EditSelectors.getEditRejectButton(view)).click(), |
| 27 | ); |
| 28 | await view.switchBack(); |
| 29 | } |
| 30 | |
| 31 | static async acceptEditWithCodeLens(editor: TextEditor): Promise<void> { |
| 32 | const acceptCodeLens = await editor.getCodeLens("Accept"); |
| 33 | await acceptCodeLens?.click(); |
| 34 | } |
| 35 | |
| 36 | static async rejectEditWithCodeLens(editor: TextEditor): Promise<void> { |
| 37 | const rejectCodeLens = await editor.getCodeLens("Reject"); |
| 38 | await rejectCodeLens?.click(); |
| 39 | } |
| 40 | } |