couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject fauxton commit: updated refs/heads/master to 2dc4188
Date Wed, 30 Nov 2016 09:27:14 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master e53deb5d9 -> 2dc418893


add more tests to replication activity


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/2dc41889
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/2dc41889
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/2dc41889

Branch: refs/heads/master
Commit: 2dc4188936d4a0a2be5fcbfdf220248510726e80
Parents: e53deb5
Author: Garren Smith <garren.smith@gmail.com>
Authored: Mon Nov 28 11:15:10 2016 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Wed Nov 30 11:26:50 2016 +0200

----------------------------------------------------------------------
 .../replication/tests/nightwatch/replication.js |  8 +--
 .../tests/nightwatch/replicationactivity.js     | 75 ++++++++++++++++----
 .../custom-commands/checkForDocumentDeleted.js  | 49 +++++++++++++
 test/nightwatch_tests/custom-commands/helper.js | 17 +++++
 4 files changed, 130 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2dc41889/app/addons/replication/tests/nightwatch/replication.js
----------------------------------------------------------------------
diff --git a/app/addons/replication/tests/nightwatch/replication.js b/app/addons/replication/tests/nightwatch/replication.js
index 1f879af..9c21361 100644
--- a/app/addons/replication/tests/nightwatch/replication.js
+++ b/app/addons/replication/tests/nightwatch/replication.js
@@ -39,6 +39,7 @@ module.exports = {
     const waitTime = client.globals.maxWaitTime;
     const baseUrl = client.globals.test_settings.launch_url;
     const password = client.globals.test_settings.password;
+    console.log('PASSWORD', password);
 
     client
       .createDatabase(newDatabaseName1)
@@ -65,14 +66,10 @@ module.exports = {
       .click('#replicate')
 
       .waitForElementPresent('.enter-password-modal', waitTime, true)
-      .setValue('.enter-password-modal input[type="password"]', password)
+      .setValue('.enter-password-modal .password-modal-input', password)
       .click('.enter-password-modal button.save')
       .waitForElementNotPresent('.enter-password-modal', waitTime, true)
       .waitForElementNotPresent('.global-notification .fonticon-cancel', waitTime, false)
-
-      // now check the database was created
-      //.checkForDatabaseCreated(replicatedDBName, waitTime)
-
       .end();
   },
 
@@ -133,7 +130,6 @@ module.exports = {
     };
 
     client
-
       // create two databases, each with a single (different) doc
       .createDatabase(newDatabaseName1)
       .checkForDatabaseCreated(newDatabaseName1, waitTime)

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2dc41889/app/addons/replication/tests/nightwatch/replicationactivity.js
----------------------------------------------------------------------
diff --git a/app/addons/replication/tests/nightwatch/replicationactivity.js b/app/addons/replication/tests/nightwatch/replicationactivity.js
index b8dc7c3..2bb9b59 100644
--- a/app/addons/replication/tests/nightwatch/replicationactivity.js
+++ b/app/addons/replication/tests/nightwatch/replicationactivity.js
@@ -13,13 +13,13 @@
 
 module.exports = {
 
-  'Can delete document': (client) => {
+  'Can view doc': client => {
     const waitTime = client.globals.maxWaitTime;
     const baseUrl = client.globals.test_settings.launch_url;
     const password = client.globals.test_settings.password;
 
     const replicatorDoc = {
-      _id: 'existing-doc-id-2',
+      _id: 'existing-doc-id-view-doc',
       source: "http://source-db.com",
       target: "http://target-db.com"
     };
@@ -29,21 +29,70 @@ module.exports = {
       .createDocument(replicatorDoc._id, '_replicator', replicatorDoc)
       .loginToGUI()
       .waitForElementNotPresent('.global-notification .fonticon-cancel', waitTime, false)
-      .url(baseUrl + '/#/replication')
+      .url(baseUrl + '/#replication')
       .waitForElementNotPresent('.load-lines', waitTime, true)
       .waitForElementPresent('.replication__filter', waitTime, true)
-      .click('a[title="Delete document existing-doc-id-2"]')
-      .waitForElementPresent('.replication_delete-doc-modal', waitTime, true)
-      .click('.replication_delete-doc-modal button.save')
-      .waitForElementNotPresent('.replication_delete-doc-modal', waitTime, true)
-      .waitForElementPresent('.global-notification .fonticon-cancel', waitTime, false)
+      .clickWhenVisible('a[href="#/database/_replicator/existing-doc-id-view-doc"]')
+      .waitForElementNotPresent('.load-lines', waitTime, true)
+      .waitForElementPresent('#editor-container', waitTime, true)
+      .end();
+  },
+
+  'Can edit doc': client => {
+    const waitTime = client.globals.maxWaitTime;
+    const baseUrl = client.globals.test_settings.launch_url;
+    const password = client.globals.test_settings.password;
+
+    const replicatorDoc = {
+      _id: 'existing-doc-id-edit-doc',
+      source: "http://source-db.com",
+      target: "http://target-db.com"
+    };
+    client
+      .deleteDatabase('_replicator')
+      .createDatabase('_replicator')
+      .createDocument(replicatorDoc._id, '_replicator', replicatorDoc)
+      .loginToGUI()
+      .waitForElementNotPresent('.global-notification .fonticon-cancel', waitTime, false)
+      .url(baseUrl + '/#replication')
+      .waitForElementNotPresent('.load-lines', waitTime, true)
+      .waitForElementPresent('.replication__filter', waitTime, true)
+      .clickWhenVisible('a[title="Edit replication"]')
+      .waitForElementNotPresent('.load-lines', waitTime, true)
+      .waitForElementPresent('.replication__section', waitTime, true)
+      .end();
+  },
+
+  'Can filter docs': client => {
+    const waitTime = client.globals.maxWaitTime;
+    const baseUrl = client.globals.test_settings.launch_url;
+    const password = client.globals.test_settings.password;
+
+    const replicatorDoc1 = {
+      _id: 'existing-doc-id-filter1',
+      source: "http://source-db.com",
+      target: "http://target-db.com"
+    };
+
+    const replicatorDoc2 = {
+      _id: 'existing-doc-filter2',
+      source: "http://source-db2.com",
+      target: "http://target-db.com"
+    };
+    client
+      .deleteDatabase('_replicator')
+      .createDatabase('_replicator')
+      .createDocument(replicatorDoc1._id, '_replicator', replicatorDoc1)
+      .createDocument(replicatorDoc2._id, '_replicator', replicatorDoc2)
+      .loginToGUI()
       .waitForElementNotPresent('.global-notification .fonticon-cancel', waitTime, false)
-      .url(baseUrl)
-      .waitForElementPresent('.databases.table', waitTime, false)
-      .url(baseUrl + '/#/replication')
+      .url(baseUrl + '/#replication')
       .waitForElementNotPresent('.load-lines', waitTime, true)
-      .waitForElementNotPresent('a[title="Delete document existing-doc-id-2"]', waitTime,
true)
-      .assert.elementNotPresent('a[title="Delete document existing-doc-id-2"]')
+      .setValue('.replication__filter-input', 'filter1')
+      .waitForElementNotPresent('a[href="#/database/_replicator/existing-doc-filter2"]',
waitTime, true)
+      .clearValue('.replication__filter-input')
+      .setValue('.replication__filter-input', 'filter')
+      .waitForElementPresent('a[href="#/database/_replicator/existing-doc-filter2"]', waitTime,
true)
       .end();
   }
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2dc41889/test/nightwatch_tests/custom-commands/checkForDocumentDeleted.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/checkForDocumentDeleted.js b/test/nightwatch_tests/custom-commands/checkForDocumentDeleted.js
new file mode 100644
index 0000000..7b28821
--- /dev/null
+++ b/test/nightwatch_tests/custom-commands/checkForDocumentDeleted.js
@@ -0,0 +1,49 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+var util = require('util'),
+    events = require('events'),
+    helpers = require('../helpers/helpers.js'),
+    request = require('request');
+
+const commandHelper = require('./helper.js');
+const checkForDocumentDeleted = commandHelper.checkForDocumentDeleted;
+
+function CheckForDocumentDeleted () {
+  events.EventEmitter.call(this);
+}
+
+// inherit from node's event emitter
+util.inherits(CheckForDocumentDeleted, events.EventEmitter);
+
+CheckForDocumentDeleted.prototype.command = function (doc, timeout, db) {
+  const couchUrl = this.client.options.db_url;
+
+  if (!db) {
+    db = helpers.testDatabaseName;
+  }
+
+  if (!timeout) {
+    timeout = helpers.maxWaitTime;
+  }
+
+  const url = [couchUrl, db, doc].join('/');
+
+  console.log('checking this doc is deleted: ', url);
+  checkForDocumentDeleted(url, timeout, () => {
+    this.emit('complete');
+  });
+
+  return this;
+};
+
+module.exports = CheckForDocumentDeleted;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/2dc41889/test/nightwatch_tests/custom-commands/helper.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/helper.js b/test/nightwatch_tests/custom-commands/helper.js
index 5b1718b..93a1516 100644
--- a/test/nightwatch_tests/custom-commands/helper.js
+++ b/test/nightwatch_tests/custom-commands/helper.js
@@ -37,3 +37,20 @@ exports.checkForDatabaseCreated = function checkForDatabaseCreated (couchUrl,
da
     });
   }, 1000);
 };
+
+exports.checkForDocumentDeleted = function checkForDocumentDeleted (couchUrl, timeout, cb)
{
+  const timeOutId = setTimeout(() => {
+    throw new Error('timeout waiting for doc to be deleted');
+  }, timeout);
+
+  const intervalId = setInterval(() => {
+    request(couchUrl, function (er, res, body) {
+      if (res.statusCode === 404) {
+        clearTimeout(timeOutId);
+        clearInterval(intervalId);
+        cb(null);
+      }
+    });
+  }, 1000);
+
+};


Mime
View raw message