obsidian-testing-framework 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/fixtures.d.ts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -10
- package/package.json +1 -1
package/lib/fixtures.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const test: import("vitest").TestAPI<{
|
|
|
7
7
|
page: import("playwright-core").Page;
|
|
8
8
|
obsidian: ObsidianTestingConfig;
|
|
9
9
|
electronApp: import("playwright-core").ElectronApplication;
|
|
10
|
+
___vaultId: string;
|
|
10
11
|
appHandle: import("playwright-core").JSHandle<import("obsidian").App>;
|
|
11
12
|
vaultPoolDir: string;
|
|
12
13
|
}>;
|
package/lib/index.js
CHANGED
|
@@ -19,14 +19,13 @@ function findConfig() {
|
|
|
19
19
|
}
|
|
20
20
|
catch (e) { }
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
return obsidianConfigFile;
|
|
22
|
+
return configLocation;
|
|
24
23
|
}
|
|
25
24
|
function generateVaultConfig(vault, concurrent, vaultPoolDir) {
|
|
26
25
|
const vaultHash = randomBytes(8).toString("hex").toLocaleLowerCase();
|
|
27
26
|
let configLocation = findConfig();
|
|
28
27
|
console.log("vault is", vault, existsSync(vault));
|
|
29
|
-
const obsidianConfigFile =
|
|
28
|
+
const obsidianConfigFile = path.join(configLocation, "obsidian.json");
|
|
30
29
|
if (!existsSync(obsidianConfigFile)) {
|
|
31
30
|
writeFileSync(obsidianConfigFile, JSON.stringify({ vaults: {} }));
|
|
32
31
|
}
|
|
@@ -70,18 +69,24 @@ export const test = base.extend({
|
|
|
70
69
|
},
|
|
71
70
|
{ scope: "worker", auto: true },
|
|
72
71
|
],
|
|
73
|
-
|
|
72
|
+
___vaultId: [
|
|
74
73
|
async ({ vaultPoolDir }, run) => {
|
|
75
|
-
const obsidianPath = inject("obsidianPath") ?? undefined;
|
|
76
74
|
const vault = inject("vault");
|
|
77
75
|
const concurrent = inject("concurrent") ?? "copy";
|
|
78
76
|
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
|
|
77
|
+
const vaultId = generateVaultConfig(vault, concurrent, vaultPoolDir);
|
|
78
|
+
await run(vaultId);
|
|
79
|
+
},
|
|
80
|
+
{ auto: true },
|
|
81
|
+
],
|
|
82
|
+
electronApp: [
|
|
83
|
+
async ({ ___vaultId: vaultId }, run) => {
|
|
84
|
+
const obsidianPath = inject("obsidianPath") ?? undefined;
|
|
79
85
|
console.log("asar located at:", getExe(obsidianPath));
|
|
80
86
|
let uriArg = "";
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
uriArg = `obsidian://open?vault=${encodeURIComponent(id)}`;
|
|
87
|
+
if (vaultId) {
|
|
88
|
+
if (!!vaultId) {
|
|
89
|
+
uriArg = `obsidian://open?vault=${encodeURIComponent(vaultId)}`;
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
const electronApp = await electron.launch({
|
|
@@ -96,10 +101,13 @@ export const test = base.extend({
|
|
|
96
101
|
{ auto: true },
|
|
97
102
|
],
|
|
98
103
|
page: [
|
|
99
|
-
async ({ electronApp }, run) => {
|
|
104
|
+
async ({ electronApp, ___vaultId: vaultId }, run) => {
|
|
100
105
|
const windows = electronApp.windows();
|
|
101
106
|
// console.log("windows", windows);
|
|
102
107
|
let page = windows[windows.length - 1];
|
|
108
|
+
await page.evaluate(() => {
|
|
109
|
+
window.localStorage.setItem(`enable-plugin-${vaultId}`, "true");
|
|
110
|
+
});
|
|
103
111
|
await page.waitForLoadState("domcontentloaded");
|
|
104
112
|
try {
|
|
105
113
|
await waitForIndexingComplete(page);
|