This commit is contained in:
parent
e58cef7a59
commit
2a63c0a742
@ -6,6 +6,7 @@ import { ObsidianTestFixtures } from "./fixtures.js";
|
|||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
import { getApp, waitForIndexingComplete } from "./util.js";
|
import { getApp, waitForIndexingComplete } from "./util.js";
|
||||||
import {execSync} from "child_process";
|
import {execSync} from "child_process";
|
||||||
|
import { Page } from "playwright";
|
||||||
|
|
||||||
export interface ObsidianTestingConfig {
|
export interface ObsidianTestingConfig {
|
||||||
vault?: string;
|
vault?: string;
|
||||||
@ -33,6 +34,18 @@ export function getExe(): string {
|
|||||||
return ""
|
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> = {
|
const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
||||||
electronApp: [
|
electronApp: [
|
||||||
async ({ obsidian: { vault } }, run) => {
|
async ({ obsidian: { vault } }, run) => {
|
||||||
@ -57,10 +70,13 @@ const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
|
|||||||
{ timeout: 60000 },
|
{ timeout: 60000 },
|
||||||
],
|
],
|
||||||
page: [
|
page: [
|
||||||
async ({ electronApp }, run) => {
|
async ({ electronApp, obsidian: {vault} }, run) => {
|
||||||
const page = await electronApp.firstWindow();
|
const windows = electronApp.windows();
|
||||||
|
console.log("windows", windows);
|
||||||
|
const page = windows.last()!;
|
||||||
await page.waitForEvent("load")
|
await page.waitForEvent("load")
|
||||||
await page.waitForLoadState("domcontentloaded");
|
await page.waitForLoadState("domcontentloaded");
|
||||||
|
await selectNewVault(page, vault!);
|
||||||
await waitForIndexingComplete(await getApp(page));
|
await waitForIndexingComplete(await getApp(page));
|
||||||
page.on("console", async (msg) => {
|
page.on("console", async (msg) => {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -35,7 +35,7 @@ export default defineConfig<ObsidianTestFixtures>({
|
|||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
obsidian: {
|
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