3 describe('egReporterTest', function() {
4 beforeEach(module('egCoreMod'));
5 beforeEach(module('egReportMod'));
6 beforeEach(module('egReporter'));
8 var reportEditCtrl, reportEditScope;
9 beforeEach(inject(function ($rootScope, $controller, $location, egIDL) {
11 reportEditScope = $rootScope.$new();
12 reportEditCtrl = $controller('ReporterTemplateEdit', {$scope: reportEditScope});
15 /** egReportTemplateSvc tests **/
16 describe('egReportTemplateSvcTests', function() {
18 it('egReportTemplateSvc should start with empty lists', inject(function(egReportTemplateSvc) {
19 expect(egReportTemplateSvc.display_fields.length).toEqual(0);
20 expect(egReportTemplateSvc.filter_fields.length).toEqual(0);
26 var display_fields = [{
27 "name": "family_name",
43 "pkey_sequence": "actor.usr_id_seq",
44 "core_label": "Core sources",
50 "path_label": "ILS User",
58 "name": "first_given_name",
59 "label": "First Name",
74 "pkey_sequence": "actor.usr_id_seq",
75 "core_label": "Core sources",
81 "path_label": "ILS User",
90 "label": "Note Content",
102 "table": "actor.usr",
105 "pkey_sequence": "actor.usr_id_seq",
106 "core_label": "Core sources",
112 "label": "User Notes",
116 "label": "User Notes",
121 "reltype": "has_many",
128 "label": "User Notes",
133 "reltype": "has_many",
139 "label": "User Note",
140 "table": "actor.usr_note",
142 "pkey_sequence": "actor.usr_note_id_seq",
143 "core_label": "Non-core sources",
146 "table": "actor.usr_note"
149 "path_label": "ILS User -> User Notes (left)",
158 describe('egReporterTemplateEditTests', function() {
159 it('initialize and set core source for ReporterTemplateEdit', inject(function(egIDL, egCore) {
163 expect(reportEditScope.class_tree.length).toEqual(0);
164 expect(reportEditScope.coreSourceChosen).toEqual(false);
167 reportEditScope.changeCoreSource('au');
168 expect(reportEditScope.coreSourceChosen).toEqual(true);
169 expect(reportEditScope.class_tree.length).toEqual(1);
173 it('LP#1721807: construct join key correctly when using virtual field', function() {
174 var tmpl = reportEditScope._mergePaths(display_fields);
175 expect(tmpl).toBeDefined();
176 expect(Object.keys(tmpl)).toContain('join');
177 expect(Object.keys(tmpl.join).length).toEqual(1);
178 var join_key = Object.keys(tmpl.join)[0];
179 var lcol = join_key.split(/-/)[0];
180 expect(lcol).toEqual('id');
185 /** template conversion tests **/
187 '{"version":4,"doc_url":"","core_class":"bre","select":[{"alias":"Title Proper (normalized)","field_doc":"","column":{"colname":"title","transform":"Bare","transform_label":"Raw Data"},"path":"bre-simple_record-rmsr-title","relation":"938089c53626281c03f9f40622093fcc"}],"from":{"path":"bre-simple_record","table":"biblio.record_entry","alias":"a0a5898f5f47b01a3943462dbf1c45ad","join":{"id-mfr-record-a0a5898f5f47b01a3943462dbf1c45ad":{"key":"record","type":"left","path":"bre-full_record_entries-mfr","table":"metabib.full_rec","label":"Bibliographic Record :: Flattened MARC Fields ","alias":"6da08cb48d3b764920485d2d40a4145c","idlclass":"mfr","template_path":"bre-full_record_entries"},"id-rmsr-id-a0a5898f5f47b01a3943462dbf1c45ad":{"key":"id","type":"left","path":"bre-simple_record-rmsr","table":"reporter.materialized_simple_record","label":"Bibliographic Record :: Simple Record Extracts ","alias":"938089c53626281c03f9f40622093fcc","idlclass":"rmsr","template_path":"bre-simple_record"}}},"where":[{"alias":"Tag","field_doc":"","column":{"colname":"tag","transform":"Bare","transform_label":"Raw Data"},"path":"bre-full_record_entries-mfr-tag","relation":"6da08cb48d3b764920485d2d40a4145c","condition":{"ilike":"::P0"}},{"alias":"Subfield","field_doc":"","column":{"colname":"subfield","transform":"Bare","transform_label":"Raw Data"},"path":"bre-full_record_entries-mfr-subfield","relation":"6da08cb48d3b764920485d2d40a4145c","condition":{"ilike":"::P1"}},{"alias":"Normalized Value","field_doc":"","column":{"colname":"value","transform":"Bare","transform_label":"Raw Data"},"path":"bre-full_record_entries-mfr-value","relation":"6da08cb48d3b764920485d2d40a4145c","condition":{"ilike":"::P2"}}],"having":[],"order_by":[],"rel_cache":{"order_by":[{"relation":"938089c53626281c03f9f40622093fcc","field":"title"}],"6da08cb48d3b764920485d2d40a4145c":{"label":"Bibliographic Record :: Flattened MARC Fields ","alias":"6da08cb48d3b764920485d2d40a4145c","path":"bre-full_record_entries","join":"","reltype":"has_many","idlclass":"mfr","table":"metabib.full_rec","fields":{"dis_tab":{},"filter_tab":{"tag":{"colname":"tag","transform":"Bare","aggregate":null,"params":null,"transform_label":"Raw Data","alias":"Tag","field_doc":"","join":"","datatype":"text","op":"ilike","op_label":"Contains Matching substring (ignore case)","op_value":{}},"subfield":{"colname":"subfield","transform":"Bare","aggregate":null,"params":null,"transform_label":"Raw Data","alias":"Subfield","field_doc":"","join":"","datatype":"text","op":"ilike","op_label":"Contains Matching substring (ignore case)","op_value":{}},"value":{"colname":"value","transform":"Bare","aggregate":null,"params":null,"transform_label":"Raw Data","alias":"Normalized Value","field_doc":"","join":"","datatype":"text","op":"ilike","op_label":"Contains Matching substring (ignore case)","op_value":{}}},"aggfilter_tab":{}}},"938089c53626281c03f9f40622093fcc":{"label":"Bibliographic Record :: Simple Record Extracts ","alias":"938089c53626281c03f9f40622093fcc","path":"bre-simple_record","join":"","reltype":"might_have","idlclass":"rmsr","table":"reporter.materialized_simple_record","fields":{"dis_tab":{"title":{"colname":"title","transform":"Bare","aggregate":null,"params":null,"transform_label":"Raw Data","alias":"Title Proper (normalized)","field_doc":"","join":"","datatype":"text","op":"=","op_label":"Equals","op_value":{}}},"filter_tab":{},"aggfilter_tab":{}}}}}'
190 describe('egReporterTemplateConversionTests', function() {
191 it('initialize for template conversion tests', inject(function(egIDL, egCore) {
194 it('test template conversion does not crash', inject(function(egIDL) {
195 angular.forEach(v4Templates, function(tmpl, i) {
196 var rt = new egIDL.rt();
198 rt.name('Test template #' + i);
199 rt.data = angular.fromJson(rt.data());
200 expect(rt.data.version).toBeLessThan(5);
201 reportEditScope.changeCoreSource(rt.data.core_class);
202 reportEditScope.upgradeTemplate(rt);
203 expect(rt.data.version).toEqual(5);