From 9805180643f5b7f3bcafc730aa91aa8b4746a514 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 13 Nov 2023 15:54:18 +0100 Subject: [PATCH] Fixup test for real login form --- test/test.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/test/test.js b/test/test.js index 4d1f95c..bd960b9 100644 --- a/test/test.js +++ b/test/test.js @@ -50,17 +50,17 @@ describe('Application life cycle test', function () { await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT); } - async function invalidPassword() { - const result = await superagent.get('https://' + app.fqdn).auth(username, password + 'x').ok(() => true); - expect(result.statusCode).to.eql(401); + async function login() { + await browser.manage().deleteAllCookies(); + await browser.get('https://' + app.fqdn); + await waitForElement(By.id('user')); + await browser.findElement(By.id('user')).sendKeys(username); + await browser.findElement(By.id('password')).sendKeys(password); + await browser.findElement(By.xpath('//button[@type="submit"]')).click(); + await waitForElement(By.xpath('//span[text()="Actions"]')); } 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"]')); } @@ -86,36 +86,36 @@ describe('Application life cycle test', function () { xit('build app', function () { execSync('cloudron build', EXEC_ARGS); }); - it('install app', async function () { - execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); - await timers.setTimeout(30000); - }); + it('install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); }); + // await timers.setTimeout(30000); it('can get app information', getAppInfo); - it('fails with invalid password', invalidPassword); + it('can login', login); it('can load page', loadPage); it('can add folder', addFolder); it('backup app', async function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); - await timers.setTimeout(30000); + // await timers.setTimeout(30000); }); it('restore app', async function () { await browser.get('about:blank'); execSync('cloudron restore --app ' + app.id, EXEC_ARGS); - await timers.setTimeout(30000); + await timers.setTimeout(5000); }); + it('can login', login); it('can load page', loadPage); it('can check folder', checkFolder); it('move to different location', async function () { await browser.get('about:blank'); execSync(`cloudron configure --location ${LOCATION}2 --app ${app.id}`, EXEC_ARGS); - await timers.setTimeout(30000); + await timers.setTimeout(5000); }); it('can get app information', getAppInfo); + it('can login', login); it('can load page', loadPage); it('can check folder', checkFolder); @@ -130,6 +130,7 @@ describe('Application life cycle test', function () { await timers.setTimeout(30000); }); it('can get app information', getAppInfo); + it('can login', login); it('can load page', loadPage); it('can add folder', addFolder); it('can update', async function () {