This commit is contained in:
parent
e58cef7a59
commit
2a63c0a742
@ -6,6 +6,7 @@ import { ObsidianTestFixtures } from "./fixtures.js";
|
||||
import { existsSync } from "fs";
|
||||
import { getApp, waitForIndexingComplete } from "./util.js";
|
||||
import {execSync} from "child_process";
|
||||
import { Page } from "playwright";
|
||||
|
||||
export interface ObsidianTestingConfig {
|
||||
vault?: string;
|
||||
@ -33,6 +34,18 @@ export function getExe(): string {
|
||||
return ""
|
||||
}
|
||||
|
||||
async function selectNewVault(page: Page, vaultPath: string) {
|
||||
try {
|
||||
let btn = await page.locator("button", {hasText: "Open"});
|
||||
const promise = page.waitForEvent("filechooser");
|
||||
await btn.click();
|
||||
const chooser = await promise;
|
||||
await chooser.setFiles(vaultPath);
|
||||
} catch(e) {
|
||||
console.debug("congratulations, you don't have to choose a vault manually!")
|
||||
}
|
||||
}
|
||||
|
||||
const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
||||
electronApp: [
|
||||
async ({ obsidian: { vault } }, run) => {
|
||||
@ -57,10 +70,13 @@ const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
||||
{ timeout: 60000 },
|
||||
],
|
||||
page: [
|
||||
async ({ electronApp }, run) => {
|
||||
const page = await electronApp.firstWindow();
|
||||
async ({ electronApp, obsidian: {vault} }, run) => {
|
||||
const windows = electronApp.windows();
|
||||
console.log("windows", windows);
|
||||
const page = windows.last()!;
|
||||
await page.waitForEvent("load")
|
||||
await page.waitForLoadState("domcontentloaded");
|
||||
await selectNewVault(page, vault!);
|
||||
await waitForIndexingComplete(await getApp(page));
|
||||
page.on("console", async (msg) => {
|
||||
console.log(
|
||||
|
@ -35,7 +35,7 @@ export default defineConfig<ObsidianTestFixtures>({
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
obsidian: {
|
||||
vault: path.resolve(path.join(process.cwd(), "..", "..", "vault", "test-framework-tester"))
|
||||
vault: path.resolve(process.cwd(), "..", "..", path.join("vault", "test-framework-tester"))
|
||||
}
|
||||
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user