Add a dedicated, gitignored testrunner account auto-created by the suite (make test-account, also invoked from global-setup) so `make test` no longer needs the real account in .env. The target uses --admin-type both so the account has admin.login for the gpx-manager specs. test-post.sh switches its login POST to --data-urlencode to survive special chars in credentials. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Np4cMQLF77i664CAQXySzU
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { execSync } = require('child_process');
|
|
|
|
module.exports = async function globalSetup() {
|
|
const envFile = path.join(__dirname, '../.env');
|
|
if (fs.existsSync(envFile)) {
|
|
fs.readFileSync(envFile, 'utf-8').split(/\r?\n/).forEach(line => {
|
|
const m = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
|
|
if (m && !process.env[m[1]]) {
|
|
process.env[m[1]] = m[2].trim().replace(/^(['"])(.*)\1$/, '$2');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Local test-account defaults (mirror the Makefile) so direct `npx playwright
|
|
// test` runs are self-contained without needing GRAV_TEST_* in .env.
|
|
if (!process.env.GRAV_TEST_USER) process.env.GRAV_TEST_USER = 'testrunner';
|
|
if (!process.env.GRAV_TEST_PASS) process.env.GRAV_TEST_PASS = 'Testpass1234';
|
|
|
|
// Ensure the local test account exists (idempotent; never committed).
|
|
execSync('make test-account', { cwd: path.join(__dirname, '..'), stdio: 'inherit' });
|
|
|
|
// Ensure demo content is loaded (italy-2026-demo trip + stories + GPX files)
|
|
execSync('make demo-load', { cwd: path.join(__dirname, '..'), stdio: 'inherit' });
|
|
};
|