This is an automated email from the ASF dual-hosted git repository.
acote pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push:
new 5173c61 Allow to resolve conflicts of design documents (#1094)
5173c61 is described below
commit 5173c613cbfa6e414252567bd12468320aa51485
Author: Alexis Côté <[email protected]>
AuthorDate: Sun Jun 24 17:06:03 2018 -0400
Allow to resolve conflicts of design documents (#1094)
---
app/addons/documents/routes-doc-editor.js | 5 +++
.../documents/tests/nightwatch/revBrowser.js | 46 ++++++++++++++++++++++
test/animal-db.json | 3 +-
test/create-animal-db.js | 45 ++++++++++++++-------
4 files changed, 83 insertions(+), 16 deletions(-)
diff --git a/app/addons/documents/routes-doc-editor.js
b/app/addons/documents/routes-doc-editor.js
index 3701666..aa09710 100644
--- a/app/addons/documents/routes-doc-editor.js
+++ b/app/addons/documents/routes-doc-editor.js
@@ -35,6 +35,7 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
routes: {
'database/:database/:doc/conflicts': 'revisionBrowser',
'database/:database/:doc/code_editor': 'codeEditor',
+ 'database/:database/_design/:ddoc/conflicts': 'revBrowserForDesignDoc',
'database/:database/_design/:ddoc': 'showDesignDoc',
'database/:database/_local/:doc': 'showLocalDoc',
'database/:database/:doc': 'codeEditor',
@@ -58,6 +59,10 @@ const DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
/>;
},
+ revBrowserForDesignDoc: function(databaseName, ddoc) {
+ return this.revisionBrowser(databaseName, '_design/' + ddoc);
+ },
+
codeEditor: function (databaseName, docId) {
const backLink = FauxtonAPI.urls('allDocs', 'app',
FauxtonAPI.url.encode(databaseName));
diff --git a/app/addons/documents/tests/nightwatch/revBrowser.js
b/app/addons/documents/tests/nightwatch/revBrowser.js
index 9674c79..7d19a70 100644
--- a/app/addons/documents/tests/nightwatch/revBrowser.js
+++ b/app/addons/documents/tests/nightwatch/revBrowser.js
@@ -58,5 +58,51 @@ module.exports = {
})
.end();
+ },
+ 'is able to show two design docs next to each other, and diff them' :
function (client) {
+ /*jshint multistr: true */
+ const waitTime = client.globals.maxWaitTime;
+ const newDatabaseName = 'animaldb';
+ const baseUrl = client.globals.test_settings.launch_url;
+
+ client
+ .createAnimalDb()
+ .checkForDocumentCreated('_design/animals', null, newDatabaseName)
+
+ .loginToGUI()
+ .url(baseUrl + '/#/database/' + newDatabaseName + '/_design/animals')
+
+ .clickWhenVisible('button.conflicts')
+
+ .waitForElementVisible('.revision-diff-area', waitTime, false)
+
+ .assert.containsText('.revision-diff-area', '"black & white"')
+ .assert.containsText('.revision-diff-area', '"white"')
+
+ .clickWhenVisible('.two-sides-toggle-button button:last-child')
+
+ .waitForElementVisible('.revision-split-area', waitTime, false)
+
+ .assert.containsText('.revision-split-area [data-id="ours"]', '"black &
white"')
+ .assert.containsText('.revision-split-area [data-id="theirs"]',
'"white"')
+
+
+ .clickWhenVisible('[data-id="button-select-theirs"]')
+ .clickWhenVisible('.modal-footer input[type="checkbox"]')
+ .clickWhenVisible('.modal-footer button.btn-danger')
+ .clickWhenVisible('.fonticon-json')
+
+ .clickWhenVisible('[data-id="_design/animals"] a')
+
+ .waitForElementVisible('.panel-section', waitTime, false)
+ .assert.elementNotPresent('button.conflicts')
+
+ .url(baseUrl + '/#/database/' + newDatabaseName +
'?include_docs=true&conflicts=true')
+
+ .getText('body', function (result) {
+ this.verify.ok(result.value.indexOf('"color": "white"') !== -1, 'check
if doc version was promoted');
+ })
+
+ .end();
}
};
diff --git a/test/animal-db.json b/test/animal-db.json
index 19e3ff5..a8d7ad7 100644
--- a/test/animal-db.json
+++ b/test/animal-db.json
@@ -9,5 +9,6 @@
{"_id":"llama","min_weight":130,"max_weight":200,"min_length":1.7,"max_length":1.8,"latin_name":"Lama
glama","wiki_page":"http://en.wikipedia.org/wiki/Llama","class":"mammal","diet":"herbivore"},
{"_id":"panda","wiki_page":"http://en.wikipedia.org/wiki/Panda","min_weight":75,"max_weight":115,"min_length":1.2,"max_length":1.8,"class":"mammal","diet":"carnivore"},
{"_id":"snipe","min_weight":0.08,"max_weight":0.14,"min_length":0.25,"max_length":0.27,"latin_name":"Gallinago
gallinago","wiki_page":"http://en.wikipedia.org/wiki/Common_Snipe","class":"bird","diet":"omnivore"},
-{"_id":"zebra","wiki_page":"http://en.wikipedia.org/wiki/Plains_zebra","min_length":2,"max_length":2.5,"min_weight":175,"max_weight":387,"class":"mammal","diet":"herbivore"}
+{"_id":"zebra","wiki_page":"http://en.wikipedia.org/wiki/Plains_zebra","min_length":2,"max_length":2.5,"min_weight":175,"max_weight":387,"class":"mammal","diet":"herbivore"},
+{"_id":"_design/animals",
"language":"javascript","views":{"by-latin-name":{"map":"function(doc){if(doc.latin_name)emit(doc.latin_name);}"}}}
]
diff --git a/test/create-animal-db.js b/test/create-animal-db.js
index c128c42..1e5205a 100644
--- a/test/create-animal-db.js
+++ b/test/create-animal-db.js
@@ -3,8 +3,6 @@ const async = require('async');
const animals = require('../test/animal-db.json');
-const conflictingDoc = 'zebra';
-
module.exports = createAnimalDb;
function createAnimalDb (url, cb) {
@@ -65,7 +63,10 @@ function createAnimalDb (url, cb) {
replicate(`${url}/animaldb`, `${url}/animaldb-copy-2`, true, cb);
},
(cb) => {
- alterDocs(cb);
+ alterZebraDocs(cb);
+ },
+ (cb) => {
+ alterAnimalDesignDoc(cb)
},
(cb) => {
replicate(`${url}/animaldb-copy`, `${url}/animaldb`, false, cb);
@@ -125,27 +126,27 @@ function createAnimalDb (url, cb) {
});
}
- function getRev (db, cb) {
+ function getRev (db, id, cb) {
request({
- uri: `${url}/${db}/${conflictingDoc}`,
+ uri: `${url}/${db}/${id}`,
json: true
}, (err, res, body) => {
cb(null, body._rev);
});
}
- function updateDoc (db, data, cb) {
+ function updateDoc (db, id, data, cb) {
- getRev(db, (err, rev) => {
- alterDoc(db, data, rev, cb);
+ getRev(db, id, (err, rev) => {
+ alterDoc(db,id, data, rev, cb);
});
}
- function alterDoc (db, data, rev, cb) {
+ function alterDoc (db, id, data, rev, cb) {
data._rev = rev;
request({
- uri: `${url}/${db}/${conflictingDoc}`,
+ uri: `${url}/${db}/${id}`,
json: true,
method: 'PUT',
body: data
@@ -154,20 +155,34 @@ function createAnimalDb (url, cb) {
});
}
- function alterDocs (cb) {
+ function alterZebraDocs (cb) {
- updateDoc('animaldb', {
+ updateDoc('animaldb','zebra', {
color: 'black & white'
}, () => {
-
- updateDoc('animaldb-copy', {
+ updateDoc('animaldb-copy', 'zebra', {
color: 'white'
}, () => {
- updateDoc('animaldb-copy-2', {
+ updateDoc('animaldb-copy-2', 'zebra', {
color: 'green'
}, cb);
});
});
}
+ function alterAnimalDesignDoc (cb) {
+
+ updateDoc('animaldb','_design/animals', {
+ color: 'black & white'
+ }, () => {
+ updateDoc('animaldb-copy', '_design/animals', {
+ color: 'white'
+ }, () => {
+ updateDoc('animaldb-copy-2', '_design/animals', {
+ color: 'green'
+ }, cb);
+ });
+ });
+ }
+
}