X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=test%2Ftest.js;h=be812c29cebc2b53adce2155e25968d7ec042625;hb=HEAD;hp=dd2d06fa426c36a8fe4a9f6511b9aa83e95c0eeb;hpb=18b1ace178b9626b5dd411b5ee694669a87aef96;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git diff --git a/test/test.js b/test/test.js index dd2d06f..be812c2 100644 --- a/test/test.js +++ b/test/test.js @@ -23,7 +23,7 @@ if (!process.env.USERNAME || !process.env.PASSWORD) { describe('Application life cycle test', function () { this.timeout(0); - const EXEC_OPTIONS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; + const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; const LOCATION = 'test'; const TEST_TIMEOUT = 10000; const TEST_FILE_NAME_0 = 'index.html'; @@ -40,6 +40,19 @@ describe('Application life cycle test', function () { browser.quit(); }); + function getAppInfo(location, done) { + if (!done) { + done = location; + location = LOCATION; + } + + var inspect = JSON.parse(execSync('cloudron inspect')); + app = inspect.apps.filter(function (a) { return a.location === location; })[0]; + expect(app).to.be.an('object'); + + done(); + } + function waitForElement(elem) { return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () { return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT); @@ -126,15 +139,10 @@ describe('Application life cycle test', function () { done(); } - xit('build app', function () { execSync('cloudron build', EXEC_OPTIONS); }); + xit('build app', function () { execSync('cloudron build', EXEC_ARGS); }); - it('install app', function () { execSync(`cloudron install --location ${LOCATION}`, EXEC_OPTIONS); }); - - it('can get app information', function () { - var inspect = JSON.parse(execSync('cloudron inspect')); - app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; - expect(app).to.be.an('object'); - }); + it('install app', function () { execSync(`cloudron install --location ${LOCATION}`, EXEC_ARGS); }); + it('can get app information', getAppInfo); it('can login', login); it('can cli login', cliLogin); @@ -150,8 +158,8 @@ describe('Application life cycle test', function () { it('second file is gone', checkFileIsGone.bind(null, TEST_FILE_NAME_1)); it('can logout', logout); - it('backup app', function () { execSync(`cloudron backup create --app ${app.id}`, EXEC_OPTIONS); }); - it('restore app', function () { execSync(`cloudron restore --app ${app.id}`, EXEC_OPTIONS); }); + it('backup app', function () { execSync(`cloudron backup create --app ${app.id}`, EXEC_ARGS); }); + it('restore app', function () { execSync(`cloudron restore --app ${app.id}`, EXEC_ARGS); }); it('can login', login); it('file is listed', checkFileIsListed.bind(null, TEST_FILE_NAME_0)); @@ -165,16 +173,43 @@ describe('Application life cycle test', function () { // ensure we don't hit NXDOMAIN in the mean time browser.get('about:blank').then(function () { - execSync(`cloudron configure --location ${LOCATION}2 --app ${app.id}`, EXEC_OPTIONS); + execSync(`cloudron configure --location ${LOCATION}2 --app ${app.id}`, EXEC_ARGS); + getAppInfo(`${LOCATION}2`, done); + }); + }); - var inspect = JSON.parse(execSync('cloudron inspect')); - app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; - expect(app).to.be.an('object'); + it('can login', login); + it('file is listed', checkFileIsListed.bind(null, TEST_FILE_NAME_0)); + it('file is served up', checkFileIsPresent); + it('file is served up', checkIndexFileIsServedUp); + it('can logout', logout); + it('uninstall app', function (done) { + // ensure we don't hit NXDOMAIN in the mean time + browser.get('about:blank').then(function () { + execSync(`cloudron uninstall --app ${app.id}`, EXEC_ARGS); done(); }); }); + // test update + it('can install app', function () { + execSync(`cloudron install --appstore-id io.cloudron.surfer --location ${LOCATION}`, EXEC_ARGS); + }); + + it('can get app information', getAppInfo); + it('can login', login); + it('can cli login', cliLogin); + it('can upload file', uploadFile.bind(null, TEST_FILE_NAME_0)); + it('file is listed', checkFileIsListed.bind(null, TEST_FILE_NAME_0)); + it('file is served up', checkFileIsPresent); + it('file is served up', checkIndexFileIsServedUp); + it('can logout', logout); + + it('can update', function () { + execSync(`cloudron update --app ${LOCATION}`, EXEC_ARGS); + }); + it('can login', login); it('file is listed', checkFileIsListed.bind(null, TEST_FILE_NAME_0)); it('file is served up', checkFileIsPresent); @@ -184,7 +219,7 @@ describe('Application life cycle test', function () { it('uninstall app', function (done) { // ensure we don't hit NXDOMAIN in the mean time browser.get('about:blank').then(function () { - execSync(`cloudron uninstall --app ${app.id}`, EXEC_OPTIONS); + execSync(`cloudron uninstall --app ${app.id}`, EXEC_ARGS); done(); }); });