Skip to content

Commit

Permalink
Clean up "renaming files works"
Browse files Browse the repository at this point in the history
  • Loading branch information
sungshik committed Dec 20, 2024
1 parent ea21fce commit da3c084
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions rascal-vscode-extension/src/test/vscode-suite/ide.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,15 @@ describe('IDE', function () {
await bench.executeCommand("workbench.files.action.refreshFilesExplorer")

Check warning on line 202 in rascal-vscode-extension/src/test/vscode-suite/ide.test.ts

View workflow job for this annotation

GitHub Actions / ESLint

rascal-vscode-extension/src/test/vscode-suite/ide.test.ts#L202

Missing semicolon (@typescript-eslint/semi)
const workspace = await explorer.getContent().getSection("test (Workspace)");
await workspace.expand();
await ide.openModule(TestWorkspace.libFile);

// Open the lib file before moving it, so we have the editor ready to inspect afterwards
const libFile = await ide.openModule(TestWorkspace.libFile);
await ide.screenshot("IDE-find-files-in-explorer");
const libFileInTree = await driver.wait(async() => workspace.findItem("Lib.rsc"), Delays.normal, "Cannot find Lib.rsc");
const libFolderInTree = await driver.wait(async() => workspace.findItem("lib"), Delays.normal, "Cannot find lib folder");

// Before moving, check that Rascal is really loaded
const checkRascalStatus = ide.statusContains("Loading Rascal");
await driver.wait(async () => !(await checkRascalStatus()), Delays.extremelySlow, "Rascal evaluators have not finished loading");

if (!libFileInTree) {fail("Could not find Lib.rsc");}
if (!libFolderInTree) {fail("Could not find lib folder");}

// Move the file
await ide.screenshot("1IDE-rename-before-move");
if (os.type() === "Darwin") {
// Context menus are not supported for macOS:
// https://github.com/redhat-developer/vscode-extension-tester/blob/main/KNOWN_ISSUES.md#macos-known-limitations-of-native-objects
Expand All @@ -230,8 +223,8 @@ describe('IDE', function () {
// on how to scroll the Explorer down:
// https://github.com/redhat-developer/vscode-extension-tester/blob/1bd6c23b25673a76f4a9d139f4572c0ea6f55a7b/packages/page-objects/src/components/sidebar/tree/default/DefaultTreeSection.ts#L36-L59

console.log("Entering special case...");
const treeDiv = await workspace.findElement(By.className('monaco-list')); // This div contains the whole visible tree in the Explorer
// Find the div that contains the whole visible tree in the Explorer
const treeDiv = await workspace.findElement(By.className('monaco-list'));

// Cut
const libFileInTreeDiv = (await treeDiv.findElements(By.xpath(`.//div[@role='treeitem' and @aria-label='Lib.rsc']`)))[0];
Expand All @@ -242,11 +235,15 @@ describe('IDE', function () {
const libFolderInTreeDiv = (await treeDiv.findElements(By.xpath(`.//div[@role='treeitem' and @aria-label='lib']`)))[0];
await libFolderInTreeDiv?.click(); // Must click on this div instead of the object returned by `findItem`
await treeDiv.sendKeys(Key.COMMAND, 'v', Key.COMMAND); // Only this div handles key events; not `libFolderInTreeDiv`
} else {
await driver.wait(ignoreFails((await libFileInTree.openContextMenu()).select("Cut")), Delays.slow);
await driver.wait(ignoreFails((await libFolderInTree.openContextMenu()).select("Paste")), Delays.slow);
}
await ide.screenshot("5IDE-rename-after-paste");

else {
// Context menus are supported for Windows and Linux
const libFileInTree = await driver.wait(async() => workspace.findItem("Lib.rsc"), Delays.normal, "Cannot find Lib.rsc");
const libFolderInTree = await driver.wait(async() => workspace.findItem("lib"), Delays.normal, "Cannot find lib folder");
await driver.wait(ignoreFails((await libFileInTree!.openContextMenu()).select("Cut")), Delays.slow);
await driver.wait(ignoreFails((await libFolderInTree!.openContextMenu()).select("Paste")), Delays.slow);
}

await driver.wait(async() => {
const text = await libFile.getText();
Expand Down

0 comments on commit da3c084

Please sign in to comment.