Files
nextcloud/php/tests/tests/desec-helpers.js
T
Simon L. 4c8012adcd test(desec): end-to-end Playwright coverage against a local mock
- desec-mock.mjs: a dependency-free Node mock of the deSEC API endpoints the code
  uses, with the real status-code semantics (202 on account creation, 403 until
  verified then 200 + token, 201/409 on domain creation) plus /__control hooks to
  verify and reset state.
- desec-register.spec.js / desec-existing.spec.js drive the real AIO UI through
  the register -> verify -> domain flow and the existing-account login flow;
  desec-helpers.js holds the shared login helper. Each scenario ends by setting a
  domain, so they run as separate CI steps with a re-seed in between.
- seed-desec-mock-config.php points desec_api_base / desec_update_url at the mock
  (config key only, no env override, so production is unaffected) and seeds a
  known master password, since seeding configuration.json makes AIO consider
  itself already installed and /setup no longer shows a generated password.
- Both Playwright workflows start the mock, mount ./community-containers so the
  caddy/dnsmasq definitions enabled by the flow are present, seed the config, and
  run the two deSEC specs with a re-seed between them.

Co-Authored-By: szaimen <42591237+szaimen@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
2026-06-18 13:19:16 +02:00

23 lines
991 B
JavaScript

// Shared helpers for the deSEC Playwright scenarios.
//
// The deSEC mock is wired up by seeding configuration.json (see seed-desec-mock-config.php),
// which makes AIO consider itself already installed: /setup no longer renders the
// initial-password page. The seed step therefore writes a known master password (AIO_TEST_PASSWORD)
// that we log in with directly here instead of scraping it from /setup.
export const DESEC_MOCK_URL = process.env.DESEC_MOCK_URL ?? 'http://localhost:8090';
const AIO_PASSWORD = process.env.AIO_TEST_PASSWORD;
export async function logInToContainersPage(page) {
if (!AIO_PASSWORD) {
throw new Error('AIO_TEST_PASSWORD must be set to the master password seeded into configuration.json');
}
await page.goto('./');
await page.locator('#master-password').click();
await page.locator('#master-password').fill(AIO_PASSWORD);
await page.getByRole('button', { name: 'Log in' }).click();
await page.waitForURL('./containers');
return page;
}