Permalink
Newer
100644
49 lines (44 sloc)
1.54 KB
1
const Application = require("spectron").Application;
2
const { assert } = require("chai");
3
const fs = require("fs");
4
5
describe("Plugin", function () {
6
this.timeout(10000);
7
8
beforeEach(async function () {
9
let path = process.env.OBSIDIAN_PATH;
10
if (!path) {
11
path = "/obsidian/obsidian";
12
}
13
this.app = new Application({ path });
14
await this.app.start();
15
const client = this.app.client;
16
17
// Open the vault. Webdriver hates file picker dialogs.
18
await client.execute(
19
"require('electron').ipcRenderer.sendSync('vaultOpen', 'test/empty_vault', false)"
20
);
21
await client.windowByIndex(1);
22
await (await client.$(".empty-state-title")).waitForExist();
23
// Disable safemode and turn on our plugin
24
await client.execute(
25
"app.plugins.setEnable(true);app.plugins.enablePlugin('obsidian-sample-plugin')"
26
);
27
// Dismiss warning model and get out of settings
28
await (await client.$(".modal-button-container button:last-child")).click();
29
await (await client.$(".modal-close-button")).click();
30
});
31
32
afterEach(function () {
33
if (this.app && this.app.isRunning()) {
34
return this.app.stop();
35
}
36
});
37
38
it("adds command", async function () {
39
const client = this.app.client;
40
await (
41
await client.$(
42
'.side-dock-ribbon-action[aria-label="Open command palette"]'
43
)
44
).click();
45
await (await client.$(".prompt-input")).keys("Sample Plugin");
46
await (await client.$(".suggestion-item")).click();
47
await (await client.$('//*[text()="Woah!"]')).isExisting();
48
});
49
});