mirror of
https://git.cloudron.io/cloudron/gitea-app.git
synced 2024-11-21 15:41:01 +00:00
add ci files
This commit is contained in:
parent
9c4088e812
commit
9b773524ce
2 changed files with 24 additions and 28 deletions
5
.gitlab-ci.yml
Normal file
5
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
include:
|
||||
- project: devops/pipeline-components
|
||||
ref: main
|
||||
file: cloudron-app.gitlab-ci.yml
|
||||
|
47
test/test.js
47
test/test.js
|
@ -1,11 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/* jshint esversion: 8 */
|
||||
/* global it:false */
|
||||
/* global xit:false */
|
||||
/* global describe:false */
|
||||
/* global before:false */
|
||||
/* global after:false */
|
||||
/* global it, xit, describe, before, after, afterEach */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -29,21 +25,23 @@ describe('Application life cycle test', function () {
|
|||
|
||||
const TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
|
||||
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
|
||||
const LOCATION = 'test';
|
||||
const LOCATION = process.env.LOCATION || 'test';
|
||||
const SSH_PORT = 29420;
|
||||
|
||||
let app, browser;
|
||||
var athenticated_by_oidc = false;
|
||||
let athenticated_by_oidc = false;
|
||||
|
||||
const repodir = '/tmp/testrepo';
|
||||
const reponame = 'testrepo';
|
||||
|
||||
const username = process.env.USERNAME;
|
||||
const password = process.env.PASSWORD;
|
||||
const email = process.env.EMAIL;
|
||||
|
||||
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 () {
|
||||
|
@ -51,8 +49,19 @@ describe('Application life cycle test', function () {
|
|||
fs.rmSync(repodir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
function getAppInfo() {
|
||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
const inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0];
|
||||
expect(app).to.be.an('object');
|
||||
}
|
||||
|
@ -147,25 +156,7 @@ describe('Application life cycle test', function () {
|
|||
await browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
|
||||
}
|
||||
|
||||
async function addPublicKeyOld() {
|
||||
var publicKey = fs.readFileSync(__dirname + '/id_ed25519.pub', 'utf8');
|
||||
|
||||
await browser.get('https://' + app.fqdn + '/user/settings/keys');
|
||||
|
||||
await browser.wait(until.elementLocated(By.id('add-ssh-button')), TIMEOUT);
|
||||
await browser.findElement(By.id('add-ssh-button')).click();
|
||||
await browser.findElement(By.id('ssh-key-title')).sendKeys('testkey');
|
||||
await browser.findElement(By.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
|
||||
var button = browser.findElement(By.xpath('//button[contains(text(), "Add Key")]'));
|
||||
await browser.executeScript('arguments[0].scrollIntoView(false)', button);
|
||||
await browser.findElement(By.xpath('//button[contains(text(), "Add Key") and contains(@class, "green")]')).click();
|
||||
|
||||
await browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
|
||||
}
|
||||
|
||||
async function createRepo() {
|
||||
var getRepoPage = await browser.get('https://' + app.fqdn + '/repo/create');
|
||||
|
||||
await browser.findElement(By.id('repo_name')).sendKeys(reponame);
|
||||
var button = browser.findElement(By.xpath('//button[contains(text(), "Create Repository")]'));
|
||||
await browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
||||
|
|
Loading…
Reference in a new issue