Skip to content

Commit fd84140

Browse files
committed
test(xqsuite): add diagnostics check to XQsuite
1 parent ad341c5 commit fd84140

File tree

8 files changed

+224
-54
lines changed

8 files changed

+224
-54
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Should you encounter documentation for features that are deprecated in the minim
4444
The full test-suite consists of validation, unit, and integration tests, it runs automatically on travis. To be able to run integration tests locally, contributors should run `npm i` to download and install [cypress.js](https://www.cypress.io). This is only required once. To execute the tests run the following commands:
4545
- To validate xml files run `mvn validate`,
4646
- to run the javascript tests `mvn test` (xQsuite coming soon). We do **not** support testing via node alone, aka `npm test`, use the maven command instead.
47-
- To run the Integrations tests `npm run cypress`.
47+
- To run the Integrations tests, however, use `npm run cypress`.
4848

49-
Both unit and integration tests, expect a running instance of exist with a copy of the documentation app installed reachable at `localhost:8080` and an empty admin password.
49+
Both unit and integration tests, expect a running instance of exist with a copy of the documentation app installed reachable at `localhost:8080` and an empty admin password. It might be necessary to skip test execution during building from time to time, use: `mvn clean package -DskipTests`.
5050

5151
## License
5252
LGPLv2.1 [eXist-db.org](http://exist-db.org/exist/apps/homepage/index.html)

package-lock.json

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"homepage": "https://github.com/eXist-db/documentation#readme",
2626
"devDependencies": {
2727
"acorn": "^6.1.1",
28+
"chai": "^4.2.0",
2829
"cypress": "^3.2.0",
2930
"del": "^4.1.1",
3031
"gulp": "^4.0.2",
@@ -41,7 +42,8 @@
4142
"gulp-svgmin": "^2.2.0",
4243
"gulp-uglify": "^3.0.2",
4344
"lazypipe": "^1.0.2",
44-
"mocha": "^6.1.4"
45+
"mocha": "^6.1.4",
46+
"supertest": "^4.0.2"
4547
},
4648
"dependencies": {
4749
"@neos21/bootstrap3-glyphicons": "^1.0.3",
Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
11
<collection xmlns="http://exist-db.org/collection-config/1.0">
2-
<index xmlns:db5="http://docbook.org/ns/docbook">
3-
<fulltext default="none" attributes="false"/>
4-
<lucene>
5-
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
2+
<index xmlns:db5="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<fulltext default="none" attributes="false"/>
4+
<lucene>
5+
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
66

7-
<!--
8-
Indexes below are ordered by their relevance (or "boost"),
9-
with the most relevant listed first.
10-
11-
Our definitions are based on the assumption that the most
12-
specific content will be deeper within the document.
13-
-->
7+
<!-- Indexes below are ordered by their relevance (or "boost"), with the most relevant listed first. Our definitions are based on the assumption that the most specific content will be deeper within the document. -->
148

15-
<!-- document metadata -->
16-
<text qname="db5:keyword" boost="2.0"/>
17-
<text match="/db5:article/db5:info/db5:title" boost="1.7"/>
18-
<text match="/db5:article/db5:para" boost="1.5"/>
9+
<!-- document metadata -->
10+
<text qname="db5:keyword" boost="2.0"/>
11+
<text match="/db5:article/db5:info/db5:title" boost="1.7"/>
12+
<text match="/db5:article/db5:para" boost="1.5"/>
1913

20-
<!-- sect3 -->
21-
<text match="/db5:article/db5:sect1/db5:sect2/db5:sect3/db5:title" boost="1.35"/>
22-
<text qname="db5:sect3" boost="1.3">
23-
<ignore qname="db5:title"/>
24-
<ignore qname="db5:programlisting"/>
25-
<ignore qname="db5:screen"/>
26-
<ignore qname="db5:synopsis"/>
27-
</text>
28-
29-
<!-- sect2 -->
30-
<text match="/db5:article/db5:sect1/db5:sect2/db5:title" boost="1.25"/>
31-
<text qname="db5:sect2" boost="1.2">
32-
<ignore qname="db5:title"/>
33-
<ignore qname="db5:programlisting"/>
34-
<ignore qname="db5:screen"/>
35-
<ignore qname="db5:synopsis"/>
36-
</text>
37-
38-
<!-- sect1 -->
39-
<text match="/db5:article/db5:sect1/db5:title" boost="1.15"/>
40-
<text qname="db5:sect1" boost="1.1">
41-
<ignore qname="db5:title"/>
42-
<ignore qname="db5:programlisting"/>
43-
<ignore qname="db5:screen"/>
44-
<ignore qname="db5:synopsis"/>
45-
</text>
14+
<!-- sect3 -->
15+
<text match="/db5:article/db5:sect1/db5:sect2/db5:sect3/db5:title" boost="1.35"/>
16+
<text qname="db5:sect3" boost="1.3">
17+
<ignore qname="db5:title"/>
18+
<ignore qname="db5:programlisting"/>
19+
<ignore qname="db5:screen"/>
20+
<ignore qname="db5:synopsis"/>
21+
</text>
4622

47-
</lucene>
48-
</index>
49-
</collection>
23+
<!-- sect2 -->
24+
<text match="/db5:article/db5:sect1/db5:sect2/db5:title" boost="1.25"/>
25+
<text qname="db5:sect2" boost="1.2">
26+
<ignore qname="db5:title"/>
27+
<ignore qname="db5:programlisting"/>
28+
<ignore qname="db5:screen"/>
29+
<ignore qname="db5:synopsis"/>
30+
</text>
31+
32+
<!-- sect1 -->
33+
<text match="/db5:article/db5:sect1/db5:title" boost="1.15"/>
34+
<text qname="db5:sect1" boost="1.1">
35+
<ignore qname="db5:title"/>
36+
<ignore qname="db5:programlisting"/>
37+
<ignore qname="db5:screen"/>
38+
<ignore qname="db5:synopsis"/>
39+
</text>
40+
41+
</lucene>
42+
<range>
43+
<create qname="@xlink:href" type="xs:string"/>
44+
<create qname="@db5:fileref" type="xs:string"/>
45+
</range>
46+
</index>
47+
</collection>

src/main/xar-resources/modules/test-runner.xql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ declare option output:media-type "application/json";
1616

1717
test:suite(
1818
inspect:module-functions(xs:anyURI("test-suite.xql"))
19-
)
19+
)

src/main/xar-resources/modules/test-suite.xql

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ declare namespace test = "http://exist-db.org/xquery/xqsuite";
1111

1212
import module namespace docbook = "http://docbook.org/ns/docbook" at "docbook.xql";
1313
import module namespace config = "http://exist-db.org/xquery/apps/config" at "config.xqm";
14+
import module namespace diag = "http://exist-db.org/xquery/diagnostics" at "diagnostics.xql";
15+
import module namespace rvds = "http://exist-db.org/xquery/rvd-support" at "rvd-support.xql";
1416

1517
declare namespace db5 = "http://docbook.org/ns/docbook";
1618

1719
declare
1820
%test:name('section-headings')
1921
%test:assertEmpty
2022
function tests:missing-id() {
21-
23+
2224
let $no-id := distinct-values(
2325
for $n in collection($config:data-root)//db5:article/db5:sect1 | collection($config:data-root)//db5:article//db5:sect2 | collection($config:data-root)//db5:article//db5:sect3
2426
return
@@ -27,9 +29,24 @@ function tests:missing-id() {
2729
else
2830
(util:document-name($n))
2931
)
30-
32+
3133
for $m in $no-id
3234
order by $m
3335
return
3436
$m
3537
};
38+
39+
declare
40+
%test:name('diagnose listings')
41+
%test:assertEmpty
42+
function tests:orphan-listing() {
43+
let $report := diag:diagnose(<root/>, map{1: 1})
44+
let $error := $report//ul//span[. eq '*ERROR* ']
45+
let $error-msg := count($error)
46+
let $art := $error/ancestor::li/h3/code/string()
47+
let $list := $error/ancestor::tr//code[1]/string()
48+
return
49+
if ($error-msg > 0)
50+
then ( $list || ' is missing in ' || $art )
51+
else ()
52+
};

src/test/mocha/test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
var assert = require('assert');
1+
const assert = require('assert')
2+
23
// this is a dummy test js tests are wip
34
describe('Array', function() {
45
describe('#indexOf()', function() {
56
it('should return -1 when the value is not present', function() {
67
assert.equal([1,2,3].indexOf(4), -1);
7-
});
8-
});
9-
});
8+
})
9+
})
10+
})

0 commit comments

Comments
 (0)