From e5296ab5ee04fa24c953c8b2928febf3ae4abbbc Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 24 Feb 2022 19:42:35 -0800 Subject: [PATCH] Fixup tests --- test/test.js | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/test/test.js b/test/test.js index 2299b9e..55cc673 100755 --- a/test/test.js +++ b/test/test.js @@ -11,11 +11,10 @@ require('chromedriver'); -var execSync = require('child_process').execSync, +const execSync = require('child_process').execSync, expect = require('expect.js'), fs = require('fs'), path = require('path'), - rimraf = require('rimraf'), superagent = require('superagent'), { Builder, By, until } = require('selenium-webdriver'), { Options } = require('selenium-webdriver/chrome'); @@ -49,7 +48,7 @@ describe('Application life cycle test', function () { after(function () { browser.quit(); - rimraf.sync(repodir); + fs.rmSync(repodir, { recursive: true, force: true }); }); function getAppInfo() { @@ -122,24 +121,6 @@ describe('Application life cycle test', function () { 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")]')); - 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 createRepo() { var getRepoPage = await browser.get('https://' + app.fqdn + '/repo/create'); @@ -165,7 +146,7 @@ describe('Application life cycle test', function () { } function cloneRepo() { - rimraf.sync(repodir); + fs.rmSync(repodir, { recursive: true, force: true }); var env = Object.create(process.env); env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; execSync(`git clone ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git ${repodir}`, { env: env }); @@ -176,7 +157,7 @@ describe('Application life cycle test', function () { env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; execSync(`touch newfile && git add newfile && git commit -a -mx && git push ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame} master`, { env: env, cwd: repodir }); - rimraf.sync('/tmp/testrepo'); + fs.rmSync(repodir, { recursive: true, force: true }); } function fileExists() { @@ -252,18 +233,6 @@ describe('Application life cycle test', function () { execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); }); - // check if the _first_ login via email succeeds - it('can login via email', async function () { execSync(`cloudron install --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, EXEC_ARGS); }); - - it('can get app information', getAppInfo); - it('can login', login.bind(null, email, password)); - - it('uninstall app', async function () { - // ensure we don't hit NXDOMAIN in the mean time - await browser.get('about:blank'); - execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS); - }); - // No SSO it('install app (no sso)', function () { execSync(`cloudron install --no-sso --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, EXEC_ARGS); }); @@ -283,7 +252,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', addPublicKeyOld); + it('can add public key', addPublicKey); it('can create repo', createRepo); it('can clone the url', cloneRepo); it('can add and push a file', pushFile);