proskomma-core 0.9.7 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +79 -0
- package/.gitattributes +2 -0
- package/babel.config.js +18 -0
- package/docs/_config.yml +1 -0
- package/docs/index.md +3 -0
- package/docs/pk_edit_0_9.odt +0 -0
- package/docs/pk_edit_0_9.pdf +0 -0
- package/docs/proskomma_101_slideshow.odp +0 -0
- package/docs/proskomma_101_slideshow.pdf +0 -0
- package/docs/proskomma_edit_html.png +0 -0
- package/docs/proskomma_edit_html.svg +451 -0
- package/docs/proskomma_edit_reference.png +0 -0
- package/docs/proskomma_edit_reference.svg +349 -0
- package/docs/repo_logo.png +0 -0
- package/esm/package.json +3 -0
- package/esm/wrapper.mjs +5 -0
- package/index.js +6 -0
- package/package.json +19 -17
- package/src/graph/index.cjs +201 -0
- package/src/graph/lib/do_cv.cjs +249 -0
- package/src/graph/lib/dump.cjs +40 -0
- package/src/graph/lib/remake_blocks.cjs +57 -0
- package/src/graph/lib/sequence_chars.cjs +84 -0
- package/src/graph/lib/sort.cjs +39 -0
- package/src/graph/lib/tribos.cjs +97 -0
- package/src/graph/lib/tribos_expression.cjs +556 -0
- package/src/graph/lib/tribos_ohm_UNUSED.cjs +37 -0
- package/src/graph/lib/tribos_step.cjs +434 -0
- package/src/graph/mutations/add.cjs +91 -0
- package/src/graph/mutations/delete.cjs +61 -0
- package/src/graph/mutations/index.cjs +54 -0
- package/src/graph/mutations/rehash.cjs +17 -0
- package/src/graph/mutations/tags.cjs +120 -0
- package/src/graph/mutations/update.cjs +210 -0
- package/src/graph/mutations/versification.cjs +96 -0
- package/src/graph/queries/block.cjs +228 -0
- package/src/graph/queries/cIndex.cjs +87 -0
- package/src/graph/queries/cell.cjs +42 -0
- package/src/graph/queries/cv.cjs +19 -0
- package/src/graph/queries/cvBook.cjs +16 -0
- package/src/graph/queries/cvChapter.cjs +16 -0
- package/src/graph/queries/cvIndex.cjs +47 -0
- package/src/graph/queries/cvNavigation.cjs +116 -0
- package/src/graph/queries/cvVerseElement.cjs +84 -0
- package/src/graph/queries/cvVerses.cjs +14 -0
- package/src/graph/queries/doc_set.cjs +220 -0
- package/src/graph/queries/document.cjs +555 -0
- package/src/graph/queries/idParts.cjs +30 -0
- package/src/graph/queries/index.cjs +151 -0
- package/src/graph/queries/inputBlockSpec.cjs +17 -0
- package/src/graph/queries/inputItemObject.cjs +12 -0
- package/src/graph/queries/input_att_spec.cjs +14 -0
- package/src/graph/queries/input_key_matches.cjs +11 -0
- package/src/graph/queries/input_key_value.cjs +11 -0
- package/src/graph/queries/input_key_values.cjs +11 -0
- package/src/graph/queries/input_selector_spec.cjs +19 -0
- package/src/graph/queries/item.cjs +71 -0
- package/src/graph/queries/itemGroup.cjs +75 -0
- package/src/graph/queries/key_value.cjs +18 -0
- package/src/graph/queries/kv_entry.cjs +21 -0
- package/src/graph/queries/kv_sequence.cjs +151 -0
- package/src/graph/queries/node.cjs +44 -0
- package/src/graph/queries/orig.cjs +11 -0
- package/src/graph/queries/regex_index.cjs +18 -0
- package/src/graph/queries/row_equals_spec.cjs +11 -0
- package/src/graph/queries/row_match_spec.cjs +11 -0
- package/src/graph/queries/selector_spec.cjs +29 -0
- package/src/graph/queries/sequence.cjs +314 -0
- package/src/graph/queries/table_sequence.cjs +192 -0
- package/src/graph/queries/tree_sequence.cjs +58 -0
- package/src/graph/queries/verseNumber.cjs +44 -0
- package/src/graph/queries/verseRange.cjs +11 -0
- package/src/graph/queries/versification.cjs +25 -0
- package/src/index.cjs +583 -0
- package/src/model/doc_set.cjs +389 -0
- package/src/model/doc_set_helpers/block.cjs +232 -0
- package/src/model/doc_set_helpers/enum.cjs +87 -0
- package/src/model/doc_set_helpers/item.cjs +198 -0
- package/src/model/doc_set_helpers/rehash.cjs +53 -0
- package/src/model/doc_set_helpers/selectors.cjs +58 -0
- package/src/model/doc_set_helpers/serialize.cjs +22 -0
- package/src/model/doc_set_helpers/unsuccinctify.cjs +288 -0
- package/src/model/doc_set_helpers/update.cjs +290 -0
- package/src/model/document.cjs +369 -0
- package/src/model/document_helpers/blocks.cjs +135 -0
- package/src/model/document_helpers/chapter_verse.cjs +291 -0
- package/src/model/document_helpers/pre_enums.cjs +67 -0
- package/src/model/document_helpers/sequences.cjs +205 -0
- package/src/model/document_helpers/serialize_succinct.cjs +55 -0
- package/src/model/document_helpers/succinct_filter.cjs +102 -0
- package/src/model/versifications/eng_vrs.cjs +455 -0
- package/src/model/versifications/index.cjs +38 -0
- package/src/model/versifications/lxx_vrs.cjs +950 -0
- package/src/model/versifications/org_vrs.cjs +155 -0
- package/src/model/versifications/rsc_vrs.cjs +342 -0
- package/src/model/versifications/rso_vrs.cjs +541 -0
- package/src/model/versifications/vul_vrs.cjs +835 -0
- package/src/parser/index.cjs +506 -0
- package/src/parser/lexers/index.cjs +11 -0
- package/src/parser/lexers/lexingRegexes.cjs +45 -0
- package/src/parser/lexers/nodes.cjs +123 -0
- package/src/parser/lexers/object_for_fragment.cjs +123 -0
- package/src/parser/lexers/tsv.cjs +45 -0
- package/src/parser/lexers/usfm.cjs +17 -0
- package/src/parser/lexers/usx/index.cjs +7 -0
- package/src/parser/lexers/usx/usx_lexer.cjs +321 -0
- package/src/parser/lib/tokenize.cjs +37 -0
- package/src/parser/model/index.cjs +637 -0
- package/src/parser/parser_specs.cjs +781 -0
- package/src/pipelines/perf2x/index.cjs +7 -0
- package/src/pipelines/perf2x/perf2PkJsonPipeline.json +41 -0
- package/src/pipelines/perf2x/perf2usfmPipeline.json +65 -0
- package/src/transforms/calculateUsfmChapterPositions.cjs +106 -0
- package/src/transforms/index.cjs +9 -0
- package/src/transforms/perf2PkJson.cjs +534 -0
- package/src/transforms/perf2usfm.cjs +294 -0
- package/src/util/byteArray.cjs +251 -0
- package/src/util/canons.cjs +117 -0
- package/src/util/enums.cjs +41 -0
- package/src/util/generateId.cjs +6 -0
- package/src/util/graftDefs.cjs +15 -0
- package/src/util/index.cjs +29 -0
- package/src/util/inspectSuccinct.cjs +59 -0
- package/src/util/itemDefs.cjs +33 -0
- package/src/util/parserConstantDefs.cjs +30 -0
- package/src/util/scopeDefs.cjs +173 -0
- package/src/util/scriptlike/blocksSpec.cjs +192 -0
- package/src/util/scriptlike/dodson_lexicon.xsl +19 -0
- package/src/util/scriptlike/dodson_lexicon_to_entries.cjs +85 -0
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon.xsl +28 -0
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon_to_entries.cjs +85 -0
- package/src/util/succinct.cjs +159 -0
- package/src/util/tags.cjs +28 -0
- package/src/util/tokenDefs.cjs +27 -0
- package/src/util/versification.cjs +364 -0
- package/test/code/main/bad.cjs +79 -0
- package/test/code/main/basics.cjs +534 -0
- package/test/code/main/block.cjs +586 -0
- package/test/code/main/block_scope_numbers.cjs +31 -0
- package/test/code/main/blocks_with_atts.cjs +150 -0
- package/test/code/main/blocks_with_cv.cjs +250 -0
- package/test/code/main/break.cjs +73 -0
- package/test/code/main/checksum.cjs +36 -0
- package/test/code/main/cl_global.cjs +35 -0
- package/test/code/main/class_for_fragment.cjs +18 -0
- package/test/code/main/clean_usfm.cjs +46 -0
- package/test/code/main/cp_vp.cjs +158 -0
- package/test/code/main/custom.cjs +124 -0
- package/test/code/main/cv.cjs +249 -0
- package/test/code/main/cvMatching.cjs +155 -0
- package/test/code/main/cv_indexes.cjs +189 -0
- package/test/code/main/cv_navigation.cjs +124 -0
- package/test/code/main/document.cjs +382 -0
- package/test/code/main/empty_blocks.cjs +71 -0
- package/test/code/main/entries.cjs +402 -0
- package/test/code/main/export_lexing_regexes.cjs +19 -0
- package/test/code/main/fig.cjs +67 -0
- package/test/code/main/filter.cjs +222 -0
- package/test/code/main/glossary.cjs +36 -0
- package/test/code/main/graft_headings.cjs +36 -0
- package/test/code/main/graft_introduction.cjs +96 -0
- package/test/code/main/graft_note.cjs +104 -0
- package/test/code/main/graft_rems.cjs +34 -0
- package/test/code/main/graft_sidebars.cjs +62 -0
- package/test/code/main/graft_title.cjs +36 -0
- package/test/code/main/hello.cjs +105 -0
- package/test/code/main/import_document.cjs +22 -0
- package/test/code/main/import_usfm_int.cjs +48 -0
- package/test/code/main/item_groups.cjs +133 -0
- package/test/code/main/items_with_cv.cjs +311 -0
- package/test/code/main/milestone_attributes.cjs +163 -0
- package/test/code/main/mixed_sequence_documents.cjs +137 -0
- package/test/code/main/mixed_sequences.cjs +217 -0
- package/test/code/main/modify_sequence.cjs +29 -0
- package/test/code/main/multiple_chapters.cjs +58 -0
- package/test/code/main/multiple_content.cjs +105 -0
- package/test/code/main/mutate_add.cjs +180 -0
- package/test/code/main/mutate_delete.cjs +236 -0
- package/test/code/main/mutate_rehash.cjs +68 -0
- package/test/code/main/mutate_tags.cjs +90 -0
- package/test/code/main/mutate_update.cjs +538 -0
- package/test/code/main/selectors.cjs +289 -0
- package/test/code/main/sequence.cjs +361 -0
- package/test/code/main/serialize.cjs +104 -0
- package/test/code/main/spans.cjs +51 -0
- package/test/code/main/split_long_tokens.cjs +30 -0
- package/test/code/main/standard_vrs.cjs +76 -0
- package/test/code/main/subclass.cjs +25 -0
- package/test/code/main/table.cjs +119 -0
- package/test/code/main/tags.cjs +248 -0
- package/test/code/main/token_alignment.cjs +84 -0
- package/test/code/main/trees.cjs +211 -0
- package/test/code/main/tribos.cjs +865 -0
- package/test/code/main/tsv.cjs +385 -0
- package/test/code/main/usx_ref.cjs +65 -0
- package/test/code/main/verse_mapping.cjs +252 -0
- package/test/code/main/verse_range.cjs +31 -0
- package/test/code/main/word_likes.cjs +41 -0
- package/test/code/utils/byte_array.cjs +271 -0
- package/test/code/utils/canons.cjs +20 -0
- package/test/code/utils/generate_id.cjs +17 -0
- package/test/code/utils/graft_defs.cjs +16 -0
- package/test/code/utils/inspect.cjs +130 -0
- package/test/code/utils/items.cjs +56 -0
- package/test/code/utils/push_succinct.cjs +69 -0
- package/test/code/utils/scope_defs.cjs +79 -0
- package/test/code/utils/serialize.cjs +28 -0
- package/test/code/utils/splice.cjs +67 -0
- package/test/code/utils/tags.cjs +69 -0
- package/test/code/utils/versification.cjs +249 -0
- package/test/lib/load.js +110 -0
- package/test/skipped_code/diff.js +53 -0
- package/test/test_data/inputBlockSpec/dodson.json +1654 -0
- package/test/test_data/inputBlockSpec/kv.json +326 -0
- package/test/test_data/inputBlockSpec/mk1.json +1019 -0
- package/test/test_data/inputBlockSpec/table.json +170 -0
- package/test/test_data/tree/genealogy.json +55 -0
- package/test/test_data/tree/jude.json +15965 -0
- package/test/test_data/tsv/en_tn_66-JUD.tsv +75 -0
- package/test/test_data/tsv/twl_JUD.tsv +144 -0
- package/test/test_data/usfm/1pe_webbe.usfm +13 -0
- package/test/test_data/usfm/66-JUD-ust.usfm +1089 -0
- package/test/test_data/usfm/78-GALspavbl.usfm +10 -0
- package/test/test_data/usfm/add_test.usfm +15 -0
- package/test/test_data/usfm/backslash.usfm +4 -0
- package/test/test_data/usfm/cl.usfm +14 -0
- package/test/test_data/usfm/cp_vp.usfm +8 -0
- package/test/test_data/usfm/custom.usfm +13 -0
- package/test/test_data/usfm/en_ust_oba.usfm +875 -0
- package/test/test_data/usfm/en_ust_psa_1.usfm +20 -0
- package/test/test_data/usfm/fig.usfm +3 -0
- package/test/test_data/usfm/filter.usfm +7 -0
- package/test/test_data/usfm/footnote.usfm +11 -0
- package/test/test_data/usfm/frt.usfm +4 -0
- package/test/test_data/usfm/headings.usfm +7 -0
- package/test/test_data/usfm/hello.usfm +8 -0
- package/test/test_data/usfm/int.usfm +7 -0
- package/test/test_data/usfm/milestone_attributes.usfm +7 -0
- package/test/test_data/usfm/milestone_attributes_default.usfm +7 -0
- package/test/test_data/usfm/no_break_space.usfm +4 -0
- package/test/test_data/usfm/no_mt.usfm +6 -0
- package/test/test_data/usfm/rems.usfm +6 -0
- package/test/test_data/usfm/section_intros.usfm +26 -0
- package/test/test_data/usfm/sidebars.usfm +25 -0
- package/test/test_data/usfm/slash_in_att.usfm +6 -0
- package/test/test_data/usfm/soft_line_break.usfm +4 -0
- package/test/test_data/usfm/spans.usfm +5 -0
- package/test/test_data/usfm/split_long_tokens.usfm +6 -0
- package/test/test_data/usfm/table.usfm +18 -0
- package/test/test_data/usfm/table_at_end.usfm +11 -0
- package/test/test_data/usfm/table_in_intro.usfm +22 -0
- package/test/test_data/usfm/table_no_end_cells.usfm +18 -0
- package/test/test_data/usfm/tit_kitchen_sink.usfm +73 -0
- package/test/test_data/usfm/titus_template.usfm +58 -0
- package/test/test_data/usfm/ugnt_3jn.usfm +265 -0
- package/test/test_data/usfm/ult_3jn.usfm +335 -0
- package/test/test_data/usfm/unknown.usfm +5 -0
- package/test/test_data/usfm/ust_psa.usfm +29 -0
- package/test/test_data/usfm/ust_psa_verse_ranges.usfm +24 -0
- package/test/test_data/usfm/ust_psa_with_ts.usfm +29 -0
- package/test/test_data/usfm/verse_breaks_in_blocks.usfm +20 -0
- package/test/test_data/usfm/verse_range.usfm +7 -0
- package/test/test_data/usfm/web_ecc.usfm +391 -0
- package/test/test_data/usfm/web_psa51.usfm +71 -0
- package/test/test_data/usfm/whitespace.usfm +12 -0
- package/test/test_data/usfm/xref.usfm +11 -0
- package/test/test_data/usx/bad_element.usx +2 -0
- package/test/test_data/usx/cp_vp.usx +12 -0
- package/test/test_data/usx/diff1.usx +59 -0
- package/test/test_data/usx/diff2.usx +74 -0
- package/test/test_data/usx/douay_rheims_ecc.usx +58 -0
- package/test/test_data/usx/douay_rheims_psa.usx +5366 -0
- package/test/test_data/usx/douay_rheims_psa_40_60.usx +666 -0
- package/test/test_data/usx/douay_rheims_rut.usx +26 -0
- package/test/test_data/usx/esg3.usx +47 -0
- package/test/test_data/usx/fig.usx +6 -0
- package/test/test_data/usx/milestone_attributes.usx +11 -0
- package/test/test_data/usx/not_nfc18_glo.usx +9 -0
- package/test/test_data/usx/not_nfc18_phm.usx +24 -0
- package/test/test_data/usx/opt_break.usx +10 -0
- package/test/test_data/usx/sidebars.usx +29 -0
- package/test/test_data/usx/table.usx +23 -0
- package/test/test_data/usx/web_psa.usx +8489 -0
- package/test/test_data/usx/web_psa150.usx +33 -0
- package/test/test_data/usx/web_psa_40_60.usx +1079 -0
- package/test/test_data/usx/web_rut.usx +95 -0
- package/test/test_data/usx/web_rut_1.usx +17 -0
- package/test/test_data/utils/douay_rheims.vrs +520 -0
- package/test/test_data/utils/douay_rheims_PSA.usx +5366 -0
- package/test/test_data/utils/serialize_example.json +91 -0
- package/test/test_data/utils/truncated_versification.vrs +29 -0
- package/test/test_data/utils/web_rut_items.json +2977 -0
- package/test/test_data/utils/webbe.vrs +395 -0
- package/test/test_data/utils/webbe_PSA.usx +8489 -0
- package/test/test_data/vrs/douay_rheims.vrs +520 -0
- package/test/test_data/vrs/truncated_versification.vrs +27 -0
- package/test/test_data/vrs/webbe.vrs +397 -0
- package/webpack.prod.js +50 -0
- package/dist/index.js +0 -8
- package/dist/index.js.LICENSE.txt +0 -23
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const test = require('tape');
|
|
3
|
+
const fse = require('fs-extra');
|
|
4
|
+
const { Proskomma } = require('../../../src/index.cjs');
|
|
5
|
+
const { pkWithDocs } = require('../../lib/load.js');
|
|
6
|
+
const { blocksSpec2Query } = require('../../../src/util/scriptlike/blocksSpec.cjs');
|
|
7
|
+
|
|
8
|
+
const testGroup = 'Mutate Add Operations';
|
|
9
|
+
|
|
10
|
+
const pk = new Proskomma();
|
|
11
|
+
let content = fse.readFileSync(
|
|
12
|
+
path.resolve(__dirname, '../../test_data/usx/web_rut.usx'),
|
|
13
|
+
).toString();
|
|
14
|
+
|
|
15
|
+
test(
|
|
16
|
+
`Document (${testGroup})`,
|
|
17
|
+
async function (t) {
|
|
18
|
+
try {
|
|
19
|
+
t.plan(10);
|
|
20
|
+
let query = '{ docSets { id } }';
|
|
21
|
+
let result = await pk.gqlQuery(query);
|
|
22
|
+
t.equal(result.errors, undefined);
|
|
23
|
+
t.equal(result.data.docSets.length, 0);
|
|
24
|
+
query = `mutation { addDocument(` +
|
|
25
|
+
`selectors: [{key: "lang", value: "eng"}, {key: "abbr", value: "ust"}], ` +
|
|
26
|
+
`contentType: "usx", ` +
|
|
27
|
+
`content: """${content}"""` +
|
|
28
|
+
`tags: ["foo", "baa"]) }`;
|
|
29
|
+
result = await pk.gqlQuery(query);
|
|
30
|
+
t.equal(result.errors, undefined);
|
|
31
|
+
t.equal(result.data.addDocument, true);
|
|
32
|
+
query = '{ docSets { id documents { id tags mainSequence { nBlocks } } } }';
|
|
33
|
+
result = await pk.gqlQuery(query);
|
|
34
|
+
t.equal(result.data.docSets.length, 1);
|
|
35
|
+
t.equal(result.data.docSets[0].documents.length, 1);
|
|
36
|
+
t.ok(result.data.docSets[0].documents[0].mainSequence.nBlocks > 0);
|
|
37
|
+
t.equal(result.data.docSets[0].documents[0].tags.length, 2);
|
|
38
|
+
t.ok(result.data.docSets[0].documents[0].tags.includes('foo'));
|
|
39
|
+
t.ok(result.data.docSets[0].documents[0].tags.includes('baa'));
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.log(err);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
test(
|
|
47
|
+
`Sequence (${testGroup})`,
|
|
48
|
+
async function (t) {
|
|
49
|
+
try {
|
|
50
|
+
t.plan(9);
|
|
51
|
+
let query = '{ documents { id nSequences sequences { id type } } }';
|
|
52
|
+
let result = await pk.gqlQuery(query);
|
|
53
|
+
t.equal(result.errors, undefined);
|
|
54
|
+
const docId = result.data.documents[0].id;
|
|
55
|
+
const nSequences = result.data.documents[0].nSequences;
|
|
56
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'banana').length, 0);
|
|
57
|
+
query = `mutation { newSequence(` +
|
|
58
|
+
` documentId: "${docId}"` +
|
|
59
|
+
` type: "banana"` +
|
|
60
|
+
` tags: ["yellow", "tasty"]) }`;
|
|
61
|
+
result = await pk.gqlQuery(query);
|
|
62
|
+
t.equal(result.errors, undefined);
|
|
63
|
+
const newSequenceId = result.data.newSequence;
|
|
64
|
+
query = '{ documents { id nSequences sequences { id type tags } } }';
|
|
65
|
+
result = await pk.gqlQuery(query);
|
|
66
|
+
t.equal(result.errors, undefined);
|
|
67
|
+
t.equal(result.data.documents[0].nSequences, nSequences + 1);
|
|
68
|
+
const bananaSequence = result.data.documents[0].sequences.filter(s => s.type === 'banana');
|
|
69
|
+
t.equal(bananaSequence.length, 1);
|
|
70
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.id === newSequenceId).length, 1);
|
|
71
|
+
t.ok(bananaSequence[0].tags.includes('yellow'));
|
|
72
|
+
t.ok(bananaSequence[0].tags.includes('tasty'));
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.log(err);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
test(
|
|
80
|
+
`Sequence with graft (${testGroup})`,
|
|
81
|
+
async function (t) {
|
|
82
|
+
try {
|
|
83
|
+
t.plan(8);
|
|
84
|
+
let query = '{ documents { id nSequences sequences { id type } } }';
|
|
85
|
+
let result = await pk.gqlQuery(query);
|
|
86
|
+
t.equal(result.errors, undefined);
|
|
87
|
+
const docId = result.data.documents[0].id;
|
|
88
|
+
const nSequences = result.data.documents[0].nSequences;
|
|
89
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'table').length, 0);
|
|
90
|
+
query = `mutation { newSequence(` +
|
|
91
|
+
` documentId: "${docId}"` +
|
|
92
|
+
` type: "table"` +
|
|
93
|
+
` graftToMain: true) }`;
|
|
94
|
+
result = await pk.gqlQuery(query);
|
|
95
|
+
t.equal(result.errors, undefined);
|
|
96
|
+
const newSequenceId = result.data.newSequence;
|
|
97
|
+
query = '{ documents { id mainSequence { id blocks { bg { payload } } } nSequences sequences { id type } } }';
|
|
98
|
+
result = await pk.gqlQuery(query);
|
|
99
|
+
t.equal(result.errors, undefined);
|
|
100
|
+
t.equal(result.data.documents[0].nSequences, nSequences + 1);
|
|
101
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'table').length, 1);
|
|
102
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.id === newSequenceId).length, 1);
|
|
103
|
+
const mainSequenceFirstBlockGrafts = result.data.documents[0].mainSequence.blocks[0].bg.map(g => g.payload);
|
|
104
|
+
t.ok(mainSequenceFirstBlockGrafts.includes(newSequenceId));
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.log(err);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
test(
|
|
112
|
+
`Sequence with block content (${testGroup})`,
|
|
113
|
+
async function (t) {
|
|
114
|
+
try {
|
|
115
|
+
t.plan(8);
|
|
116
|
+
const blocksSpec = fse.readJSONSync(path.resolve(__dirname, '../../test_data/inputBlockSpec/mk1.json'));
|
|
117
|
+
const blockQuery = blocksSpec2Query(blocksSpec);
|
|
118
|
+
let query = '{ documents { id nSequences sequences { id type } } }';
|
|
119
|
+
let result = await pk.gqlQuery(query);
|
|
120
|
+
t.equal(result.errors, undefined);
|
|
121
|
+
const docId = result.data.documents[0].id;
|
|
122
|
+
const nSequences = result.data.documents[0].nSequences;
|
|
123
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.type === 'table').length, 1);
|
|
124
|
+
query = `mutation { newSequence(` +
|
|
125
|
+
` documentId: "${docId}"` +
|
|
126
|
+
` type: "randomText"` +
|
|
127
|
+
` blocksSpec: ${blockQuery}` +
|
|
128
|
+
` graftToMain: true) }`;
|
|
129
|
+
result = await pk.gqlQuery(query);
|
|
130
|
+
t.equal(result.errors, undefined);
|
|
131
|
+
const newSequenceId = result.data.newSequence;
|
|
132
|
+
query = '{ documents { id nSequences sequences { id type blocks { text } } } }';
|
|
133
|
+
result = await pk.gqlQuery(query);
|
|
134
|
+
t.equal(result.errors, undefined);
|
|
135
|
+
t.equal(result.data.documents[0].nSequences, nSequences + 1);
|
|
136
|
+
const newSequence = result.data.documents[0].sequences.filter(s => s.id === newSequenceId)[0];
|
|
137
|
+
t.equal(result.data.documents[0].sequences.filter(s => s.id === newSequenceId).length, 1);
|
|
138
|
+
t.equal(newSequence.type, 'randomText');
|
|
139
|
+
t.ok(newSequence.blocks[0].text.startsWith('Start of the Good News'));
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.log(err);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
test(
|
|
147
|
+
`Block (${testGroup})`,
|
|
148
|
+
async function (t) {
|
|
149
|
+
try {
|
|
150
|
+
t.plan(7);
|
|
151
|
+
const pk = pkWithDocs(
|
|
152
|
+
[
|
|
153
|
+
['../test_data/usfm/1pe_webbe.usfm', {
|
|
154
|
+
lang: 'eng',
|
|
155
|
+
abbr: 'web',
|
|
156
|
+
}],
|
|
157
|
+
],
|
|
158
|
+
);
|
|
159
|
+
let query = '{ documents { id mainSequence { id nBlocks } } }';
|
|
160
|
+
let result = await pk.gqlQuery(query);
|
|
161
|
+
t.equal(result.errors, undefined);
|
|
162
|
+
const docId = result.data.documents[0].id;
|
|
163
|
+
const seqId = result.data.documents[0].mainSequence.id;
|
|
164
|
+
const nBlocks = result.data.documents[0].mainSequence.nBlocks;
|
|
165
|
+
t.equal(nBlocks, 3);
|
|
166
|
+
query = `mutation { newBlock(documentId: "${docId}" sequenceId: "${seqId}" blockN: 1, blockScope: "blockTag/q4") }`;
|
|
167
|
+
result = await pk.gqlQuery(query);
|
|
168
|
+
t.equal(result.errors, undefined);
|
|
169
|
+
t.equal(result.data.newBlock, true);
|
|
170
|
+
query = '{ documents { id mainSequence { id nBlocks blocks(positions:[1]) { bs { payload } } } } }';
|
|
171
|
+
result = await pk.gqlQuery(query);
|
|
172
|
+
t.equal(result.errors, undefined);
|
|
173
|
+
t.equal(result.data.documents[0].mainSequence.nBlocks, nBlocks + 1);
|
|
174
|
+
t.equal(result.data.documents[0].mainSequence.blocks[0].bs.payload, 'blockTag/q4');
|
|
175
|
+
} catch (err) {
|
|
176
|
+
console.log(err);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
);
|
|
180
|
+
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const test = require('tape');
|
|
3
|
+
const fse = require('fs-extra');
|
|
4
|
+
const {
|
|
5
|
+
pkWithDoc,
|
|
6
|
+
pkWithDocs,
|
|
7
|
+
} = require('../../lib/load.js');
|
|
8
|
+
|
|
9
|
+
const testGroup = 'Mutate Delete Operations';
|
|
10
|
+
|
|
11
|
+
test(
|
|
12
|
+
`DocSet (${testGroup})`,
|
|
13
|
+
async function (t) {
|
|
14
|
+
try {
|
|
15
|
+
t.plan(9);
|
|
16
|
+
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
17
|
+
lang: 'eng',
|
|
18
|
+
abbr: 'ust',
|
|
19
|
+
}, {}, {}, [], [])[0];
|
|
20
|
+
let query = '{ docSets { id } }';
|
|
21
|
+
let result = await pk.gqlQuery(query);
|
|
22
|
+
t.equal(result.errors, undefined);
|
|
23
|
+
t.equal(result.data.docSets.length, 1);
|
|
24
|
+
query = `mutation { deleteDocSet(docSetId: "foo/baa") }`;
|
|
25
|
+
result = await pk.gqlQuery(query);
|
|
26
|
+
t.equal(result.errors, undefined);
|
|
27
|
+
t.equal(result.data.deleteDocSet, false);
|
|
28
|
+
query = '{ docSets { id } }';
|
|
29
|
+
result = await pk.gqlQuery(query);
|
|
30
|
+
t.equal(result.data.docSets.length, 1);
|
|
31
|
+
query = `mutation { deleteDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
32
|
+
result = await pk.gqlQuery(query);
|
|
33
|
+
t.equal(result.errors, undefined);
|
|
34
|
+
t.equal(result.data.deleteDocSet, true);
|
|
35
|
+
query = '{ nDocSets nDocuments }';
|
|
36
|
+
result = await pk.gqlQuery(query);
|
|
37
|
+
t.equal(result.data.nDocSets, 0);
|
|
38
|
+
t.equal(result.data.nDocuments, 0);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.log(err);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
test(
|
|
46
|
+
`Reload Deleted DocSet (${testGroup})`,
|
|
47
|
+
async function (t) {
|
|
48
|
+
try {
|
|
49
|
+
t.plan(3);
|
|
50
|
+
const selectors = {
|
|
51
|
+
lang: 'eng',
|
|
52
|
+
abbr: 'ust',
|
|
53
|
+
};
|
|
54
|
+
const pk = pkWithDoc('../test_data/usx/web_rut.usx', selectors, {}, {}, [], [])[0];
|
|
55
|
+
let query = '{ docSets { id } }';
|
|
56
|
+
let result = await pk.gqlQuery(query);
|
|
57
|
+
query = `mutation { deleteDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
58
|
+
result = await pk.gqlQuery(query);
|
|
59
|
+
query = '{ docSets { id } nDocuments}';
|
|
60
|
+
result = await pk.gqlQuery(query);
|
|
61
|
+
t.equal(result.data.docSets.length, 0);
|
|
62
|
+
t.equal(result.data.nDocuments, 0);
|
|
63
|
+
const content = fse.readFileSync(path.resolve(__dirname, '../../test_data/usx/web_rut.usx'));
|
|
64
|
+
|
|
65
|
+
t.doesNotThrow(
|
|
66
|
+
() => pk.importDocument(
|
|
67
|
+
selectors,
|
|
68
|
+
'usx',
|
|
69
|
+
content,
|
|
70
|
+
{},
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.log(err);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
test(
|
|
80
|
+
`Document (${testGroup})`,
|
|
81
|
+
async function (t) {
|
|
82
|
+
try {
|
|
83
|
+
t.plan(9);
|
|
84
|
+
const pk = pkWithDocs(
|
|
85
|
+
[
|
|
86
|
+
['../test_data/usx/web_rut.usx', {
|
|
87
|
+
lang: 'eng',
|
|
88
|
+
abbr: 'ust',
|
|
89
|
+
}],
|
|
90
|
+
['../test_data/usx/web_psa150.usx', {
|
|
91
|
+
lang: 'eng',
|
|
92
|
+
abbr: 'ust',
|
|
93
|
+
}],
|
|
94
|
+
],
|
|
95
|
+
);
|
|
96
|
+
let query = '{ docSets { id documents { id } } }';
|
|
97
|
+
let result = await pk.gqlQuery(query);
|
|
98
|
+
t.equal(result.errors, undefined);
|
|
99
|
+
t.equal(result.data.docSets.length, 1);
|
|
100
|
+
t.equal(result.data.docSets[0].documents.length, 2);
|
|
101
|
+
const aDocumentId = result.data.docSets[0].documents[0].id;
|
|
102
|
+
query = `mutation { deleteDocument(docSetId: "${result.data.docSets[0].id}", documentId: "foobaa") }`;
|
|
103
|
+
result = await pk.gqlQuery(query);
|
|
104
|
+
t.equal(result.errors, undefined);
|
|
105
|
+
t.equal(result.data.deleteDocument, false);
|
|
106
|
+
query = '{ docSets { id documents { id } } }';
|
|
107
|
+
result = await pk.gqlQuery(query);
|
|
108
|
+
t.equal(result.data.docSets[0].documents.length, 2);
|
|
109
|
+
query = `mutation { deleteDocument(docSetId: "${result.data.docSets[0].id}", documentId: "${aDocumentId}") }`;
|
|
110
|
+
result = await pk.gqlQuery(query);
|
|
111
|
+
t.equal(result.errors, undefined);
|
|
112
|
+
t.equal(result.data.deleteDocument, true);
|
|
113
|
+
query = '{ docSets { id documents { id } } }';
|
|
114
|
+
result = await pk.gqlQuery(query);
|
|
115
|
+
t.equal(result.data.docSets.length, 1);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.log(err);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
test(
|
|
123
|
+
`Inline Sequence (${testGroup})`,
|
|
124
|
+
async function (t) {
|
|
125
|
+
try {
|
|
126
|
+
t.plan(12);
|
|
127
|
+
const pk = pkWithDocs(
|
|
128
|
+
[
|
|
129
|
+
['../test_data/usx/web_rut.usx', {
|
|
130
|
+
lang: 'eng',
|
|
131
|
+
abbr: 'ust',
|
|
132
|
+
}],
|
|
133
|
+
],
|
|
134
|
+
);
|
|
135
|
+
let query = '{ documents { id nSequences mainSequence { id blocks(positions:[0]) { items { type subType payload } } } } }';
|
|
136
|
+
let result = await pk.gqlQuery(query);
|
|
137
|
+
t.equal(result.errors, undefined);
|
|
138
|
+
t.equal(result.data.documents.length, 1);
|
|
139
|
+
const docId = result.data.documents[0].id;
|
|
140
|
+
const nSequences = result.data.documents[0].nSequences;
|
|
141
|
+
const items = result.data.documents[0].mainSequence.blocks[0].items;
|
|
142
|
+
const mainId = result.data.documents[0].mainSequence.id;
|
|
143
|
+
const graft = items.filter(i => i.type === 'graft')[0];
|
|
144
|
+
query = `mutation { deleteSequence(documentId: "foo" sequenceId: "${graft.payload}") }`;
|
|
145
|
+
result = await pk.gqlQuery(query);
|
|
146
|
+
t.equal(result.errors.length, 1);
|
|
147
|
+
t.ok(result.errors[0].message.startsWith('Document \'foo\' not found'));
|
|
148
|
+
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "${mainId}") }`;
|
|
149
|
+
result = await pk.gqlQuery(query);
|
|
150
|
+
t.equal(result.errors.length, 1);
|
|
151
|
+
t.ok(result.errors[0].message.startsWith('Cannot delete main sequence'));
|
|
152
|
+
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "baa") }`;
|
|
153
|
+
result = await pk.gqlQuery(query);
|
|
154
|
+
t.equal(result.errors, undefined);
|
|
155
|
+
t.equal(result.data.deleteSequence, false);
|
|
156
|
+
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "${graft.payload}") }`;
|
|
157
|
+
result = await pk.gqlQuery(query);
|
|
158
|
+
t.equal(result.errors, undefined);
|
|
159
|
+
t.equal(result.data.deleteSequence, true);
|
|
160
|
+
query = '{ documents { id nSequences mainSequence { id blocks(positions:[0]) { items { type subType payload } } } } }';
|
|
161
|
+
result = await pk.gqlQuery(query);
|
|
162
|
+
t.equal(result.errors, undefined);
|
|
163
|
+
t.equal(result.data.documents[0].nSequences, nSequences - 2);
|
|
164
|
+
} catch (err) {
|
|
165
|
+
console.log(err);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
test(
|
|
171
|
+
`Block-Grafted Sequence (${testGroup})`,
|
|
172
|
+
async function (t) {
|
|
173
|
+
try {
|
|
174
|
+
t.plan(6);
|
|
175
|
+
const pk = pkWithDocs(
|
|
176
|
+
[
|
|
177
|
+
['../test_data/usx/not_nfc18_phm.usx', {
|
|
178
|
+
lang: 'fra',
|
|
179
|
+
abbr: 'nfc18',
|
|
180
|
+
}],
|
|
181
|
+
],
|
|
182
|
+
);
|
|
183
|
+
let query = '{ documents { id nSequences mainSequence { id blocks(positions:[0]) { bg { subType payload } } } } }';
|
|
184
|
+
let result = await pk.gqlQuery(query);
|
|
185
|
+
t.equal(result.errors, undefined);
|
|
186
|
+
t.equal(result.data.documents.length, 1);
|
|
187
|
+
const docId = result.data.documents[0].id;
|
|
188
|
+
const nSequences = result.data.documents[0].nSequences;
|
|
189
|
+
const graftSeqId = result.data.documents[0].mainSequence.blocks[0].bg[0].payload;
|
|
190
|
+
query = `mutation { deleteSequence(documentId: "${docId}" sequenceId: "${graftSeqId}") }`;
|
|
191
|
+
result = await pk.gqlQuery(query);
|
|
192
|
+
t.equal(result.errors, undefined);
|
|
193
|
+
t.equal(result.data.deleteSequence, true);
|
|
194
|
+
query = '{ documents { id nSequences } }';
|
|
195
|
+
result = await pk.gqlQuery(query);
|
|
196
|
+
t.equal(result.errors, undefined);
|
|
197
|
+
t.equal(result.data.documents[0].nSequences, nSequences - 1);
|
|
198
|
+
} catch (err) {
|
|
199
|
+
console.log(err);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
test(
|
|
205
|
+
`Block (${testGroup})`,
|
|
206
|
+
async function (t) {
|
|
207
|
+
try {
|
|
208
|
+
t.plan(6);
|
|
209
|
+
const pk = pkWithDocs(
|
|
210
|
+
[
|
|
211
|
+
['../test_data/usfm/1pe_webbe.usfm', {
|
|
212
|
+
lang: 'eng',
|
|
213
|
+
abbr: 'web',
|
|
214
|
+
}],
|
|
215
|
+
],
|
|
216
|
+
);
|
|
217
|
+
let query = '{ documents { id mainSequence { id nBlocks } } }';
|
|
218
|
+
let result = await pk.gqlQuery(query);
|
|
219
|
+
t.equal(result.errors, undefined);
|
|
220
|
+
const docId = result.data.documents[0].id;
|
|
221
|
+
const seqId = result.data.documents[0].mainSequence.id;
|
|
222
|
+
const nBlocks = result.data.documents[0].mainSequence.nBlocks;
|
|
223
|
+
t.equal(nBlocks, 3);
|
|
224
|
+
query = `mutation { deleteBlock(documentId: "${docId}" sequenceId: "${seqId}" blockN: 1) }`;
|
|
225
|
+
result = await pk.gqlQuery(query);
|
|
226
|
+
t.equal(result.errors, undefined);
|
|
227
|
+
t.equal(result.data.deleteBlock, true);
|
|
228
|
+
query = '{ documents { id mainSequence { id nBlocks blocks { items { type subType payload } } } } }';
|
|
229
|
+
result = await pk.gqlQuery(query);
|
|
230
|
+
t.equal(result.errors, undefined);
|
|
231
|
+
t.equal(result.data.documents[0].mainSequence.nBlocks, nBlocks - 1);
|
|
232
|
+
} catch (err) {
|
|
233
|
+
console.log(err);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const test = require('tape');
|
|
3
|
+
const fse = require('fs-extra');
|
|
4
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
5
|
+
|
|
6
|
+
const pk = pkWithDoc('../test_data/usx/web_psa150.usx', {
|
|
7
|
+
lang: 'eng',
|
|
8
|
+
abbr: 'web',
|
|
9
|
+
}, {}, {}, [], [])[0];
|
|
10
|
+
|
|
11
|
+
const testGroup = 'Rehash';
|
|
12
|
+
|
|
13
|
+
test(
|
|
14
|
+
`One Document (${testGroup})`,
|
|
15
|
+
async function (t) {
|
|
16
|
+
try {
|
|
17
|
+
t.plan(8);
|
|
18
|
+
let query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
19
|
+
let result = await pk.gqlQuery(query);
|
|
20
|
+
t.equal(result.errors, undefined);
|
|
21
|
+
t.equal(result.data.docSets.length, 1);
|
|
22
|
+
const nMainSequenceBlocks = result.data.docSets[0].documents[0].mainSequence.nBlocks;
|
|
23
|
+
query = `mutation { rehashDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
24
|
+
result = await pk.gqlQuery(query);
|
|
25
|
+
t.equal(result.errors, undefined);
|
|
26
|
+
t.equal(result.data.rehashDocSet, true);
|
|
27
|
+
query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
28
|
+
result = await pk.gqlQuery(query);
|
|
29
|
+
t.equal(result.errors, undefined);
|
|
30
|
+
t.equal(result.data.docSets.length, 1);
|
|
31
|
+
t.equal(result.data.docSets[0].documents.length, 1);
|
|
32
|
+
t.equal(result.data.docSets[0].documents[0].mainSequence.nBlocks, nMainSequenceBlocks);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.log(err);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
test(
|
|
40
|
+
`After adding document (${testGroup})`,
|
|
41
|
+
async function (t) {
|
|
42
|
+
try {
|
|
43
|
+
t.plan(6);
|
|
44
|
+
let query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
45
|
+
let result = await pk.gqlQuery(query);
|
|
46
|
+
t.equal(result.errors, undefined);
|
|
47
|
+
t.equal(result.data.docSets.length, 1);
|
|
48
|
+
// const firstDocumentId = result.data.docSets[0].documents[0].id;
|
|
49
|
+
// const nMainSequenceBlocks = result.data.docSets[0].documents[0].mainSequence.nBlocks;
|
|
50
|
+
const content = fse.readFileSync(path.resolve(__dirname, '../../test_data/usx/web_rut.usx'));
|
|
51
|
+
|
|
52
|
+
pk.importDocument({
|
|
53
|
+
lang: 'eng',
|
|
54
|
+
abbr: 'web',
|
|
55
|
+
}, 'usx', content);
|
|
56
|
+
query = `mutation { rehashDocSet(docSetId: "${result.data.docSets[0].id}") }`;
|
|
57
|
+
result = await pk.gqlQuery(query);
|
|
58
|
+
t.equal(result.errors, undefined);
|
|
59
|
+
t.equal(result.data.rehashDocSet, true);
|
|
60
|
+
query = '{ docSets { id documents { id mainSequence { nBlocks blocks { dump } } } } }';
|
|
61
|
+
result = await pk.gqlQuery(query);
|
|
62
|
+
t.equal(result.errors, undefined);
|
|
63
|
+
t.equal(result.data.docSets[0].documents.length, 2);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.log(err);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
3
|
+
|
|
4
|
+
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
5
|
+
lang: 'eng',
|
|
6
|
+
abbr: 'ust',
|
|
7
|
+
}, {}, {}, [], [])[0];
|
|
8
|
+
|
|
9
|
+
const testGroup = 'Mutate Tags';
|
|
10
|
+
|
|
11
|
+
test(
|
|
12
|
+
`DocSet (${testGroup})`,
|
|
13
|
+
async function (t) {
|
|
14
|
+
try {
|
|
15
|
+
t.plan(6);
|
|
16
|
+
let query = '{ docSets { id tags } }';
|
|
17
|
+
let result = await pk.gqlQuery(query);
|
|
18
|
+
t.equal(result.errors, undefined);
|
|
19
|
+
const docSet = result.data.docSets[0];
|
|
20
|
+
t.equal(docSet.tags.length, 0);
|
|
21
|
+
query = `mutation { addDocSetTags(docSetId: "${docSet.id}", tags: ["foo", "baa"]) }`;
|
|
22
|
+
result = await pk.gqlQuery(query);
|
|
23
|
+
t.equal(result.data.addDocSetTags.length, 2);
|
|
24
|
+
query = `mutation { addDocSetTags(docSetId: "${docSet.id}", tags: ["foo", "frob"]) }`;
|
|
25
|
+
result = await pk.gqlQuery(query);
|
|
26
|
+
t.equal(result.data.addDocSetTags.length, 3);
|
|
27
|
+
query = `mutation { removeDocSetTags(docSetId: "${docSet.id}", tags: ["baa", "frob"]) }`;
|
|
28
|
+
result = await pk.gqlQuery(query);
|
|
29
|
+
t.equal(result.data.removeDocSetTags.length, 1);
|
|
30
|
+
t.ok(result.data.removeDocSetTags.includes('foo'));
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.log(err);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
test(
|
|
38
|
+
`Document (${testGroup})`,
|
|
39
|
+
async function (t) {
|
|
40
|
+
try {
|
|
41
|
+
t.plan(6);
|
|
42
|
+
let query = '{ docSets { id documents { id tags } } }';
|
|
43
|
+
let result = await pk.gqlQuery(query);
|
|
44
|
+
t.equal(result.errors, undefined);
|
|
45
|
+
const docSet = result.data.docSets[0];
|
|
46
|
+
const document = docSet.documents[0];
|
|
47
|
+
t.equal(document.tags.length, 0);
|
|
48
|
+
query = `mutation { addDocumentTags(docSetId: "${docSet.id}", documentId: "${document.id}", tags: ["foo", "baa"]) }`;
|
|
49
|
+
result = await pk.gqlQuery(query);
|
|
50
|
+
t.equal(result.data.addDocumentTags.length, 2);
|
|
51
|
+
query = `mutation { addDocumentTags(docSetId: "${docSet.id}", documentId: "${document.id}", tags: ["foo", "frob"]) }`;
|
|
52
|
+
result = await pk.gqlQuery(query);
|
|
53
|
+
t.equal(result.data.addDocumentTags.length, 3);
|
|
54
|
+
query = `mutation { removeDocumentTags(docSetId: "${docSet.id}", documentId: "${document.id}", tags: ["baa", "frob"]) }`;
|
|
55
|
+
result = await pk.gqlQuery(query);
|
|
56
|
+
t.equal(result.data.removeDocumentTags.length, 1);
|
|
57
|
+
t.ok(result.data.removeDocumentTags.includes('foo'));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
console.log(err);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
test(
|
|
65
|
+
`Sequence (${testGroup})`,
|
|
66
|
+
async function (t) {
|
|
67
|
+
try {
|
|
68
|
+
t.plan(6);
|
|
69
|
+
let query = '{ docSets { id documents { id mainSequence { id tags } } } }';
|
|
70
|
+
let result = await pk.gqlQuery(query);
|
|
71
|
+
t.equal(result.errors, undefined);
|
|
72
|
+
const docSet = result.data.docSets[0];
|
|
73
|
+
const document = docSet.documents[0];
|
|
74
|
+
const sequence = document.mainSequence;
|
|
75
|
+
t.equal(sequence.tags.length, 0);
|
|
76
|
+
query = `mutation { addSequenceTags(docSetId: "${docSet.id}", documentId: "${document.id}", sequenceId: "${sequence.id}", tags: ["foo", "baa"]) }`;
|
|
77
|
+
result = await pk.gqlQuery(query);
|
|
78
|
+
t.equal(result.data.addSequenceTags.length, 2);
|
|
79
|
+
query = `mutation { addSequenceTags(docSetId: "${docSet.id}", documentId: "${document.id}", sequenceId: "${sequence.id}", tags: ["foo", "frob"]) }`;
|
|
80
|
+
result = await pk.gqlQuery(query);
|
|
81
|
+
t.equal(result.data.addSequenceTags.length, 3);
|
|
82
|
+
query = `mutation { removeSequenceTags(docSetId: "${docSet.id}", documentId: "${document.id}", sequenceId: "${sequence.id}", tags: ["baa", "frob"]) }`;
|
|
83
|
+
result = await pk.gqlQuery(query);
|
|
84
|
+
t.equal(result.data.removeSequenceTags.length, 1);
|
|
85
|
+
t.ok(result.data.removeSequenceTags.includes('foo'));
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.log(err);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
);
|