From aa0b00cd1e5db43aef83eb7d41987ce3eb38645a Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 31 Jan 2022 14:08:14 +0100 Subject: [PATCH] Fixup tests --- test/test.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 8643ff0..2299b9e 100755 --- a/test/test.js +++ b/test/test.js @@ -88,7 +88,7 @@ describe('Application life cycle test', function () { await browser.findElement(By.id('user_name')).sendKeys(username); await browser.findElement(By.id('password')).sendKeys(password); await browser.findElement(By.xpath('//form[@action="/user/login"]//button')).click(); - await browser.wait(until.elementLocated(By.linkText('Dashboard')), TIMEOUT); + await browser.wait(until.elementLocated(By.xpath('//img[contains(@class, "avatar")]')), TIMEOUT); } async function adminLogin() { @@ -111,7 +111,26 @@ describe('Application life cycle test', function () { await browser.get(sshPage); - await browser.findElement(By.xpath('//div[text()="Add Key"]')).click(); + 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")]')).click(); + + await browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT); + } + + async function addPublicKeyOld() { + var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8'); + + const sshPage = 'https://' + app.fqdn + '/user/settings/keys'; + + await browser.get(sshPage); + + await browser.wait(until.elementLocated(By.xpath('//div[@data-panel="#add-ssh-key-panel"]')), TIMEOUT); + await browser.findElement(By.xpath('//div[@data-panel="#add-ssh-key-panel"]')).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")]')); @@ -264,7 +283,7 @@ describe('Application life cycle test', function () { it('can login', login.bind(null, username, password)); it('can set avatar', setAvatar); it('can get avatar', checkAvatar); - it('can add public key', addPublicKey); + it('can add public key', addPublicKeyOld); it('can create repo', createRepo); it('can clone the url', cloneRepo); it('can add and push a file', pushFile);