add ci files

This commit is contained in:
Girish Ramakrishnan 2024-10-03 18:23:28 +02:00
parent e0a5ac3fe2
commit bcde4b30d6
1 changed files with 19 additions and 9 deletions

View File

@ -1,11 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/* jshint esversion: 8 */ /* jshint esversion: 8 */
/* global describe */ /* global it, xit, describe, before, after, afterEach */
/* global before */
/* global after */
/* global it */
/* global xit */
'use strict'; 'use strict';
@ -28,24 +24,38 @@ if (!process.env.USERNAME || !process.env.PASSWORD) {
describe('Application life cycle test', function () { describe('Application life cycle test', function () {
this.timeout(0); this.timeout(0);
const LOCATION = 'test'; const LOCATION = process.env.LOCATION || 'test';
const TEST_TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 30000; const TEST_TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 30000;
const BUCKET = 'cloudrontestbucket'; const BUCKET = 'cloudrontestbucket';
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
let browser, app; let browser, app;
let athenticated_by_oidc = false, rootPassword; let athenticated_by_oidc = false, rootPassword;
let username = process.env.USERNAME; const username = process.env.USERNAME;
let password = process.env.PASSWORD; const password = process.env.PASSWORD;
before(function () { before(function () {
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build(); const chromeOptions = new Options().windowSize({ width: 1280, height: 1024 });
if (process.env.CI) chromeOptions.addArguments('no-sandbox', 'disable-dev-shm-usage', 'headless');
browser = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build();
if (!fs.existsSync('./screenshots')) fs.mkdirSync('./screenshots');
}); });
after(function () { after(function () {
browser.quit(); browser.quit();
}); });
afterEach(async function () {
if (!process.env.CI || !app) return;
const currentUrl = await browser.getCurrentUrl();
if (!currentUrl.includes(app.domain)) return;
expect(this.currentTest.title).to.be.a('string');
const screenshotData = await browser.takeScreenshot();
fs.writeFileSync(`./screenshots/${new Date().getTime()}-${this.currentTest.title.replaceAll(' ', '_')}.png`, screenshotData, 'base64');
});
async function waitForElement(elem) { async function waitForElement(elem) {
await browser.wait(until.elementLocated(elem), TEST_TIMEOUT); await browser.wait(until.elementLocated(elem), TEST_TIMEOUT);
await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT); await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);