master
Girish Ramakrishnan 2023-10-11 11:00:23 +05:30
parent 67383ed187
commit ae4e726aa9
1 changed files with 42 additions and 79 deletions

View File

@ -5,6 +5,7 @@
/* global before */
/* global after */
/* global it */
/* global xit */
'use strict';
@ -15,7 +16,7 @@ const execSync = require('child_process').execSync,
superagent = require('superagent'),
path = require('path'),
timers = require('timers/promises'),
{ Builder, By, Key, until } = require('selenium-webdriver'),
{ Builder, By, until } = require('selenium-webdriver'),
{ Options } = require('selenium-webdriver/chrome');
describe('Application life cycle test', function () {
@ -44,94 +45,56 @@ describe('Application life cycle test', function () {
expect(app).to.be.an('object');
}
function waitForElement(elem) {
return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () {
return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
});
async function waitForElement(elem) {
await browser.wait(until.elementLocated(elem), TEST_TIMEOUT);
await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
}
function invalidPassword(callback) {
superagent.get('https://' + app.fqdn).auth(username, password + 'x').end(function (error, result) {
expect(result.status).to.eql(401);
callback();
});
async function invalidPassword() {
const result = await superagent.get('https://' + app.fqdn).auth(username, password + 'x').ok(() => true);
expect(result.statusCode).to.eql(401);
}
function loadPage(callback) {
browser.manage().deleteAllCookies().then(function () {
return browser.sleep(5000);
}).then(function() {
return browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () {
return browser.get('https://' + app.fqdn);
});
}).then(function () {
return browser.sleep(5000);
}).then(function () {
return browser.get('https://' + app.fqdn);
}).then(function () {
return waitForElement(By.xpath('//span[text()="Actions"]'));
}).then(function () {
callback();
});
async function loadPage() {
await browser.manage().deleteAllCookies();
await browser.sleep(5000);
await browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn);
await browser.get('https://' + app.fqdn);
await browser.sleep(5000);
await browser.get('https://' + app.fqdn);
await waitForElement(By.xpath('//span[text()="Actions"]'));
}
function addFolder(callback) {
browser.get('https://' + app.fqdn).then(function () {
return browser.findElement(By.css('[ng-click*=addFolder]')).click();
}).then(function () {
return waitForElement(By.id('folderPath'));
}).then(function () {
return browser.sleep(4000); // wait more, not sure why this is needed
}).then(function() {
return browser.findElement(By.id('folderLabel')).sendKeys(FOLDER);
}).then(function () {
return browser.sleep(4000); // without this sometimes only part of the folder name gets through
}).then(function() {
return browser.findElement(By.css('[ng-click*=saveFolder]')).click();
}).then(function() {
return browser.wait(until.elementLocated(By.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT);
}).then(function () {
return browser.sleep(4000);
}).then(function() {
callback();
});
async function addFolder() {
await browser.get('https://' + app.fqdn);
await browser.findElement(By.css('[ng-click*=addFolder]')).click();
await waitForElement(By.id('folderPath'));
await browser.sleep(4000); // wait more, not sure why this is needed
await browser.findElement(By.id('folderLabel')).sendKeys(FOLDER);
await browser.sleep(4000); // without this sometimes only part of the folder name gets through
await browser.findElement(By.css('[ng-click*=saveFolder]')).click();
await browser.wait(until.elementLocated(By.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT);
await browser.sleep(4000);
}
function checkFolder(callback) {
browser.get('https://' + app.fqdn).then(function () {
return browser.sleep(5000);
}).then(function () {
return browser.get('https://' + app.fqdn);
}).then(function () {
return browser.wait(until.elementLocated(By.xpath(`//span[text()="${FOLDER}"]`)), TEST_TIMEOUT);
}).then(function () {
callback();
});
async function checkFolder() {
await browser.get('https://' + app.fqdn);
await browser.sleep(5000);
await browser.get('https://' + app.fqdn);
await browser.wait(until.elementLocated(By.xpath(`//span[text()="${FOLDER}"]`)), TEST_TIMEOUT);
}
function removeFolder(callback) {
browser.get('https://' + app.fqdn).then(function () {
return waitForElement(By.xpath('//span[text()="Actions"]'));
}).then(function() {
return browser.findElement(By.css('#folders button')).click();
}).then(function () {
return browser.sleep(3000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(By.css('#folder-0 button[ng-click*=editFolder]')).click();
}).then(function () {
return browser.sleep(3000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(By.xpath('//button[@data-target="#remove-folder-confirmation"]')).click();
}).then(function () {
return browser.sleep(3000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(By.css('[ng-click*=deleteFolder]')).click();
}).then(function () {
return browser.sleep(3000); //This needs to run for some time
}).then(function () {
callback();
});
async function removeFolder() {
await browser.get('https://' + app.fqdn);
await waitForElement(By.xpath('//span[text()="Actions"]'));
await browser.findElement(By.css('#folders button')).click();
await browser.sleep(3000); //No way to check for visibility of angular-js components
await browser.findElement(By.css('#folder-0 button[ng-click*=editFolder]')).click();
await browser.sleep(3000); //No way to check for visibility of angular-js components
await browser.findElement(By.xpath('//button[@data-target="#remove-folder-confirmation"]')).click();
await browser.sleep(3000); //No way to check for visibility of angular-js components
await browser.findElement(By.css('[ng-click*=deleteFolder]')).click();
await browser.sleep(3000); //This needs to run for some time
}
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });