garrensmith closed pull request #1019: Fix replication activity order reversing
on action click
URL: https://github.com/apache/couchdb-fauxton/pull/1019
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/Gruntfile.js b/Gruntfile.js
index bca5e268d..62cc59d51 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -159,7 +159,7 @@ module.exports = function (grunt) {
exec: {
start_nightWatch: {
- command: __dirname + '/node_modules/nightwatch/bin/nightwatch' +
+ command: 'node ' + __dirname +
'/node_modules/nightwatch/bin/nightwatch' +
' -c ' + __dirname + '/test/nightwatch_tests/nightwatch.json',
options: {
maxBuffer: 1000 * 1024
diff --git a/app/addons/replication/components/common-table.js
b/app/addons/replication/components/common-table.js
index 8e3fd0508..39122611a 100644
--- a/app/addons/replication/components/common-table.js
+++ b/app/addons/replication/components/common-table.js
@@ -280,12 +280,15 @@ export class ReplicationTable extends React.Component {
}
sort(column, descending, docs) {
+ let orderChanged = false;
const sorted = docs.sort((a, b) => {
if (a[column] < b[column]) {
+ orderChanged = true;
return -1;
}
if (a[column] > b[column]) {
+ orderChanged = true;
return 1;
}
@@ -293,7 +296,7 @@ export class ReplicationTable extends React.Component {
});
- if (!descending) {
+ if (!descending && orderChanged) {
sorted.reverse();
}
diff --git a/app/addons/replication/tests/nightwatch/replicationactivity.js
b/app/addons/replication/tests/nightwatch/replicationactivity.js
index c3f2e07c1..3f1f49b59 100644
--- a/app/addons/replication/tests/nightwatch/replicationactivity.js
+++ b/app/addons/replication/tests/nightwatch/replicationactivity.js
@@ -94,5 +94,44 @@ module.exports = {
.setValue('.replication__filter-input', 'filter')
.waitForElementPresent('a[href="#/database/_replicator/existing-doc-filter2"]',
waitTime, true)
.end();
+ },
+ "Action click doesn't change doc's order": client =>{
+ const waitTime = client.globals.maxWaitTime;
+ const baseUrl = client.globals.test_settings.launch_url;
+ const firstRowSelector = '.replication__table-row:nth-of-type(1)';
+ let firstDoc;
+
+ 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 + '/#replication')
+ .waitForElementNotPresent('.load-lines', waitTime, true)
+ .waitForElementVisible(firstRowSelector, waitTime, true)
+ .getText(firstRowSelector + ' td:nth-of-type(2)', function(result) {
+ firstDoc = result.value;
+ })
+ .clickWhenVisible(firstRowSelector + '
.replication__row-btn.icon-trash', waitTime, true)
+ .clickWhenVisible('.replication_delete-doc-modal.modal-dialog
.modal-footer .cancel-link', waitTime, true)
+ .waitForElementVisible(firstRowSelector, waitTime, true)
+ .getText(firstRowSelector + ' td:nth-of-type(2)', function(result) {
+ this.verify.ok(result.value === firstDoc,
+ 'Checking if the order was reserved if no documents were
sorted');
+ })
+ .end();
}
};
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services