Girish Ramakrishnan 9 rokov pred
rodič
commit
dbb883e1c1
1 zmenil súbory, kde vykonal 51 pridanie a 1 odobranie
  1. 51 1
      test/test.js

+ 51 - 1
test/test.js

@@ -29,7 +29,7 @@ describe('Application life cycle test', function () {
     this.timeout(0);
     var firefox = require('selenium-webdriver/firefox');
     var server, browser = new firefox.Driver();
-    var LOCATION = 'wptest3';
+    var LOCATION = 'wptest';
     var app;
     var username = process.env.USERNAME;
     var password = process.env.PASSWORD;
@@ -98,6 +98,31 @@ describe('Application life cycle test', function () {
         browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "Post updated.")]')), 4000).then(function () { done(); });
     });
 
+    it('can upload media', function (done) {
+        browser.get('https://' + app.fqdn + '/wp-admin/media-new.php?browser-uploader');
+        browser.wait(until.elementLocated(by.id('async-upload')), 4000);
+        browser.findElement(by.xpath('//input[@id="async-upload" and @type="file"]')).sendKeys(path.resolve(__dirname, '../icon.png'));
+        browser.findElement(by.id('html-upload')).click();
+
+        browser.wait(function () {
+            return browser.getCurrentUrl().then(function (url) {
+                return url === 'https://' + app.fqdn + '/wp-admin/upload.php';
+            });
+        }, 4000).then(function () { done(); });
+    });
+
+    var mediaLink;
+
+    it('can see media', function (done) {
+        browser.get('https://' + app.fqdn + '/wp-admin/upload.php?item=5'); // there's got to be a better way..
+        browser.wait(until.elementLocated(by.xpath('//*[text()="Attachment Details"]')), 4000);
+        browser.findElement(by.xpath('//img[@class="details-image"]')).getAttribute('src').then(function (srcLink) {
+            console.log('media is located at ', srcLink);
+            mediaLink = srcLink;
+            done();
+        });
+    });
+
     it('can restart app', function (done) {
         execSync('cloudron restart');
         done();
@@ -108,6 +133,14 @@ describe('Application life cycle test', function () {
         browser.findElement(by.xpath('//*[text()="Hello Cloudron!"]')).then(function () { done(); });
     });
 
+    it('can see media', function (done) {
+        superagent.get(mediaLink).end(function (error, result) {
+            expect(error).to.be(null);
+            expect(result.statusCode).to.be(200);
+            done();
+        });
+    });
+
     it('backup app', function () {
         execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
     });
@@ -121,6 +154,14 @@ describe('Application life cycle test', function () {
         browser.findElement(by.xpath('//*[text()="Hello Cloudron!"]')).then(function () { done(); });
     });
 
+    it('can see media', function (done) {
+        superagent.get(mediaLink).end(function (error, result) {
+            expect(error).to.be(null);
+            expect(result.statusCode).to.be(200);
+            done();
+        });
+    });
+
     it('can login', function (done) {
         browser.get('https://' + app.fqdn + '/wp-login.php');
         browser.findElement(by.id('user_login')).sendKeys(username);
@@ -135,6 +176,7 @@ describe('Application life cycle test', function () {
         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');
+        mediaLink = mediaLink.replace(LOCATION, LOCATION + '2');
     });
 
     it('can see updated post', function (done) {
@@ -142,6 +184,14 @@ describe('Application life cycle test', function () {
         browser.findElement(by.xpath('//*[text()="Hello Cloudron!"]')).then(function () { done(); });
     });
 
+    it('can see media', function (done) {
+        superagent.get(mediaLink).end(function (error, result) {
+            expect(error).to.be(null);
+            expect(result.statusCode).to.be(200);
+            done();
+        });
+    });
+
     it('can login', function (done) {
         browser.get('https://' + app.fqdn + '/wp-login.php');
         browser.findElement(by.id('user_login')).sendKeys(username);