Prepare for ci

This commit is contained in:
Johannes Zellner
2024-11-10 20:42:07 +01:00
parent 363b3bcbfe
commit 30203a4fae
2 changed files with 21 additions and 12 deletions

View File

@@ -3,9 +3,10 @@ FROM cloudron/base:4.2.0@sha256:46da2fffb36353ef714f97ae8e962bd2c212ca091108d768
RUN mkdir -p /app/code RUN mkdir -p /app/code
WORKDIR /app/code WORKDIR /app/code
ARG VERSION=6.5 # renovate: datasource=github-releases depName=traccar/traccar versioning=semver extractVersion=^v(?<version>.+)$
ARG TRACCAR_VERSION=6.5
RUN wget https://github.com/traccar/traccar/releases/download/v${VERSION}/traccar-linux-64-${VERSION}.zip -O traccar.zip && \ RUN wget https://github.com/traccar/traccar/releases/download/v${TRACCAR_VERSION}/traccar-linux-64-${TRACCAR_VERSION}.zip -O traccar.zip && \
unzip traccar.zip && \ unzip traccar.zip && \
./traccar.run --target /app/code/ --noexec && \ ./traccar.run --target /app/code/ --noexec && \
rm README.txt traccar.zip traccar.run rm README.txt traccar.zip traccar.run

View File

@@ -1,10 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
/* jshint esversion: 8 */ /* global it, xit, describe, before, after, afterEach */
/* global describe */
/* global before */
/* global after */
/* global it */
'use strict'; 'use strict';
@@ -12,6 +8,7 @@ require('chromedriver');
const execSync = require('child_process').execSync, const execSync = require('child_process').execSync,
expect = require('expect.js'), expect = require('expect.js'),
fs = require('fs'),
path = require('path'), path = require('path'),
{ Builder, By, Key, until } = require('selenium-webdriver'), { Builder, By, Key, until } = require('selenium-webdriver'),
{ Options } = require('selenium-webdriver/chrome'); { Options } = require('selenium-webdriver/chrome');
@@ -24,7 +21,7 @@ if (!process.env.USERNAME || !process.env.EMAIL || !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 = 20000; const TEST_TIMEOUT = 20000;
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
const DEVICE_NAME = 'FancyDevice'; const DEVICE_NAME = 'FancyDevice';
@@ -39,16 +36,27 @@ describe('Application life cycle test', function () {
let athenticated_by_oidc = false; let athenticated_by_oidc = false;
before(function () { before(function () {
const options = new Options().windowSize({ width: 1280, height: 1024 }); const chromeOptions = new Options().windowSize({ width: 1280, height: 1024 });
if (process.env.HEADLESS) options.addArguments('headless'); if (process.env.CI) chromeOptions.addArguments('no-sandbox', 'disable-dev-shm-usage', 'headless');
browser = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build();
browser = new Builder().forBrowser('chrome').setChromeOptions(options).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);