Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/230#discussion_r23397432
--- Diff: app/addons/documents/tests/nightwatch/expandCollapseRows.js ---
@@ -0,0 +1,52 @@
+// 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.
+
+module.exports = {
+
+ 'Expand/Collapse works on documents': function (client) {
+ var waitTime = 10000,
+ newDatabaseName = client.globals.testDatabaseName,
+ baseUrl = client.globals.test_settings.launch_url;
+
+ client
+ .loginToGUI()
+ .createDocument("doc 1", newDatabaseName)
+ .createDocument("doc 2", newDatabaseName)
+ .createDocument("doc 3", newDatabaseName)
+ .createDocument("doc 4", newDatabaseName)
+ .createDocument("doc 5", newDatabaseName)
+ .url(baseUrl + '/#/database/' + newDatabaseName + '/_all_docs')
+ .waitForElementVisible('#collapse', waitTime, false)
+
+ // confirm all rows are expanded by default (more elegant way to do
this?)
+ .source(function (result) {
+ var numExpandedDocs = result.value.match(/doc-data/g).length;
+ this.verify.ok(numExpandedDocs === 5, 'Checking there are 5
expanded rows');
+ })
+
+ // now toggle the items and confirm there are NO expanded items
+ .click('#collapse')
+ .waitForElementNotPresent('.doc-data', waitTime, false)
+
+ // lastly, expand a single one and confirm there's only one that's
been expanded
+
+ // this is done because we're unable to click() on hidden input, or
the :before styled checkbox
+ .execute('$(".js-row-select").first().trigger("click");')
+ .pause(500)
+ .click('#collapse')
+ .source(function (result) {
+ var numExpandedDocs = result.value.match(/doc-data/g).length;
+ this.verify.ok(numExpandedDocs === 1, 'Checking there is 1
expanded row');
+ })
+ .end();
--- End diff --
you can use the label, as it is made for clicking on it - you may want to
add some wait-calls `waitElement*` for some classes to appear that this example
also runs on slow machines
```javascript
// now toggle the items and confirm there are NO expanded items
.click('#collapse')
.waitForElementNotPresent('.doc-data', waitTime, false)
// lastly, expand a single one and confirm there's only one that's
been expanded
.click('.label-checkbox-doclist')
.click('#collapse')
.source(function (result) {
var numExpandedDocs = result.value.match(/doc-data/g).length;
this.verify.ok(numExpandedDocs === 1, 'Checking there is 1 expanded
row');
})
.end();
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---