open-nomad/e2e/ui/global-setup.js
Tim Gross 2ad9f6bc5f
E2E: playwright configuration and smoke test (#12721)
Scripts for running playwright tests in a Docker container that has
chromium and webkit preinstalled. Includes a basic smoke test for
authentication so that we can be sure the test rig is working
end-to-end. Wiring this up in CI will be in an upcoming PR.
2022-04-21 09:13:10 -04:00

25 lines
781 B
JavaScript

const { chromium } = require('@playwright/test');
module.exports = async config => {
var NOMAD_TOKEN = process.env.NOMAD_TOKEN;
if (NOMAD_TOKEN === undefined || NOMAD_TOKEN === "") {
return
}
var NOMAD_ADDR = process.env.NOMAD_ADDR;
if (NOMAD_ADDR == undefined || NOMAD_ADDR == "") {
NOMAD_ADDR = 'http://localhost:4646';
}
const browser = await chromium.launch();
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
await page.goto(NOMAD_ADDR+'/ui/settings/tokens');
await page.fill('input[id="token-input"]', NOMAD_TOKEN);
await page.click('button:has-text("Set Token")', {strict: true});
await page.context().storageState({ path: 'storageState.json' });
await browser.close();
};