28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { launchObsidian, withPlugin } from "./harness";
|
|
|
|
test("plugin loads, command registered, modal opens & prefills", async () => {
|
|
const obs = await launchObsidian();
|
|
try {
|
|
await withPlugin(obs, "jekyll-publish");
|
|
|
|
const hasCommand = await obs.page.evaluate(() =>
|
|
Boolean((window as any).app.commands.commands["jekyll-publish:publish-current-note"])
|
|
);
|
|
expect(hasCommand).toBe(true);
|
|
|
|
const modalOpened = await obs.page.evaluate(async () => {
|
|
const app = (window as any).app;
|
|
const file = app.vault.getFiles().find((f: any) => f.extension === "md");
|
|
await app.workspace.getLeaf(true).openFile(file);
|
|
app.commands.executeCommandById("jekyll-publish:publish-current-note");
|
|
await new Promise((r) => setTimeout(r, 500));
|
|
const heading = document.querySelector(".modal-container h2");
|
|
return heading?.textContent ?? "";
|
|
});
|
|
expect(modalOpened).toContain("Publish to Jekyll");
|
|
} finally {
|
|
await obs.close();
|
|
}
|
|
});
|