clean stuff up
Some checks failed
Playwright Tests / test (push) Failing after 3m17s

This commit is contained in:
parent 2188e3d0b6
commit e0f9022dd9
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -2,10 +2,8 @@ import { test as base } from "@playwright/test";
import { _electron as electron } from "playwright"; import { _electron as electron } from "playwright";
import { Fixtures } from "@playwright/test"; import { Fixtures } from "@playwright/test";
import path from "path"; import path from "path";
import { extractAll } from "asar";
import { ObsidianTestFixtures } from "./fixtures.js"; import { ObsidianTestFixtures } from "./fixtures.js";
import tmp from "tmp"; import { existsSync } from "fs";
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
import { getApp, waitForIndexingComplete } from "./util.js"; import { getApp, waitForIndexingComplete } from "./util.js";
export interface ObsidianTestingConfig { export interface ObsidianTestingConfig {
@ -18,7 +16,7 @@ export function getExe(): string {
process.env.LOCALAPPDATA!, process.env.LOCALAPPDATA!,
"Obsidian", "Obsidian",
"Resources", "Resources",
"obsidian.asar" "app.asar"
); );
} }
if (process.platform == "darwin") { if (process.platform == "darwin") {
@ -26,7 +24,7 @@ export function getExe(): string {
} }
const possibleDirs = ["/opt/Obsidian", "/usr/lib/Obsidian", "/opt/obsidian", "/usr/lib/obsidian", "/var/lib/flatpak/app/md.obsidian.Obsidian/current/active/files", "/snap/obsidian/current"]; const possibleDirs = ["/opt/Obsidian", "/usr/lib/Obsidian", "/opt/obsidian", "/usr/lib/obsidian", "/var/lib/flatpak/app/md.obsidian.Obsidian/current/active/files", "/snap/obsidian/current"];
for(let i = 0; i < possibleDirs.length; i++) { for(let i = 0; i < possibleDirs.length; i++) {
if(existsSync(possibleDirs[i])) return path.join(possibleDirs[i], "resources", "obsidian.asar"); if(existsSync(possibleDirs[i])) return path.join(possibleDirs[i], "resources", "app.asar");
} }
return "" return ""
} }
@ -35,30 +33,11 @@ const obsidianTestFixtures: Fixtures<ObsidianTestFixtures> = {
electronApp: [ electronApp: [
async ({ obsidian: { vault } }, run) => { async ({ obsidian: { vault } }, run) => {
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true"; process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true";
let mainFile = path.join(tmp.tmpdir, "obsidian");
let electronFile = path.join(tmp.tmpdir, "electron");
const packageJsonFile = path.join(tmp.tmpdir, "obsidian", "package.json");
try {
rmSync(mainFile, { recursive: true });
rmSync(electronFile, { recursive: true });
mkdirSync(electronFile);
mkdirSync(mainFile);
} catch (e) {}
extractAll(getExe(), mainFile);
extractAll(path.join(path.dirname(getExe()), "app.asar"), electronFile);
renameSync(
path.join(mainFile, "main.js"),
path.join(mainFile, "index.js")
);
const packageJson = JSON.parse(readFileSync(packageJsonFile).toString());
// packageJson.main = "app.js";
writeFileSync(packageJsonFile, JSON.stringify(packageJson));
const electronApp = await electron.launch({ const electronApp = await electron.launch({
timeout: 10000, timeout: 10000,
cwd: mainFile,
args: [ args: [
path.join(path.dirname(getExe()), "app.asar"), getExe(),
!!vault && `obsidian://open?vault=${encodeURI(vault)}`, !!vault && `obsidian://open?vault=${encodeURI(vault)}`,
].filter((a) => !!a) as string[], ].filter((a) => !!a) as string[],
}); });