// Copyright (C) 2026 Zaher Salman // SPDX-License-Identifier: GPL-3.0-or-later const assert = require("assert"); const fs = require("fs"); const path = require("path"); const repoRoot = path.resolve(__dirname, ".."); function testSharedHelpWindowInfrastructure() { const main = fs.readFileSync(path.join(repoRoot, "main.js"), "utf8"); const lib = fs.readFileSync(path.join(repoRoot, "muSRFitlib.js"), "utf8"); const elec = fs.readFileSync(path.join(repoRoot, "muSRFitelec.js"), "utf8"); const html = fs.readFileSync(path.join(repoRoot, "index.html"), "utf8"); const help = fs.readFileSync(path.join(repoRoot, "quick-start.html"), "utf8"); const deploy = fs.readFileSync(path.join(repoRoot, "scripts", "deploy-web.sh"), "utf8"); assert.match(main, /function createAuxiliaryWindow/); assert.match(main, /createParameterPlotWindow[\s\S]*createAuxiliaryWindow/); assert.match(main, /ipcMain\.on\("openQuickStartWindow"/); assert.match(main, /file: "quick-start\.html"/); assert.match(elec, /function openElectronAuxiliaryWindow/); assert.match(elec, /parameterPlot: "openParameterPlotWindow"/); assert.match(elec, /quickStart: "openQuickStartWindow"/); assert.match(lib, /openElectronAuxiliaryWindow\("quickStart"/); assert.match(lib, /dialog\.show\(\)/); assert.doesNotMatch(lib, /quickStartDialog[\s\S]{0,500}showModal/); assert.match(html, /class="web-plot-window quick-start-dialog"/); assert.match(html, /id="quickStartFrame"/); assert.match(help, /id="helpRuns"/); assert.match(help, /id="helpParams"/); assert.match(help, /quickStartSection/); assert.match(help, /class="quick-start-footer"/); assert.match(help, /zaher\.salman@psi\.ch/); assert.match(help, /https:\/\/musruser\.psi\.ch\/muSRFlow\/docs\//); assert.match(help, /id="helpAbout"/); assert.match(help, /About muSRFlow/); assert.match(help, /id="musrflowVersion"/); assert.match(help, /setVersion\(payload && payload\.version\)/); assert.match(main, /version: app\.getVersion\(\)/); assert.match(main, /shell\.openExternal/); assert.match(main, /setWindowOpenHandler/); assert.match(deploy, /quick-start\.html/); assert.match(deploy, /__MUSRFLOW_VERSION__/); assert.match(deploy, /node -p 'require\(process\.argv\[1\]\)\.version'/); assert.doesNotMatch(lib, /musrfit-gui|bitbucket\.org\/zaher-salman\/musrfit-gui/); } testSharedHelpWindowInfrastructure(); console.log("help window tests passed");