Skip to content

Commit 0c6abf2

Browse files
committed
TriggerScriptTest updates
1 parent 734ffd5 commit 0c6abf2

8 files changed

Lines changed: 327 additions & 494 deletions

File tree

Lines changed: 7 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,47 @@
1-
/*
2-
* Copyright (c) 2016-2017 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5-
*/
61
var shared = require("TriggerTestModule/EmployeeLib");
72
var console = require("console");
83

94
function managedColumns() {
10-
return {
11-
insert: ["Country"],
12-
update: ["Country"],
13-
};
5+
return shared.managedColumns();
146
}
157

168
function init(event, errors) {
179
console.log("init got triggered with event: " + event);
18-
console.log(shared.sampleFunc("this is from the shared function"));
1910
}
2011

2112
function beforeInsert(row, errors) {
2213
console.log("exp.data: beforeInsert: row is: " + row);
23-
var name = row.Name || row.name;
24-
if (name === "Managed Insert") {
25-
row.Country = "MANAGED-INS";
26-
} else if (name === "Managed Struct") {
27-
row.Country = "MANAGED-STRUCT";
28-
row.undeclaredCol = "bad";
29-
} else if (name === "Managed Struct Remove") {
30-
row.Country = "MANAGED-STRUCT-REM";
31-
delete row.Comments;
32-
delete row.comments;
33-
}
34-
35-
if (name === "Managed Unhandled") {
36-
delete row.Country;
37-
} else {
38-
if (row.Comments) {
39-
if (row.Comments === "Individual Test") {
40-
row.Country = "Inserting Single";
41-
row.Comments = "BeforeDelete"; //set this for next test step
42-
} else if (row.Comments === "Import Test") {
43-
row.Country = "Importing TSV";
44-
} else if (row.Comments === "API Test") {
45-
row.Country = "API BeforeInsert";
46-
}
47-
} else {
48-
if (row.comments === "Individual Test") {
49-
row.country = "Inserting Single";
50-
row.comments = "BeforeDelete"; //set this for next test step
51-
} else if (row.comments === "Import Test") {
52-
row.country = "Importing TSV";
53-
} else if (row.comments === "API Test") {
54-
row.country = "API BeforeInsert";
55-
}
56-
}
57-
if (!row.Country)
58-
row.Country = "DC-DEFAULT";
59-
}
14+
shared.beforeInsert(row, errors);
6015
console.log("exp.data: edited row is: " + row);
61-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
6216
}
6317

6418
function beforeUpdate(row, oldRow, errors) {
6519
console.log("exp.data: beforeUpdate: row is: " + row);
66-
var comments = row.Comments || row.comments;
67-
if (comments === "Managed Update") {
68-
row.Country = "MANAGED-UPD";
69-
}
70-
else if (comments === "Managed Struct") {
71-
row.Country = "MANAGED-STRUCT";
72-
row.undeclaredCol = "bad";
73-
}
74-
else if (comments === "Managed Struct Remove") {
75-
row.Country = "MANAGED-STRUCT-REM";
76-
delete row.Comments;
77-
}
78-
79-
if (comments === "Managed Unhandled") {
80-
delete row.Country;
81-
} else {
82-
if (row.Comments === "BeforeUpdate")
83-
row.Country = "Before Update changed me";
84-
else if (row.comments === "BeforeUpdate")
85-
row.country = "Before Update changed me";
86-
if (!row.Country)
87-
row.Country = "DC-DEFAULT-UPD";
88-
}
20+
shared.beforeUpdate(row, oldRow, errors);
8921
console.log("exp.data: old row is: " + oldRow);
90-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
9122
}
9223

9324
function beforeDelete(row, errors) {
9425
console.log("exp.data: beforeDelete: row is: " + row);
95-
if (row.comments === "BeforeDelete")
96-
errors[null] = "This is the Before Delete Error";
97-
98-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
26+
shared.beforeDelete(row, errors);
9927
}
10028

10129
function afterInsert(row, errors) {
10230
console.log("exp.data: afterInsert: row is: " + row);
103-
104-
if (row.comments === "AfterInsert")
105-
errors[null] = "This is the After Insert Error";
106-
107-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
31+
shared.afterInsert(row, errors);
10832
}
10933

11034
function afterUpdate(row, oldRow, errors) {
11135
console.log("exp.data: afterUpdate: row is: " + row);
112-
113-
if (row.comments === "AfterUpdate")
114-
errors[null] = "This is the After Update Error";
115-
36+
shared.afterUpdate(row, oldRow, errors);
11637
console.log("exp.data: old row is: " +oldRow);
117-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
11838
}
11939

12040
function afterDelete(row, errors) {
12141
console.log("exp.data: afterDelete: row is: " + row);
122-
123-
if (row.country === "Before Update changed me")
124-
errors[null] = "This is the After Delete Error";
125-
126-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
42+
shared.afterDelete(row, errors);
12743
}
12844

12945
function complete(event, errors) {
13046
console.log("exp.data: complete got triggered with event: " + event);
131-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
13247
}

modules/triggerTestModule/resources/queries/lists/Employees.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
* Copyright (c) 2016-2018 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5-
*/
6-
var shared = require("TriggerTestModule/EmployeeLib");
71
var console = require("console");
82

93
function managedColumns() {
@@ -16,7 +10,6 @@ function managedColumns() {
1610

1711
function init(event, errors) {
1812
console.log("init got triggered with event: " + event);
19-
console.log(shared.sampleFunc("this is from the shared function"));
2013
}
2114

2215
function beforeInsert(row, errors) {
@@ -48,12 +41,11 @@ function beforeInsert(row, errors) {
4841
row.boomeRANG = "Back at ya!";
4942
}
5043
console.log("list: edited row is: " + row);
51-
console.log(shared.sampleFunc("list: this is from the shared function"));
5244
}
5345

5446
function beforeUpdate(row, oldRow, errors) {
5547
console.log("list: beforeUpdate: row is: " + row);
56-
if (row.name === "Emp 3" || row.name === "Emp 8")
48+
if (row.company === "Company Up")
5749
row.company = "Before Update changed me";
5850
else if (row.name === "Managed Update") {
5951
row.company = "Managed Co";
@@ -80,47 +72,37 @@ function beforeUpdate(row, oldRow, errors) {
8072
row.boomeRANG = "Back at me!";
8173
}
8274
console.log("list: old row is: " + oldRow);
83-
console.log(shared.sampleFunc("list: this is from the shared function"));
8475
}
8576

8677
function beforeDelete(row, errors) {
8778
console.log("list: beforeDelete: row is: " + row);
8879
if (row.company === "Inserting Single" || row.company === "DeleteMe")
8980
errors[null] = "This is the Before Delete Error";
90-
91-
console.log(shared.sampleFunc("list: this is from the shared function"));
9281
}
9382

9483
function afterInsert(row, errors) {
9584
console.log("list: afterInsert: row is: " + row);
9685

9786
if (row.name === "Emp 1")
9887
errors[null] = "This is the After Insert Error";
99-
100-
console.log(shared.sampleFunc("list: this is from the shared function"));
10188
}
10289

10390
function afterUpdate(row, oldRow, errors) {
10491
console.log("list: afterUpdate: row is: " + row);
10592

106-
if (row.name === "Emp 2" || row.name === "Emp 6" )
93+
if (row.company === "Company After Update Error")
10794
errors[null] = "This is the After Update Error";
108-
//throw new Error("This is the After Update Error");
10995

11096
console.log("list: old row is: " +oldRow);
111-
console.log(shared.sampleFunc("list: this is from the shared function"));
11297
}
11398

11499
function afterDelete(row, errors) {
115100
console.log("list: afterDelete: row is: " + row);
116101

117102
if (row.company === "Before Update changed me")
118103
errors[null] = "This is the After Delete Error";
119-
120-
console.log(shared.sampleFunc("list: this is from the shared function"));
121104
}
122105

123106
function complete(event, errors) {
124107
console.log("list: complete got triggered with event: " + event);
125-
console.log(shared.sampleFunc("list: this is from the shared function"));
126108
}
Lines changed: 7 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,47 @@
1-
/*
2-
* Copyright (c) 2016-2017 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5-
*/
61
var shared = require("TriggerTestModule/EmployeeLib");
72
var console = require("console");
83

94
function managedColumns() {
10-
return {
11-
insert: ["Country"],
12-
update: ["Country"],
13-
};
5+
return shared.managedColumns();
146
}
157

168
function init(event, errors) {
179
console.log("init got triggered with event: " + event);
18-
console.log(shared.sampleFunc("this is from the shared function"));
1910
}
2011

2112
function beforeInsert(row, errors) {
2213
console.log("samples: beforeInsert: row is: " + row);
23-
if (row.name === "Managed Insert") {
24-
row.Country = "MANAGED-INS";
25-
} else if (row.name === "Managed Struct") {
26-
row.Country = "MANAGED-STRUCT";
27-
row.undeclaredCol = "bad";
28-
} else if (row.name === "Managed Struct Remove") {
29-
row.Country = "MANAGED-STRUCT-REM";
30-
delete row.Comments;
31-
}
32-
33-
if (row.name === "Managed Unhandled") {
34-
delete row.Country;
35-
} else {
36-
if (row.Comments) {
37-
if (row.Comments === "Individual Test") {
38-
row.Country = "Inserting Single";
39-
row.Comments = "BeforeDelete";
40-
}
41-
else if (row.Comments === "Import Test")
42-
row.Country = "Importing TSV";
43-
else if (row.Comments === "API Test")
44-
row.Country = "API BeforeInsert";
45-
} else {
46-
if (row.Comments === "Individual Test") {
47-
row.country = "Inserting Single";
48-
row.Comments = "BeforeDelete";
49-
}
50-
else if (row.Comments === "Import Test")
51-
row.country = "Importing TSV";
52-
else if (row.Comments === "API Test")
53-
row.country = "API BeforeInsert";
54-
}
55-
if (!row.Country)
56-
row.Country = "ST-DEFAULT";
57-
}
14+
shared.beforeInsert(row, errors);
5815
console.log("samples: edited row is: " + row);
59-
console.log(shared.sampleFunc("samples: this is from the shared function"));
6016
}
6117

6218
function beforeUpdate(row, oldRow, errors) {
6319
console.log("samples: beforeUpdate: row is: " + row);
64-
if (row.Comments === "Managed Update") {
65-
row.Country = "MANAGED-UPD";
66-
} else if (row.Comments === "Managed Struct") {
67-
row.Country = "MANAGED-STRUCT";
68-
row.undeclaredCol = "bad";
69-
} else if (row.Comments === "Managed Struct Remove") {
70-
row.Country = "MANAGED-STRUCT-REM";
71-
delete row.Comments;
72-
}
73-
74-
if (row.Comments === "Managed Unhandled") {
75-
delete row.Country;
76-
} else {
77-
if (row.Comments === "BeforeUpdate")
78-
row.Country = "Before Update changed me";
79-
else if (row.Comments === "BeforeUpdate")
80-
row.country = "Before Update changed me";
81-
if (!row.Country) {
82-
row.Country = "ST-DEFAULT-UPD";
83-
}
84-
}
85-
20+
shared.beforeUpdate(row, oldRow, errors);
8621
console.log("samples: old row is: " + oldRow);
87-
console.log(shared.sampleFunc("samples: this is from the shared function"));
8822
}
8923

9024
function beforeDelete(row, errors) {
9125
console.log("samples: beforeDelete: row is: " + row);
92-
if (row.Comments === "BeforeDelete")
93-
errors[null] = "This is the Before Delete Error";
94-
95-
console.log(shared.sampleFunc("samples: this is from the shared function"));
26+
shared.beforeDelete(row, errors);
9627
}
9728

9829
function afterInsert(row, errors) {
9930
console.log("samples: afterInsert: row is: " + row);
100-
101-
if (row.Comments === "AfterInsert")
102-
errors[null] = "This is the After Insert Error";
103-
104-
console.log(shared.sampleFunc("samples: this is from the shared function"));
31+
shared.afterInsert(row, errors);
10532
}
10633

10734
function afterUpdate(row, oldRow, errors) {
10835
console.log("samples: afterUpdate: row is: " + row);
109-
110-
if (row.Comments === "AfterUpdate")
111-
errors[null] = "This is the After Update Error";
112-
36+
shared.afterUpdate(row, oldRow, errors);
11337
console.log("samples: old row is: " +oldRow);
114-
console.log(shared.sampleFunc("samples: this is from the shared function"));
11538
}
11639

11740
function afterDelete(row, errors) {
11841
console.log("samples: afterDelete: row is: " + row);
119-
120-
if (row.country === "Before Update changed me")
121-
errors[null] = "This is the After Delete Error";
122-
123-
console.log(shared.sampleFunc("samples: this is from the shared function"));
42+
shared.afterDelete(row, errors);
12443
}
12544

12645
function complete(event, errors) {
12746
console.log("samples: complete got triggered with event: " + event);
128-
console.log(shared.sampleFunc("samples: this is from the shared function"));
12947
}

0 commit comments

Comments
 (0)