Browse Source

Fix tests

Girish Ramakrishnan 6 years ago
parent
commit
741b54458a
1 changed files with 27 additions and 3 deletions
  1. 27 3
      test/test.js

+ 27 - 3
test/test.js

@@ -100,13 +100,17 @@ describe('Application life cycle test', function () {
 
     function checkPost(done) {
         browser.get('https://' + app.fqdn).then(function () {
-            return browser.wait(until.elementLocated(by.xpath('//h3/a[text()="Hello Cloudron!"]')), TIMEOUT);
+            if (app.manifest.version === '1.7.0') {
+                return browser.wait(until.elementLocated(by.xpath('//h3/a[text()="Hello Cloudron!"]')), TIMEOUT);
+            } else {
+                return browser.wait(until.elementLocated(by.xpath('//h2/a[text()="Hello Cloudron!"]')), TIMEOUT);
+            }
         }).then(function () {
             done();
         });
     }
 
-    function editPost(done) {
+    function editPostWordpress4(done) {
         browser.get('https://' + app.fqdn + '/wp-admin/post.php?post=1&action=edit').then(function () {
             return browser.wait(until.elementLocated(by.xpath('//input[@id="title"]')), TIMEOUT);
         }).then(function () {
@@ -122,6 +126,26 @@ describe('Application life cycle test', function () {
         });
     }
 
+    function editPost(done) {
+        browser.get('https://' + app.fqdn + '/wp-admin/post.php?post=1&action=edit').then(function () {
+            return browser.wait(until.elementLocated(by.xpath('//button[@aria-label="Disable tips"]')), TIMEOUT);
+        }).then(function () {
+            return browser.findElement(by.xpath('//button[@aria-label="Disable tips"]')).click();
+        }).then(function () {
+            return browser.findElement(by.xpath('//textarea[@id="post-title-0"]')).sendKeys(Key.chord(Key.CONTROL, 'a'));
+        }).then(function () {
+            return browser.findElement(by.xpath('//textarea[@id="post-title-0"]')).sendKeys('Hello Cloudron!');
+        }).then(function () {
+            return browser.findElement(by.xpath('//button[text()="Update"]')).click();
+        }).then(function () {
+            return browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "Post updated.")]')), TIMEOUT);
+        }).then(function () {
+            return browser.sleep(3000);
+        }).then(function () {
+            done();
+        });
+    }
+
     function uploadMedia(done) {
         browser.get('https://' + app.fqdn + '/wp-admin/media-new.php?browser-uploader').then(function () {
             return browser.wait(until.elementLocated(by.id('async-upload')), TIMEOUT);
@@ -331,7 +355,7 @@ describe('Application life cycle test', function () {
         expect(app).to.be.an('object');
     });
     it('can login', login.bind(null, username, password));
-    it('can edit', editPost);
+    it('can edit', editPostWordpress4);
     it('can upload media', uploadMedia);
 
     it('can update', function () {