From 2a87a826c48ad7f44d5dea97f23b62bc7dee6fac Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 22 Sep 2023 08:13:33 +0530 Subject: [PATCH] Fix test --- test/test.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/test/test.js b/test/test.js index d8b2106..93bb5d4 100755 --- a/test/test.js +++ b/test/test.js @@ -52,7 +52,7 @@ describe('Application life cycle test', function () { } async function checkRegistration(mode) { - if (mode === 'none') { + if (mode === 'none') { await browser.get('https://' + app.fqdn); await browser.sleep(2000); await browser.findElement(By.xpath('//div[@class="sign-in-banner"]/descendant::button/span[contains(text(), "Create account")]')).click(); @@ -65,7 +65,7 @@ describe('Application life cycle test', function () { async function login(username, password) { await browser.get('https://' + app.fqdn + '/auth/sign_in'); // there is also separate login page at /users/sign_in - await browser.wait(until.elementLocated(By.xpath('//button[contains(text(), "Log in")]')), TEST_TIMEOUT); + await visible(By.xpath('//button[contains(text(), "Log in")]')); await browser.findElement(By.id('user_email')).sendKeys(username); await browser.findElement(By.id('user_password')).sendKeys(password); await browser.findElement(By.xpath('//button[contains(text(), "Log in")]')).click(); @@ -76,26 +76,22 @@ describe('Application life cycle test', function () { await browser.get('https://' + app.fqdn + '/settings/preferences/appearance'); // there is also separate login page at /users/sign_in await browser.wait(until.elementLocated(By.id('logout')), TEST_TIMEOUT); await browser.findElement(By.id('logout')).click(); - await browser.wait(until.elementLocated(By.id('user_email')), TEST_TIMEOUT); + await visible(By.id('user_email')); } - async function skipTutorial() { - await browser.get('https://' + app.fqdn + '/web/start'); - await browser.wait(until.elementLocated(By.xpath('//button/span[text() = "Done"]')), TEST_TIMEOUT); - await browser.findElement(By.xpath('//button/span[text() = "Done"]')).click(); - await browser.sleep(5000); // can be wizard or timeline at this point - await browser.wait(until.elementLocated(By.xpath('//span[text() = "See some suggestions"]')), TEST_TIMEOUT); - await browser.sleep(5000); + async function dismissHelp() { + await browser.get('https://' + app.fqdn + '/home'); + await visible(By.xpath('//button[@title = "Dismiss"]')); + await browser.findElement(By.xpath('//button[@title ="Dismiss"]')).click(); } async function checkTimeline() { await browser.get('https://' + app.fqdn + '/home'); - await browser.sleep(2000); - await browser.wait(until.elementLocated(By.xpath('//span[text() = "See some suggestions"]')), TEST_TIMEOUT); + await visible(By.xpath('//span[contains(text(), "Your home timeline is empty")]')); } 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 === LOCATION || a.location === LOCATION + '2'; })[0]; expect(app).to.be.an('object'); } @@ -106,7 +102,7 @@ describe('Application life cycle test', function () { it('can get app information', getAppInfo); it('registration is disabled', checkRegistration.bind(null, 'none')); it('can LDAP login', login.bind(null, username, password)); - it('can skip tutorial', skipTutorial); + it('can dismiss help', dismissHelp); it('can see timeline', checkTimeline); it('can logout', logout);