-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit-id:45249b72
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
import commandExists = require("command-exists"); | ||
|
||
export const is_scarb_available = () => | ||
commandExists("scarb") | ||
.then(() => true) | ||
.catch(() => false); |
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,6 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "empty" | ||
version = "0.1.0" |
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,3 @@ | ||
[package] | ||
name = "empty" | ||
version = "0.1.0" |
Empty file.
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,71 @@ | ||
import { EditorView, StatusBar, VSBrowser, WebElement, Workbench } from "vscode-extension-tester"; | ||
import { expect } from "chai"; | ||
import { is_scarb_available } from "../test-support/scarb"; | ||
import * as path from "path"; | ||
|
||
describe("Status bar test", function () { | ||
this.timeout(50000); | ||
|
||
let is_scarb: boolean; | ||
|
||
before(async function () { | ||
is_scarb = await is_scarb_available(); | ||
|
||
await VSBrowser.instance.openResources(path.join("ui-test-resources", "empty")); | ||
}); | ||
|
||
afterEach(async function () { | ||
await new EditorView().closeAllEditors(); | ||
}); | ||
|
||
it("checks if status bar is displaying correct message", async function () { | ||
const statusBar = await VSBrowser.instance.driver.wait( | ||
getStatusBarItem, | ||
5000, | ||
"failed to obtain Cairo status bar", | ||
// Check every 0.5 second. | ||
500, | ||
); | ||
|
||
expect(statusBar).not.undefined; | ||
|
||
// `new StatusBar().getItem("Cairo")` is broken and searches not only in title. | ||
const title = await statusBar!.getAttribute(StatusBar["locators"].StatusBar.itemTitle); | ||
|
||
if (is_scarb) { | ||
expect(title).to.match( | ||
/Cairo, Cairo Language\nscarb .+ \(.+\)\ncairo: .+ \(.+\)\nsierra: .+/, | ||
); | ||
} else { | ||
expect(title).to.be.eq("Cairo, Cairo Language"); | ||
} | ||
}); | ||
|
||
it("checks if status bar is disabled", async function () { | ||
const settings = await new Workbench().openSettings(); | ||
|
||
const setting = await settings.findSetting("Show In Status Bar", "Cairo1"); | ||
setting.setValue(false); | ||
|
||
// Wait so extension have time to refresh. | ||
await new Promise((done) => setTimeout(done, 2000)); | ||
|
||
const statusBar = await getStatusBarItem(); | ||
|
||
expect(statusBar).to.be.undefined; | ||
}); | ||
}); | ||
|
||
async function getStatusBarItem(): Promise<WebElement | undefined> { | ||
const items = await new StatusBar().getItems(); | ||
|
||
for (const item of items) { | ||
const text = await item.getText(); | ||
|
||
if (text.startsWith("Cairo")) { | ||
return item; | ||
} | ||
} | ||
|
||
return undefined; | ||
} |