obsidian-integration-testing 1.1.2 → 1.2.1
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/README.md +241 -14
- package/dist/lib/cjs/context-id.cjs +1 -1
- package/dist/lib/cjs/context-id.d.cts +1 -1
- package/dist/lib/cjs/enable-plugin.cjs +54 -0
- package/dist/lib/cjs/enable-plugin.d.cts +44 -0
- package/dist/lib/cjs/exec.cjs +4 -4
- package/dist/lib/cjs/exec.d.cts +8 -8
- package/dist/lib/cjs/function-expression.cjs +1 -1
- package/dist/lib/cjs/function-expression.d.cts +1 -1
- package/dist/lib/cjs/index.cjs +13 -1
- package/dist/lib/cjs/index.d.cts +9 -1
- package/dist/lib/cjs/integration-global-setup.cjs +29 -7
- package/dist/lib/cjs/integration-global-setup.d.cts +1 -6
- package/dist/lib/cjs/json-with-functions.cjs +1 -1
- package/dist/lib/cjs/json-with-functions.d.cts +1 -1
- package/dist/lib/cjs/noop.cjs +1 -1
- package/dist/lib/cjs/noop.d.cts +1 -1
- package/dist/lib/cjs/obsidian-cli.cjs +10 -76
- package/dist/lib/cjs/obsidian-cli.d.cts +9 -3
- package/dist/lib/cjs/obsidian-config.cjs +1 -1
- package/dist/lib/cjs/obsidian-config.d.cts +1 -1
- package/dist/lib/cjs/temp-vault.cjs +47 -5
- package/dist/lib/cjs/temp-vault.d.cts +19 -1
- package/dist/lib/cjs/transport-appium.cjs +242 -0
- package/dist/lib/cjs/transport-appium.d.cts +164 -0
- package/dist/lib/cjs/transport-desktop-cdp.cjs +398 -0
- package/dist/lib/cjs/transport-desktop-cdp.d.cts +158 -0
- package/dist/lib/cjs/transport-desktop-cli.cjs +230 -0
- package/dist/lib/cjs/transport-desktop-cli.d.cts +65 -0
- package/dist/lib/cjs/transport-factory.cjs +143 -0
- package/dist/lib/cjs/transport-factory.d.cts +25 -0
- package/dist/lib/cjs/transport-options.cjs +17 -0
- package/dist/lib/cjs/transport-options.d.cts +100 -0
- package/dist/lib/cjs/transport.cjs +17 -0
- package/dist/lib/cjs/transport.d.cts +86 -0
- package/dist/lib/cjs/type-guards.cjs +1 -1
- package/dist/lib/cjs/type-guards.d.cts +1 -1
- package/dist/lib/cjs/vault-registry.cjs +7 -56
- package/dist/lib/cjs/vault-registry.d.cts +3 -5
- package/dist/lib/esm/context-id.d.mts +1 -1
- package/dist/lib/esm/context-id.mjs +1 -1
- package/dist/lib/esm/enable-plugin.d.mts +44 -0
- package/dist/lib/esm/enable-plugin.mjs +30 -0
- package/dist/lib/esm/exec.d.mts +8 -8
- package/dist/lib/esm/exec.mjs +4 -4
- package/dist/lib/esm/function-expression.d.mts +1 -1
- package/dist/lib/esm/function-expression.mjs +1 -1
- package/dist/lib/esm/index.d.mts +9 -1
- package/dist/lib/esm/index.mjs +9 -1
- package/dist/lib/esm/integration-global-setup.d.mts +1 -6
- package/dist/lib/esm/integration-global-setup.mjs +29 -7
- package/dist/lib/esm/json-with-functions.d.mts +1 -1
- package/dist/lib/esm/json-with-functions.mjs +1 -1
- package/dist/lib/esm/noop.d.mts +1 -1
- package/dist/lib/esm/noop.mjs +1 -1
- package/dist/lib/esm/obsidian-cli.d.mts +9 -3
- package/dist/lib/esm/obsidian-cli.mjs +10 -80
- package/dist/lib/esm/obsidian-config.d.mts +1 -1
- package/dist/lib/esm/obsidian-config.mjs +1 -1
- package/dist/lib/esm/temp-vault.d.mts +19 -1
- package/dist/lib/esm/temp-vault.mjs +54 -7
- package/dist/lib/esm/transport-appium.d.mts +164 -0
- package/dist/lib/esm/transport-appium.mjs +218 -0
- package/dist/lib/esm/transport-desktop-cdp.d.mts +158 -0
- package/dist/lib/esm/transport-desktop-cdp.mjs +364 -0
- package/dist/lib/esm/transport-desktop-cli.d.mts +65 -0
- package/dist/lib/esm/transport-desktop-cli.mjs +199 -0
- package/dist/lib/esm/transport-factory.d.mts +25 -0
- package/dist/lib/esm/transport-factory.mjs +108 -0
- package/dist/lib/esm/transport-options.d.mts +100 -0
- package/dist/lib/esm/transport-options.mjs +1 -0
- package/dist/lib/esm/transport.d.mts +86 -0
- package/dist/lib/esm/transport.mjs +1 -0
- package/dist/lib/esm/type-guards.d.mts +1 -1
- package/dist/lib/esm/type-guards.mjs +1 -1
- package/dist/lib/esm/vault-registry.d.mts +3 -5
- package/dist/lib/esm/vault-registry.mjs +7 -56
- package/dist/obsidian-integration-testing-1.2.1.tgz +0 -0
- package/package.json +12 -2
- package/patches/@wdio+protocols+9.27.0.patch +12 -0
- package/patches/@wdio+types+9.27.0.patch +13 -0
- package/patches/urlpattern-polyfill+10.1.0.patch +13 -0
- package/scripts/postinstall.mjs +29 -0
- package/dist/obsidian-integration-testing-1.1.2.tgz +0 -0
|
@@ -1,64 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const POLL_TIMEOUT_MS = 3e4;
|
|
4
|
-
const CLOSE_DELAY_MS = 1e3;
|
|
1
|
+
import { inject } from "vitest";
|
|
2
|
+
import { getOrCreateTransport } from "./transport-factory.mjs";
|
|
5
3
|
async function registerVault(vaultPath) {
|
|
6
|
-
await
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line no-shadow -- No actual shadowing as the function is executed externally.
|
|
9
|
-
fn({ vaultPath: vaultPath2 }) {
|
|
10
|
-
window.electron.ipcRenderer.sendSync("vault-open", vaultPath2, false);
|
|
11
|
-
},
|
|
12
|
-
shouldSkipPreflightChecks: true
|
|
13
|
-
});
|
|
14
|
-
const deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
15
|
-
while (Date.now() < deadline) {
|
|
16
|
-
try {
|
|
17
|
-
const basePath = await evalInObsidian({
|
|
18
|
-
fn({ app }) {
|
|
19
|
-
return app.vault.adapter.getBasePath();
|
|
20
|
-
},
|
|
21
|
-
shouldSkipPreflightChecks: true,
|
|
22
|
-
vaultPath
|
|
23
|
-
});
|
|
24
|
-
if (basePath === vaultPath) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
} catch {
|
|
28
|
-
}
|
|
29
|
-
await new Promise((r) => {
|
|
30
|
-
setTimeout(r, POLL_INTERVAL_MS);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`Vault at ${vaultPath} did not become ready within ${String(POLL_TIMEOUT_MS)}ms`);
|
|
4
|
+
const transport = await getOrCreateTransport(inject("obsidianTransport"));
|
|
5
|
+
await transport.registerVault(vaultPath);
|
|
34
6
|
}
|
|
35
7
|
async function unregisterVault(vaultPath) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fn() {
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
window.electron.remote?.getCurrentWindow().destroy();
|
|
41
|
-
}, 0);
|
|
42
|
-
},
|
|
43
|
-
shouldSkipPreflightChecks: true,
|
|
44
|
-
vaultPath
|
|
45
|
-
});
|
|
46
|
-
} catch {
|
|
47
|
-
}
|
|
48
|
-
await new Promise((r) => {
|
|
49
|
-
setTimeout(r, CLOSE_DELAY_MS);
|
|
50
|
-
});
|
|
51
|
-
await evalInObsidian({
|
|
52
|
-
args: { vaultPath },
|
|
53
|
-
// eslint-disable-next-line no-shadow -- No actual shadowing as the function is executed externally.
|
|
54
|
-
fn({ vaultPath: vaultPath2 }) {
|
|
55
|
-
window.electron.ipcRenderer.sendSync("vault-remove", vaultPath2);
|
|
56
|
-
},
|
|
57
|
-
shouldSkipPreflightChecks: true
|
|
58
|
-
});
|
|
8
|
+
const transport = await getOrCreateTransport(inject("obsidianTransport"));
|
|
9
|
+
await transport.unregisterVault(vaultPath);
|
|
59
10
|
}
|
|
60
11
|
export {
|
|
61
12
|
registerVault,
|
|
62
13
|
unregisterVault
|
|
63
14
|
};
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vc3JjL3ZhdWx0LXJlZ2lzdHJ5LnRzIl0sCiAgInNvdXJjZXNDb250ZW50Ij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1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Simplifies integration testing of Obsidian plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"obsidian",
|
|
@@ -49,7 +49,9 @@
|
|
|
49
49
|
"**/package.json",
|
|
50
50
|
"dist/",
|
|
51
51
|
"LICENSE",
|
|
52
|
-
"
|
|
52
|
+
"patches/",
|
|
53
|
+
"README.md",
|
|
54
|
+
"scripts/postinstall.mjs"
|
|
53
55
|
],
|
|
54
56
|
"scripts": {
|
|
55
57
|
"build": "jiti scripts/build.ts",
|
|
@@ -65,6 +67,7 @@
|
|
|
65
67
|
"lint:fix": "jiti scripts/lint-fix.ts",
|
|
66
68
|
"lint:md": "jiti scripts/lint-md.ts",
|
|
67
69
|
"lint:md:fix": "jiti scripts/lint-md-fix.ts",
|
|
70
|
+
"postinstall": "node scripts/postinstall.mjs",
|
|
68
71
|
"prepare": "jiti scripts/prepare.ts",
|
|
69
72
|
"spellcheck": "jiti scripts/spellcheck.ts",
|
|
70
73
|
"test": "jiti scripts/test.ts",
|
|
@@ -91,6 +94,8 @@
|
|
|
91
94
|
"@typescript-eslint/utils": "latest",
|
|
92
95
|
"@vitest/coverage-v8": "latest",
|
|
93
96
|
"@vitest/runner": "4.1.0",
|
|
97
|
+
"@wdio/protocols": "9.27.0",
|
|
98
|
+
"@wdio/types": "9.27.0",
|
|
94
99
|
"better-typescript-lib": "latest",
|
|
95
100
|
"commitizen": "latest",
|
|
96
101
|
"cspell": "latest",
|
|
@@ -113,10 +118,12 @@
|
|
|
113
118
|
"nano-staged": "latest",
|
|
114
119
|
"obsidian": "latest",
|
|
115
120
|
"obsidian-typings": "obsidian-public-latest",
|
|
121
|
+
"puppeteer-core": "latest",
|
|
116
122
|
"semver": "latest",
|
|
117
123
|
"type-fest": "latest",
|
|
118
124
|
"typescript": "latest",
|
|
119
125
|
"typescript-eslint": "latest",
|
|
126
|
+
"urlpattern-polyfill": "10.1.0",
|
|
120
127
|
"vitest": "latest"
|
|
121
128
|
},
|
|
122
129
|
"peerDependencies": {
|
|
@@ -128,5 +135,8 @@
|
|
|
128
135
|
"@antfu/utils": "9.2.0",
|
|
129
136
|
"eslint-plugin-import": "npm:eslint-plugin-import-x@latest",
|
|
130
137
|
"type-fest": "latest"
|
|
138
|
+
},
|
|
139
|
+
"dependencies": {
|
|
140
|
+
"webdriverio": "^9.27.0"
|
|
131
141
|
}
|
|
132
142
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
diff --git a/node_modules/@wdio/protocols/tsconfig.json b/node_modules/@wdio/protocols/tsconfig.json
|
|
2
|
+
index 21e7b19..8dbebc0 100644
|
|
3
|
+
--- a/node_modules/@wdio/protocols/tsconfig.json
|
|
4
|
+
+++ b/node_modules/@wdio/protocols/tsconfig.json
|
|
5
|
+
@@ -1,7 +1,5 @@
|
|
6
|
+
{
|
|
7
|
+
- "extends": "../../tsconfig",
|
|
8
|
+
"compilerOptions": {
|
|
9
|
+
- "baseUrl": ".",
|
|
10
|
+
"outDir": "build",
|
|
11
|
+
"rootDir": "src",
|
|
12
|
+
"removeComments": false
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/node_modules/@wdio/types/build/Capabilities.d.ts b/node_modules/@wdio/types/build/Capabilities.d.ts
|
|
2
|
+
index 945fb98..e17332d 100644
|
|
3
|
+
--- a/node_modules/@wdio/types/build/Capabilities.d.ts
|
|
4
|
+
+++ b/node_modules/@wdio/types/build/Capabilities.d.ts
|
|
5
|
+
@@ -146,7 +146,7 @@ export interface WithRequestedCapabilities {
|
|
6
|
+
* })
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
- capabilities: RequestedStandaloneCapabilities;
|
|
10
|
+
+ capabilities?: RequestedStandaloneCapabilities;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The `capabilities` property is a required property when defining a testrunner configuration.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/node_modules/urlpattern-polyfill/dist/index.d.ts b/node_modules/urlpattern-polyfill/dist/index.d.ts
|
|
2
|
+
index 429e17c..534a0a1 100644
|
|
3
|
+
--- a/node_modules/urlpattern-polyfill/dist/index.d.ts
|
|
4
|
+
+++ b/node_modules/urlpattern-polyfill/dist/index.d.ts
|
|
5
|
+
@@ -2,8 +2,5 @@ import type * as Types from "./types.js";
|
|
6
|
+
export { URLPattern } from "./types.js";
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
- class URLPattern extends Types.URLPattern {}
|
|
10
|
+
- type URLPatternInit = Types.URLPatternInit;
|
|
11
|
+
- type URLPatternResult = Types.URLPatternResult;
|
|
12
|
+
type URLPatternComponentResult = Types.URLPatternComponentResult;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import {
|
|
3
|
+
join,
|
|
4
|
+
relative
|
|
5
|
+
} from 'node:path/posix';
|
|
6
|
+
import {
|
|
7
|
+
cwd,
|
|
8
|
+
env
|
|
9
|
+
} from 'node:process';
|
|
10
|
+
|
|
11
|
+
const isGlobalInstall = env.npm_config_global === 'true';
|
|
12
|
+
|
|
13
|
+
if (isGlobalInstall) {
|
|
14
|
+
console.log('Global install detected, skipping patch-package...');
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let pkgDir = cwd().replace(/\\/g, '/');
|
|
19
|
+
const patchDir = join(pkgDir, 'patches');
|
|
20
|
+
const relativePath = '/node_modules/obsidian-integration-testing';
|
|
21
|
+
if (pkgDir.endsWith(relativePath)) {
|
|
22
|
+
pkgDir = pkgDir.slice(0, -relativePath.length);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
spawnSync(`npx patch-package --patch-dir "${relative(pkgDir, patchDir)}"`, {
|
|
26
|
+
shell: true,
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
cwd: pkgDir
|
|
29
|
+
});
|
|
Binary file
|