1
0
mirror of https://git.cloudron.io/cloudron/minio-app synced 2025-09-02 15:25:07 +00:00

Updated tests to the new UI and redo the old tests with async AND disable LDAP support for now

This commit is contained in:
Elias Hackradt
2021-07-16 15:33:27 +02:00
parent f814368e12
commit e38d1020ac
5 changed files with 106 additions and 111 deletions

View File

@@ -1,9 +1,11 @@
#!/usr/bin/env node
/* jshint esversion: 8 */
/* global describe */
/* global before */
/* global after */
/* global it */
/* global xit */
'use strict';
@@ -15,7 +17,6 @@ var execSync = require('child_process').execSync,
{ Builder, By, Key, until } = require('selenium-webdriver'),
{ Options } = require('selenium-webdriver/chrome');
describe('Application life cycle test', function () {
this.timeout(0);
@@ -23,130 +24,121 @@ describe('Application life cycle test', function () {
const TEST_TIMEOUT = 10000;
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
const BUCKET = 'cloudrontestbucket';
const username = process.env.USERNAME;
const password = process.env.PASSWORD;
var app;
var browser;
let browser, app;
before(function (done) {
if (!process.env.PASSWORD) return done(new Error('PASSWORD env var not set'));
if (!process.env.USERNAME) return done(new Error('USERNAME env var not set'));
before(function () {
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build();
done();
});
after(function () {
browser.quit();
});
function sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis));
}
async function waitForElement(elem) {
await browser.wait(until.elementLocated(elem), TEST_TIMEOUT);
await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
}
function getAppInfo() {
var 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');
}
function pageLoaded() {
return browser.wait(until.elementLocated(By.className('page-load pl-0 pl-1')), TEST_TIMEOUT);
async function login(accessKey='minioadmin', secretKey='minioadmin') {
await browser.get(`https://${app.fqdn}/login`);
await waitForElement(By.id('accessKey'));
await browser.findElement(By.id('accessKey')).sendKeys(accessKey);
await browser.findElement(By.id('secretKey')).sendKeys(secretKey);
await browser.findElement(By.xpath('//button[@type="submit"]/span[text()="Login"]')).click();
await waitForElement(By.xpath(`//div/span[contains(text(), "Dashboard")]`));
}
function visible(selector) {
return browser.wait(until.elementLocated(selector), TEST_TIMEOUT).then(function () {
return browser.wait(until.elementIsVisible(browser.findElement(selector)), TEST_TIMEOUT);
});
async function old_login(accessKey='minioadmin', secretKey='minioadmin') {
await browser.get(`https://${app.fqdn}/minio/login`);
await waitForElement(By.id('accessKey'));
await browser.findElement(By.id('accessKey')).sendKeys(accessKey);
await browser.findElement(By.id('secretKey')).sendKeys(secretKey);
await browser.findElement(By.xpath('//button[@type="submit"]')).click();
await waitForElement(By.xpath(`//input[@placeholder="Search Buckets..."]`));
}
function login(accessKey, secretKey, callback) {
browser.manage().deleteAllCookies();
browser.get('https://' + app.fqdn).then(function () {
return visible(By.id('accessKey'));
}).then(function () {
return browser.findElement(By.id('accessKey')).sendKeys(accessKey);
}).then(function () {
return browser.findElement(By.id('secretKey')).sendKeys(secretKey);
}).then(function () {
// return browser.findElement(By.className('lw-btn')).click();
return browser.findElement(By.tagName('form')).submit();
}).then(function () {
return browser.wait(until.elementLocated(By.id('top-right-menu')), TEST_TIMEOUT);
}).then(function () {
callback();
});
async function logout() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//div/span[contains(text(), "Dashboard")]`));
await browser.findElement(By.xpath('//div/span[contains(text(), "Logout")]')).click();
await waitForElement(By.id('accessKey'));
}
function logout(callback) {
browser.get('https://' + app.fqdn);
pageLoaded().then(function () {
return visible(By.id('top-right-menu'));
}).then(function () {
return browser.findElement(By.id('top-right-menu')).click();
}).then(function () {
if (app.manifest.version === '1.137.0') {
return visible(By.xpath('//*[text()="Sign Out "]'));
} else {
return visible(By.xpath('//*[contains(text(), "Logout")]'));
}
}).then(function () {
if (app.manifest.version === '1.137.0') {
return browser.findElement(By.xpath('//*[text()="Sign Out "]')).click();
} else {
return browser.findElement(By.xpath('//*[contains(text(),"Logout")]')).click();
}
}).then(function () {
return browser.wait(until.elementLocated(By.id('accessKey')), TEST_TIMEOUT);
}).then(function () {
callback();
});
async function old_logout() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//input[@placeholder="Search Buckets..."]`));
await browser.findElement(By.xpath('//div/button[@id="top-right-menu"]')).click();
await browser.findElement(By.xpath('//ul/li/a[@id="logout"]')).click();
await waitForElement(By.id('accessKey'));
}
function addBucket(callback) {
browser.get('https://' + app.fqdn);
pageLoaded().then(function () {
return visible(By.className('fa-plus'));
}).then(function () {
return browser.findElement(By.className('fa-plus')).click();
}).then(function () {
const c = 'fa-hdd';
return visible(By.className(c));
}).then(function () {
const c = 'fa-hdd';
return browser.findElement(By.className(c)).click();
}).then(function () {
return visible(By.xpath('//*[@class="modal-body"]/form/div/input'));
}).then(function () {
return browser.findElement(By.xpath('//*[@class="modal-body"]/form/div/input')).sendKeys(BUCKET);
}).then(function () {
return browser.findElement(By.xpath('//*[@class="modal-body"]/form')).submit();
}).then(function () {
return visible(By.xpath('//*[@class="main"]/a[text()="' + BUCKET + '"]'));
}).then(function () {
callback();
});
async function addBucket() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath('//div/span[contains(text(), "Bucket")]'));
await browser.findElement(By.xpath('//div/span[contains(text(), "Bucket")]')).click();
await waitForElement(By.xpath('//span[text()="Create Bucket"]'));
await browser.findElement(By.xpath('//span[text()="Create Bucket"]')).click();
await browser.findElement(By.xpath('//input[@id="bucket-name"]')).sendKeys(BUCKET);
await browser.findElement(By.xpath('//button[@type="submit"]/span[text()="Save"]')).click();
await waitForElement(By.xpath(`//div/span[contains(text(), "${BUCKET}")]`));
await browser.findElement(By.xpath(`//div/span[contains(text(), "${BUCKET}")]`));
}
function checkBucket(callback) {
browser.get('https://' + app.fqdn);
pageLoaded().then(function () {
return browser.findElement(By.xpath(`//a[contains(text(), ${BUCKET})]`));
}).then(function () {
callback();
});
async function old_addBucket() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//input[@placeholder="Search Buckets..."]`));
await browser.findElement(By.xpath('//div/button[@id="fe-action-toggle"]')).click();
await browser.findElement(By.xpath('//ul/a[@id="show-make-bucket"]')).click();
await browser.findElement(By.xpath('//input[@placeholder="Bucket Name"]')).sendKeys(BUCKET);
await browser.findElement(By.xpath('//*[@class="modal-body"]/form')).submit();
await waitForElement(By.xpath(`//*[@class="main"]/a[text()="${BUCKET}"]`));
}
function openSettings(callback) {
browser.get('https://' + app.fqdn);
async function checkBucket() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//div/span[contains(text(), "Dashboard")]`));
await browser.findElement(By.xpath('//div/span[contains(text(), "Bucket")]')).click();
await waitForElement(By.xpath(`//div/span[contains(text(), "${BUCKET}")]`));
await browser.findElement(By.xpath(`//div/span[contains(text(), "${BUCKET}")]`));
}
pageLoaded().then(function () {
return visible(By.id('top-right-menu'));
}).then(function () {
return browser.findElement(By.id('top-right-menu')).click();
}).then(function () {
return visible(By.xpath('//*[contains(text(), "Change Password")]'));
}).then(function () {
return browser.findElement(By.xpath('//*[contains(text(),"Change Password")]')).click();
}).then(function () {
return browser.wait(until.elementLocated(By.xpath('//*[contains(text(), "Change Password")]')), TEST_TIMEOUT);
}).then(function () {
callback();
});
async function old_checkBucket() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//input[@placeholder="Search Buckets..."]`));
await waitForElement(By.xpath(`//*[@class="main"]/a[text()="${BUCKET}"]`));
}
async function openSettings() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//div/span[contains(text(), "Dashboard")]`));
await browser.findElement(By.xpath('//div/span[contains(text(), "Account")]')).click();
await waitForElement(By.xpath(`//button/span[text()="Change Password"]`));
await browser.findElement(By.xpath('//button/span[text()="Change Password"]'));
}
async function old_openSettings() {
await browser.get(`https://${app.fqdn}/`);
await waitForElement(By.xpath(`//input[@placeholder="Search Buckets..."]`));
await browser.findElement(By.xpath('//div/button[@id="top-right-menu"]')).click();
await waitForElement(By.xpath('//ul/li/a[contains(text(), "Change Password")]'));
await browser.findElement(By.xpath('//ul/li/a[contains(text(), "Change Password")]'));
}
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });
@@ -199,10 +191,11 @@ describe('Application life cycle test', function () {
it('can install app', function () { execSync('cloudron install --appstore-id io.minio.cloudronapp --location ' + LOCATION, EXEC_ARGS); });
it('can get app information', getAppInfo);
it('can login', login.bind(null, 'minioadmin', 'minioadmin'));
it('can add buckets', addBucket);
it('can logout', logout);
it('can update', function () { execSync('cloudron update --app ' + LOCATION, EXEC_ARGS); });
it('can login', old_login.bind(null, 'minioadmin', 'minioadmin'));
it('can add buckets', old_addBucket);
it('can logout', old_logout);
it('can update', function () { execSync(`cloudron update --app ${LOCATION} --no-wait`, EXEC_ARGS); });
it('can enable API Port', function () { execSync(`cloudron configure --app ${LOCATION} -p API_PORT=9000 -l ${LOCATION} `, EXEC_ARGS); });
it('can get app information', getAppInfo);
it('can login', login.bind(null, 'minioadmin', 'minioadmin'));