Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (44 sloc)
1.54 KB
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
| const Application = require("spectron").Application; | |
| const { assert } = require("chai"); | |
| const fs = require("fs"); | |
| describe("Plugin", function () { | |
| this.timeout(10000); | |
| beforeEach(async function () { | |
| let path = process.env.OBSIDIAN_PATH; | |
| if (!path) { | |
| path = "/obsidian/obsidian"; | |
| } | |
| this.app = new Application({ path }); | |
| await this.app.start(); | |
| const client = this.app.client; | |
| // Open the vault. Webdriver hates file picker dialogs. | |
| await client.execute( | |
| "require('electron').ipcRenderer.sendSync('vaultOpen', 'test/empty_vault', false)" | |
| ); | |
| await client.windowByIndex(1); | |
| await (await client.$(".empty-state-title")).waitForExist(); | |
| // Disable safemode and turn on our plugin | |
| await client.execute( | |
| "app.plugins.setEnable(true);app.plugins.enablePlugin('obsidian-sample-plugin')" | |
| ); | |
| // Dismiss warning model and get out of settings | |
| await (await client.$(".modal-button-container button:last-child")).click(); | |
| await (await client.$(".modal-close-button")).click(); | |
| }); | |
| afterEach(function () { | |
| if (this.app && this.app.isRunning()) { | |
| return this.app.stop(); | |
| } | |
| }); | |
| it("adds command", async function () { | |
| const client = this.app.client; | |
| await ( | |
| await client.$( | |
| '.side-dock-ribbon-action[aria-label="Open command palette"]' | |
| ) | |
| ).click(); | |
| await (await client.$(".prompt-input")).keys("Sample Plugin"); | |
| await (await client.$(".suggestion-item")).click(); | |
| await (await client.$('//*[text()="Woah!"]')).isExisting(); | |
| }); | |
| }); |