chore: add E2E testing infrastructure with Playwright

- Add Playwright and @electron/asar dev dependencies
- Add e2e, e2e:setup, and e2e:launch npm scripts
- Update copy-files.mjs to default to tasknotes-e2e-vault in repo
- Add .gitignore entries for test artifacts and unpacked Obsidian
This commit is contained in:
callumalpass 2025-12-30 21:21:13 +11:00
parent df674a0523
commit 0b104f0cb1
4 changed files with 114 additions and 8 deletions

7
.gitignore vendored
View file

@ -58,6 +58,11 @@ webhook*.log
external/tasknotes-e2e/.e2e/
C/
.copy-files.local
# E2E testing - unpacked Obsidian and test results
.obsidian-unpacked/
test-results/
tasknotes-e2e-vault/.obsidian/plugins/tasknotes/
.augment
# Test output files
jest-out.txt
@ -66,4 +71,4 @@ BASES_API_EXPLORATION.md
BASES_API_MIGRATION.md
OBSIDIAN-SERVER-README.md
obsidian-help
obsidian-api
obsidian-api

View file

@ -1,12 +1,15 @@
#!/usr/bin/env node
import { copyFile, mkdir, access, constants, readFile } from 'fs/promises';
import { join, resolve } from 'path';
import os from 'os';
import { join, resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
// Default copy destination - can be overridden with OBSIDIAN_PLUGIN_PATH environment variable
// Use os.homedir() to avoid literal "$HOME" not being expanded by Node
const defaultPath = join(os.homedir(), 'testvault', 'test', '.obsidian', 'plugins', 'tasknotes');
// Get current script directory
const __dirname = dirname(fileURLToPath(import.meta.url));
// Default copy destination - the e2e-vault in this repo
// Can be overridden with OBSIDIAN_PLUGIN_PATH environment variable or .copy-files.local file
const defaultPath = join(__dirname, 'tasknotes-e2e-vault', '.obsidian', 'plugins', 'tasknotes');
const LOCAL_OVERRIDE_FILE = '.copy-files.local';
let copyPath = process.env.OBSIDIAN_PLUGIN_PATH || defaultPath;
try {

93
package-lock.json generated
View file

@ -27,6 +27,8 @@
"devDependencies": {
"@codemirror/autocomplete": "^6.19.1",
"@codemirror/state": "^6.5.2",
"@electron/asar": "^3.4.1",
"@playwright/test": "^1.57.0",
"@types/jest": "^30.0.0",
"@types/node": "^24.3.0",
"@types/yaml": "^1.9.6",
@ -872,6 +874,34 @@
"node": ">=18"
}
},
"node_modules/@electron/asar": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz",
"integrity": "sha512-i4/rNPRS84t0vSRa2HorerGRXWyF4vThfHesw0dmcWHp+cspK743UanA0suA5Q5y8kzY2y6YKrvbIUn69BCAiA==",
"dev": true,
"license": "MIT",
"dependencies": {
"commander": "^5.0.0",
"glob": "^7.1.6",
"minimatch": "^3.0.4"
},
"bin": {
"asar": "bin/asar.js"
},
"engines": {
"node": ">=10.12.0"
}
},
"node_modules/@electron/asar/node_modules/commander": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
"integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 6"
}
},
"node_modules/@electron/get": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz",
@ -3074,6 +3104,22 @@
"url": "https://opencollective.com/unts"
}
},
"node_modules/@playwright/test": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.57.0.tgz",
"integrity": "sha512-6TyEnHgd6SArQO8UO2OMTxshln3QMWBtPGrOCgs3wVEmQmwyuNtB10IZMfmYDE0riwNR1cu4q+pPcxMVtaG3TA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.57.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@sinclair/typebox": {
"version": "0.34.41",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.41.tgz",
@ -11106,6 +11152,53 @@
"pathe": "^2.0.3"
}
},
"node_modules/playwright": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.57.0.tgz",
"integrity": "sha512-ilYQj1s8sr2ppEJ2YVadYBN0Mb3mdo9J0wQ+UuDhzYqURwSoW4n1Xs5vs7ORwgDGmyEh33tRMeS8KhdkMoLXQw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.57.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.57.0.tgz",
"integrity": "sha512-agTcKlMw/mjBWOnD6kFZttAAGHgi/Nw0CZ2o6JqWSbMlI219lAFLZZCyqByTsvVAJq5XA5H8cA6PrvBRpBWEuQ==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/playwright/node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/points-on-curve": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz",

View file

@ -5,10 +5,13 @@
"main": "main.js",
"scripts": {
"build": "npm run build-css && node generate-release-notes-import.mjs && tsc -noEmit --skipLibCheck && node esbuild.config.mjs production",
"dev": "npm run build && npm run copy-files",
"dev:watch": "npm run build-css && node generate-release-notes-import.mjs && node esbuild.config.mjs",
"dev": "npm run build-css && node generate-release-notes-import.mjs && node esbuild.config.mjs",
"build:test": "npm run build && node copy-files.mjs",
"copy-files": "node copy-files.mjs",
"build-css": "node build-css.mjs",
"e2e": "playwright test",
"e2e:setup": "bash e2e-setup.sh",
"e2e:launch": "bash e2e-launch.sh",
"version": "node version-bump.mjs && node generate-release-notes-import.mjs && git add manifest.json versions.json src/releaseNotes.ts",
"test": "jest",
"test:watch": "jest --watch",
@ -37,6 +40,8 @@
"devDependencies": {
"@codemirror/autocomplete": "^6.19.1",
"@codemirror/state": "^6.5.2",
"@electron/asar": "^3.4.1",
"@playwright/test": "^1.57.0",
"@types/jest": "^30.0.0",
"@types/node": "^24.3.0",
"@types/yaml": "^1.9.6",