Skip to content

Commit

Permalink
test-clipboard-cleanup (#2368)
Browse files Browse the repository at this point in the history
## Checklist

- [ ] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [ ] I have updated the
[docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and
[cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet)
- [ ] I have not broken the cheatsheet

This should also deprecate having to solve
#559

---------

Co-authored-by: Cedric Halbronn <[email protected]>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 30, 2024
1 parent 2c73ca7 commit a497f63
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 15 deletions.
4 changes: 0 additions & 4 deletions packages/common/src/ide/normalized/NormalizedIDE.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getFixturePath } from "../../index";
import { GeneralizedRange } from "../../types/GeneralizedRange";
import { TextEditor } from "../../types/TextEditor";
import FakeClipboard from "../fake/FakeClipboard";
import FakeConfiguration from "../fake/FakeConfiguration";
import FakeGlobalState from "../fake/FakeGlobalState";
import FakeIDE from "../fake/FakeIDE";
Expand All @@ -13,7 +12,6 @@ import { QuickPickOptions } from "../types/QuickPickOptions";
export class NormalizedIDE extends PassthroughIDEBase {
configuration: FakeConfiguration;
globalState: FakeGlobalState;
clipboard: FakeClipboard;

constructor(
original: IDE,
Expand All @@ -25,8 +23,6 @@ export class NormalizedIDE extends PassthroughIDEBase {
this.messages = isSilent ? fakeIde.messages : original.messages;
this.configuration = fakeIde.configuration;
this.globalState = fakeIde.globalState;
this.clipboard = fakeIde.clipboard;

this.initializeConfiguration();
}

Expand Down
4 changes: 1 addition & 3 deletions packages/cursorless-engine/src/testUtil/takeSnapshot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Clipboard,
ExcludableSnapshotField,
ExtraContext,
ExtraSnapshotField,
Expand All @@ -23,7 +22,6 @@ export async function takeSnapshot(
marks?: SerializedMarks,
extraContext?: ExtraContext,
metadata?: unknown,
clipboard?: Clipboard,
) {
const snapshot: TestCaseSnapshot = {
documentContents: editor.document.getText(),
Expand All @@ -39,7 +37,7 @@ export async function takeSnapshot(
}

if (!excludeFields.includes("clipboard")) {
snapshot.clipboard = await (clipboard ?? ide.clipboard).readText();
snapshot.clipboard = await ide.clipboard.readText();
}

if (!excludeFields.includes("visibleRanges")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ async function runTest(file: string, spyIde: SpyIDE) {
}

if (fixture.initialState.clipboard) {
vscode.env.clipboard.writeText(fixture.initialState.clipboard);
// FIXME https://github.com/cursorless-dev/cursorless/issues/559
// spyIde.clipboard.writeText(fixture.initialState.clipboard);
spyIde.clipboard.writeText(fixture.initialState.clipboard);
}

commandServerApi.setFocusedElementType(fixture.focusedElementType);
Expand Down Expand Up @@ -188,8 +186,6 @@ async function runTest(file: string, spyIde: SpyIDE) {
spyIde.activeTextEditor!,
spyIde,
marks,
// FIXME: Stop overriding the clipboard once we have #559
true,
);

const rawSpyIdeValues = spyIde.getSpyValues(fixture.ide?.flashes != null);
Expand Down
2 changes: 0 additions & 2 deletions packages/cursorless-vscode/src/constructTestHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function constructTestHelpers(
editor: TextEditor,
ide: IDE,
marks: SerializedMarks | undefined,
forceRealClipboard: boolean,
): Promise<TestCaseSnapshot> {
return takeSnapshot(
storedTargets,
Expand All @@ -62,7 +61,6 @@ export function constructTestHelpers(
marks,
undefined,
undefined,
forceRealClipboard ? vscodeIDE.clipboard : undefined,
);
},

Expand Down
1 change: 0 additions & 1 deletion packages/vscode-common/src/TestHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface TestHelpers {
editor: TextEditor,
ide: IDE,
marks: SerializedMarks | undefined,
forceRealClipboard: boolean,
): Promise<TestCaseSnapshot>;

runIntegrationTests(): Promise<void>;
Expand Down

0 comments on commit a497f63

Please sign in to comment.