Remove hack to prevent vanishing statistics button when modifying the builder object on root
Change-Id: I89d7df6d303983918e16b8b04b34895df5466897
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index b60dc5d..3edfdf8 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -424,6 +424,10 @@
});
it('should be deserializable', function () {
+
+ // Reset list
+ KorAP._vcKeyMenu = menuClass.create([['referTo','ref']]);
+
var docGroup = docGroupFactory.create();
expect(docGroup.operation()).toEqual("and");
expect(docGroup.operands().length).toEqual(2);
@@ -471,7 +475,7 @@
var op3 = docGroup.getOperand(2);
expect(op3.ldType()).toEqual("docGroup");
expect(op3.operation()).toEqual("or");
-
+
var op4 = op3.getOperand(0);
expect(op4.ldType()).toEqual("doc");
expect(op4.type()).toEqual("string");
@@ -750,14 +754,13 @@
["pubDate", "date"]
]);
expect(vc.toQuery()).toEqual("");
- expect(vc.element().firstChild.textContent).toEqual("⋯");
- vc.element().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.textContent).toEqual("⋯");
+ vc.builder().firstChild.firstChild.click();
// Click on pubDate
vc.element().firstChild.getElementsByTagName("LI")[1].click();
-
- expect(vc.element().firstChild.firstChild.textContent).toEqual("pubDate");
- expect(vc.element().firstChild.children[1].getAttribute("data-type")).toEqual("date");
+ expect(vc.builder().firstChild.firstChild.textContent).toEqual("pubDate");
+ expect(vc.builder().firstChild.children[1].getAttribute("data-type")).toEqual("date");
});
});
@@ -800,7 +803,7 @@
});
expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
- var vcE = vc.element();
+ var vcE = vc.builder();
expect(vcE.firstChild.children.length).toEqual(4);
// Click to delete
@@ -831,7 +834,7 @@
expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
- var vcE = vc.element();
+ var vcE = vc.builder();
expect(vcE.firstChild.children.length).toEqual(4);
// Click to delete
@@ -1149,9 +1152,9 @@
"ref":"myCorpus"
});
- // iv class="doc groupref"><span class="key fixed">referTo</span><span data-type="string" class="value">myCorpus</span>
- var vcE = vc.element();
- expect(vcE.getAttribute('class')).toEqual('vc');
+ // iv class="doc groupref"><span class="key fixed">@referTo</span><span data-type="string" class="value">myCorpus</span>
+ var vcE = vc.builder();
+ expect(vcE.getAttribute('class')).toEqual('builder');
expect(vcE.firstChild.tagName).toEqual('DIV');
expect(vcE.firstChild.classList.contains('groupref')).toBeTruthy();
@@ -1170,15 +1173,15 @@
it('should be based on a nested docGroup', function () {
var vc = nestedGroupFactory.create();
- expect(vc.element().getAttribute('class')).toEqual('vc');
- expect(vc.element().firstChild.getAttribute('class')).toEqual('docGroup');
- expect(vc.element().firstChild.children[0].getAttribute('class')).toEqual('doc');
- var dg = vc.element().firstChild.children[1];
+ expect(vc.builder().getAttribute('class')).toEqual('builder');
+ expect(vc.builder().firstChild.getAttribute('class')).toEqual('docGroup');
+ expect(vc.builder().firstChild.children[0].getAttribute('class')).toEqual('doc');
+ var dg = vc.builder().firstChild.children[1];
expect(dg.getAttribute('class')).toEqual('docGroup');
expect(dg.children[0].getAttribute('class')).toEqual('doc');
expect(dg.children[1].getAttribute('class')).toEqual('doc');
expect(dg.children[2].getAttribute('class')).toEqual('operators button-group');
- expect(vc.element().firstChild.children[2].getAttribute('class')).toEqual('operators button-group');
+ expect(vc.builder().firstChild.children[2].getAttribute('class')).toEqual('operators button-group');
});
it('should be based on a nested docGroupRef', function () {
@@ -1904,8 +1907,8 @@
expect(vc.root().operation()).toEqual('or');
// Operands and operators
- expect(vc.element().firstChild.children.length).toEqual(4);
- expect(vc.element().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
+ expect(vc.builder().firstChild.children.length).toEqual(4);
+ expect(vc.builder().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
// Remove inner group and flatten
_delOn(vc.root().getOperand(2).getOperand(0));
@@ -1917,8 +1920,8 @@
expect(vc.root().operation()).toEqual('or');
// Operands and operators
- expect(vc.element().firstChild.children.length).toEqual(5);
- expect(vc.element().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
+ expect(vc.builder().firstChild.children.length).toEqual(5);
+ expect(vc.builder().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
});
});
@@ -1981,7 +1984,7 @@
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- var fc = vc.element().firstChild;
+ var fc = vc.builder().firstChild;
expect(fc.getAttribute('data-operation')).toEqual('and');
expect(fc.children.length).toEqual(4);
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
@@ -1993,7 +1996,7 @@
_andOn(vc.root().getOperand(0));
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- fc = vc.element().firstChild;
+ fc = vc.builder().firstChild;
expect(fc.getAttribute('data-operation')).toEqual('and');
expect(fc.children.length).toEqual(5);
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
@@ -2045,7 +2048,7 @@
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- var fc = vc.element().firstChild;
+ var fc = vc.builder().firstChild;
expect(fc.children.length).toEqual(4);
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
expect(fc.children[0].getAttribute('class')).toEqual('doc');
@@ -2055,7 +2058,7 @@
// add with 'or' in the middle
_orOn(vc.root().getOperand(0));
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- fc = vc.element().firstChild;
+ fc = vc.builder().firstChild;
expect(fc.getAttribute('data-operation')).toEqual('and');
expect(fc.children.length).toEqual(4);
@@ -2066,7 +2069,7 @@
expect(fc.children[3].getAttribute('class')).toEqual('operators button-group');
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
- fc = vc.element().firstChild.firstChild;
+ fc = vc.builder().firstChild.firstChild;
expect(fc.children.length).toEqual(3);
expect(fc.children[0].getAttribute('class')).toEqual('doc');
expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
@@ -2074,7 +2077,7 @@
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
_orOn(vc.root().getOperand(2));
- fc = vc.element().firstChild;
+ fc = vc.builder().firstChild;
expect(fc.children.length).toEqual(4);
expect(fc.children[0].getAttribute('class')).toEqual('docGroup');
@@ -2082,7 +2085,7 @@
expect(fc.children[2].getAttribute('class')).toEqual('docGroup');
expect(fc.children[3].getAttribute('class')).toEqual('operators button-group');
- fc = vc.element().firstChild.children[2];
+ fc = vc.builder().firstChild.children[2];
expect(fc.children[0].getAttribute('class')).toEqual('doc groupref');
expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
expect(fc.children[2].getAttribute('class')).toEqual('operators button-group');
@@ -2584,14 +2587,14 @@
['b', 'string'],
['c', 'date']
]).fromJson();
- expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('SPAN');
+ expect(vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('SPAN');
// Click on unspecified
- vc.element().firstChild.firstChild.click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+ vc.builder().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('UL');
- var list = vc.element().firstChild.firstChild;
+ var list = vc.builder().firstChild.firstChild;
expect(list.getElementsByTagName("LI")[0].innerText).toEqual('referTo');
expect(list.getElementsByTagName("LI")[1].innerText).toEqual('a');
expect(list.getElementsByTagName("LI")[2].innerText).toEqual('b');
@@ -2602,14 +2605,14 @@
['e', 'string'],
['f', 'date']
]).fromJson();
- expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('SPAN');
+ expect(vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('SPAN');
// Click on unspecified
- vc.element().firstChild.firstChild.click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+ vc.builder().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('UL');
- list = vc.element().firstChild.firstChild;
+ list = vc.builder().firstChild.firstChild;
expect(list.getElementsByTagName("LI")[0].innerText).toEqual('referTo');
expect(list.getElementsByTagName("LI")[1].innerText).toEqual('d');
expect(list.getElementsByTagName("LI")[2].innerText).toEqual('e');
@@ -2627,30 +2630,30 @@
it('should be clickable on key', function () {
// Click on unspecified
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Click on "d"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[1].click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('SPAN');
- expect(vc.element().firstChild.firstChild.innerText).toEqual('d');
- expect(vc.element().firstChild.children[1].innerText).toEqual('eq');
- expect(vc.element().firstChild.children[1].getAttribute('data-type')).toEqual('text');
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[1].click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('SPAN');
+ expect(vc.builder().firstChild.firstChild.innerText).toEqual('d');
+ expect(vc.builder().firstChild.children[1].innerText).toEqual('eq');
+ expect(vc.builder().firstChild.children[1].getAttribute('data-type')).toEqual('text');
// blur
document.body.click();
});
it('should be clickable on operation for text', function () {
// Click on "d" (or unspecified)
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Choose "d"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[1].click();
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[1].click();
// Click on matchop
- vc.element().firstChild.children[1].click();
+ vc.builder().firstChild.children[1].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual('UL');
+ expect(vc.builder().firstChild.children[1].tagName).toEqual('UL');
- var ul = vc.element().firstChild.children[1];
+ var ul = vc.builder().firstChild.children[1];
expect(ul.getElementsByTagName('li')[0].innerText).toEqual("eq");
expect(ul.getElementsByTagName('li')[1].innerText).toEqual("ne");
expect(ul.getElementsByTagName('li')[2].innerText).toEqual("contains");
@@ -2659,48 +2662,47 @@
// Choose "contains"
ul.getElementsByTagName('li')[2].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual("SPAN");
- expect(vc.element().firstChild.children[1].innerText).toEqual("contains");
+ expect(vc.builder().firstChild.children[1].tagName).toEqual("SPAN");
+ expect(vc.builder().firstChild.children[1].innerText).toEqual("contains");
// blur
document.body.click();
})
it('should be clickable on operation for string', function () {
// Click on "d" (or unspecified)
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Choose "e"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[2].click();
-
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[2].click();
+
// As a consequence the matchoperator may no longer
// be valid and needs to be re-evaluated
- var fc = vc.element().firstChild;
-
+ var fc = vc.builder().firstChild;
expect(fc.firstChild.tagName).toEqual('SPAN');
expect(fc.firstChild.innerText).toEqual('e');
expect(fc.children[1].innerText).toEqual('eq');
expect(fc.children[1].getAttribute('data-type')).toEqual('string');
- vc.element().firstChild.children[1].click();
+ vc.builder().firstChild.children[1].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual('UL');
+ expect(vc.builder().firstChild.children[1].tagName).toEqual('UL');
- var ul = vc.element().firstChild.children[1];
+ var ul = vc.builder().firstChild.children[1];
expect(ul.getElementsByTagName('li')[0].innerText).toEqual("eq");
expect(ul.getElementsByTagName('li')[1].innerText).toEqual("ne");
expect(ul.getElementsByTagName('li')[2]).toBeUndefined();
// Choose "ne"
ul.getElementsByTagName('li')[1].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual("SPAN");
- expect(vc.element().firstChild.children[1].innerText).toEqual("ne");
+ expect(vc.builder().firstChild.children[1].tagName).toEqual("SPAN");
+ expect(vc.builder().firstChild.children[1].innerText).toEqual("ne");
// Click on text
- expect(vc.element().firstChild.children[2].innerText).toEqual("⋯");
- vc.element().firstChild.children[2].click();
+ expect(vc.builder().firstChild.children[2].innerText).toEqual("⋯");
+ vc.builder().firstChild.children[2].click();
// Blur text element
- expect(vc.element().firstChild.children[2].firstChild.value).toEqual('');
+ expect(vc.builder().firstChild.children[2].firstChild.value).toEqual('');
// blur
document.body.click();
@@ -2710,22 +2712,22 @@
// Replay matchop check - so it's guaranteed that "ne" is chosen
// Click on "e" (or unspecified)
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Rechoose "e"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[1].click();
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[1].click();
// Click on matchop
- vc.element().firstChild.children[1].click();
+ vc.builder().firstChild.children[1].click();
// Choose "ne"
- vc.element().firstChild.children[1].getElementsByTagName('li')[1].click();
- expect(vc.element().firstChild.children[1].innerText).toEqual("ne");
+ vc.builder().firstChild.children[1].getElementsByTagName('li')[1].click();
+ expect(vc.builder().firstChild.children[1].innerText).toEqual("ne");
// Click on "e"
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Choose "f"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[3].click();
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[3].click();
// The matchoperator should still be "ne" as this is valid for dates as well (now)
- var fc = vc.element().firstChild;
+ var fc = vc.builder().firstChild;
expect(fc.firstChild.tagName).toEqual('SPAN');
expect(fc.firstChild.innerText).toEqual('f');
expect(fc.children[1].innerText).toEqual('ne');
@@ -2746,7 +2748,7 @@
"value":"Baum"
});
- expect(vc.element().firstChild.children[1].getAttribute('data-type')).toEqual('text');
+ expect(vc.builder().firstChild.children[1].getAttribute('data-type')).toEqual('text');
});
});
@@ -2767,24 +2769,24 @@
['b', null],
['c', null]
]).fromJson();
- expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
+ expect(vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy();
// This should open up the menu
- vc.element().firstChild.firstChild.click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+ vc.builder().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('UL');
KorAP._vcKeyMenu._prefix.clear();
KorAP._vcKeyMenu._prefix.add('x');
- var prefElement = vc.element().querySelector('span.pref');
+ var prefElement = vc.builder().querySelector('span.pref');
expect(prefElement.innerText).toEqual('x');
// This should add key 'x' to VC
prefElement.click();
- expect(vc.element().firstChild.classList.contains('doc')).toBeTruthy();
- expect(vc.element().firstChild.firstChild.className).toEqual('key');
- expect(vc.element().firstChild.firstChild.innerText).toEqual('x');
+ expect(vc.builder().firstChild.classList.contains('doc')).toBeTruthy();
+ expect(vc.builder().firstChild.firstChild.className).toEqual('key');
+ expect(vc.builder().firstChild.firstChild.innerText).toEqual('x');
});
});
});