@luomus/laji-form 14.3.8 → 15.1.0

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/cypress/fixtures/example.json +5 -0
  3. closes suggestion list (failed).png +0 -0
  4. is marked as suggested (failed).png +0 -0
  5. package/dist/laji-form.js +1 -1
  6. package/lib/components/LajiForm.js +0 -1
  7. package/lib/components/fields/ImageArrayField.js +2 -4
  8. package/lib/components/fields/NamedPlaceSaverField.js +1 -1
  9. package/lib/components/fields/SectionArrayField.js +5 -1
  10. package/lib/components/fields/SingleActiveArrayField.js +1 -1
  11. package/lib/components/fields/UnitShorthandField.js +2 -2
  12. package/lib/components/templates/ArrayFieldTemplate.js +3 -2
  13. package/lib/components/templates/FieldTemplate.js +2 -2
  14. package/lib/utils.d.ts +6 -2
  15. package/lib/utils.js +13 -13
  16. package/llol +10 -0
  17. package/llol.pdf +10 -0
  18. package/migrate.sh +33 -0
  19. package/package.json +14 -21
  20. package/playwright-report/index.html +62 -0
  21. package/playwright.config.ts +77 -0
  22. package/q +196 -0
  23. package/rename.sh +24 -0
  24. package/test-export/test-utils.d.ts +177 -150
  25. package/test-export/test-utils.js +214 -218
  26. package/trip-report.spec.ts +594 -0
  27. package/tsconfig.test.json +1 -1
  28. package/lib/components/fields/AsArrayField.d.ts +0 -292
  29. package/lib/components/fields/AsArrayField.js +0 -39
  30. package/test-export/array-spec.d.ts +0 -1
  31. package/test-export/array-spec.js +0 -204
  32. package/test-export/bird-point-count-spec.d.ts +0 -1
  33. package/test-export/bird-point-count-spec.js +0 -62
  34. package/test-export/collection-contest-form-spec.d.ts +0 -1
  35. package/test-export/collection-contest-form-spec.js +0 -38
  36. package/test-export/dataset-form-spec.d.ts +0 -1
  37. package/test-export/dataset-form-spec.js +0 -50
  38. package/test-export/date-time-widget-spec.d.ts +0 -1
  39. package/test-export/date-time-widget-spec.js +0 -188
  40. package/test-export/geocoder-spec.d.ts +0 -1
  41. package/test-export/geocoder-spec.js +0 -135
  42. package/test-export/image-array-spec.d.ts +0 -1
  43. package/test-export/image-array-spec.js +0 -94
  44. package/test-export/inject-field-spec.d.ts +0 -1
  45. package/test-export/inject-field-spec.js +0 -148
  46. package/test-export/internal-uuids-spec.d.ts +0 -1
  47. package/test-export/internal-uuids-spec.js +0 -157
  48. package/test-export/invasive-species-eradication-np-spec.d.ts +0 -1
  49. package/test-export/invasive-species-eradication-np-spec.js +0 -18
  50. package/test-export/invasive-species-eradication-spec.d.ts +0 -1
  51. package/test-export/invasive-species-eradication-spec.js +0 -25
  52. package/test-export/line-transect-spec.d.ts +0 -1
  53. package/test-export/line-transect-spec.js +0 -121
  54. package/test-export/mobile-form-spec.d.ts +0 -1
  55. package/test-export/mobile-form-spec.js +0 -84
  56. package/test-export/nafi-spec.d.ts +0 -1
  57. package/test-export/nafi-spec.js +0 -85
  58. package/test-export/select-widget-spec.d.ts +0 -1
  59. package/test-export/select-widget-spec.js +0 -68
  60. package/test-export/single-item-array-field-spec.d.ts +0 -1
  61. package/test-export/single-item-array-field-spec.js +0 -92
  62. package/test-export/syke-butterfly-spec.d.ts +0 -1
  63. package/test-export/syke-butterfly-spec.js +0 -163
  64. package/test-export/transaction-form-spec.d.ts +0 -1
  65. package/test-export/transaction-form-spec.js +0 -63
  66. package/test-export/trip-report-autosuggest-spec.d.ts +0 -1
  67. package/test-export/trip-report-autosuggest-spec.js +0 -272
  68. package/test-export/trip-report-spec.d.ts +0 -1
  69. package/test-export/trip-report-spec.js +0 -456
  70. package/test-export/unit-list-shorthand-array-field-spec.d.ts +0 -1
  71. package/test-export/unit-list-shorthand-array-field-spec.js +0 -71
  72. package/test-export/validation-spec.d.ts +0 -1
  73. package/test-export/validation-spec.js +0 -336
  74. package/test-export/water-bird-spec.d.ts +0 -1
  75. package/test-export/water-bird-spec.js +0 -30
  76. package/test-export/wbc-spec.d.ts +0 -1
  77. package/test-export/wbc-spec.js +0 -82
@@ -1,336 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const test_utils_1 = require("./test-utils");
13
- const properties = require("../properties.json");
14
- describe("Validations", () => {
15
- let form;
16
- // Uncomment when https://github.com/rjsf-team/react-jsonschema-form/pull/1528 is merged.
17
- //beforeAll(async () => {
18
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
19
- form = yield test_utils_1.createForm();
20
- }));
21
- const schema = {
22
- type: "object",
23
- properties: {
24
- a: {
25
- type: "string"
26
- },
27
- b: {
28
- type: "string"
29
- }
30
- },
31
- };
32
- const formData = { b: "bar" };
33
- const message = "foo";
34
- const getCustom = (message = "foo", live) => ({
35
- a: {
36
- presence: {
37
- message,
38
- options: {
39
- _live: live
40
- }
41
- }
42
- }
43
- });
44
- it("pass on no errors", () => __awaiter(void 0, void 0, void 0, function* () {
45
- yield form.setState({ schema, formData });
46
- yield form.submit();
47
- expect(yield form.getSubmittedData()).toEqual(formData);
48
- }));
49
- it("fail on schema errors", () => __awaiter(void 0, void 0, void 0, function* () {
50
- yield form.setState({ schema: Object.assign(Object.assign({}, schema), { required: ["a"] }), formData });
51
- yield form.submit();
52
- expect(yield form.getSubmittedData()).not.toEqual(formData);
53
- expect(yield form.errors.$$all.count()).toBe(1);
54
- }));
55
- it("doesn't run schema validators before submitted", () => __awaiter(void 0, void 0, void 0, function* () {
56
- const _formData = Object.assign(Object.assign({}, formData), { a: "foo" });
57
- yield form.setState({ schema: Object.assign(Object.assign({}, schema), { required: ["a"] }), formData: _formData });
58
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
59
- expect(yield form.errors.$$all.count()).toBe(0);
60
- yield form.submit();
61
- expect(yield form.errors.$$all.count()).toBe(1);
62
- }));
63
- it("fail on custom errors", () => __awaiter(void 0, void 0, void 0, function* () {
64
- const validators = getCustom();
65
- const formData = {};
66
- yield form.setState({ schema, formData, validators });
67
- yield form.submit();
68
- expect(yield form.getSubmittedData()).not.toEqual(formData);
69
- expect(yield form.errors.$$all.get(0).getText()).toContain(message);
70
- }));
71
- describe("warnings", () => {
72
- it("prevent submit", () => __awaiter(void 0, void 0, void 0, function* () {
73
- const warnings = getCustom();
74
- yield form.setState({ schema, formData, warnings });
75
- yield form.submit();
76
- expect(yield form.getSubmittedData()).not.toEqual(formData);
77
- expect(yield form.warnings.$$all.get(0).getText()).toContain(message);
78
- }));
79
- it("can be submitted via warnings-acknowledged-submit button", () => __awaiter(void 0, void 0, void 0, function* () {
80
- const warnings = getCustom();
81
- yield form.setState({ schema, formData, warnings });
82
- yield form.submit();
83
- yield test_utils_1.waitUntilBlockingLoaderHides();
84
- yield form.$acknowledgeWarnings.click();
85
- expect(yield form.getSubmittedData()).toEqual(formData);
86
- }));
87
- });
88
- [["errors", "validators"], ["warnings", "warnings"]].forEach(([type, propName]) => {
89
- it(`doesn't run ${type} live validators on init`, () => __awaiter(void 0, void 0, void 0, function* () {
90
- const validators = getCustom(message, "live");
91
- const formData = {};
92
- yield form.setState({ schema, formData, [propName]: validators });
93
- expect(yield form[type].$panel.isPresent()).toBe(false);
94
- }));
95
- it(`runs live ${type} validators on onChange`, () => __awaiter(void 0, void 0, void 0, function* () {
96
- const validators = getCustom(message, "live");
97
- const formData = { a: "bar" };
98
- yield form.setState({ schema, formData, [propName]: validators });
99
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
100
- expect(yield form[type].$$all.get(0).getText()).toContain(message);
101
- }));
102
- });
103
- it("doesn't show blocker during live validation", () => __awaiter(void 0, void 0, void 0, function* () {
104
- const validators = getCustom(message, "live");
105
- const formData = { a: "bar" };
106
- yield form.setState({ schema, formData, validators });
107
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
108
- expect(yield form.isBlocked()).toBe(false);
109
- }));
110
- it("runs both validators and warnings live on Change", () => __awaiter(void 0, void 0, void 0, function* () {
111
- const validators = getCustom(message, "live");
112
- const formData = { a: "bar" };
113
- yield form.setState({ schema, formData, validators, warnings: validators });
114
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
115
- for (const type of ["errors", "warnings"]) {
116
- expect(yield form[type].$$all.get(0).getText()).toContain(message);
117
- }
118
- }));
119
- it("keeps non live errors when doing only live validation", () => __awaiter(void 0, void 0, void 0, function* () {
120
- const validators = getCustom(message, "live");
121
- const warnings = getCustom(message);
122
- const formData = { a: "bar" };
123
- yield form.setState({ schema, formData, validators, warnings });
124
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
125
- yield form.submit();
126
- yield test_utils_1.waitUntilBlockingLoaderHides();
127
- expect(yield form.warnings.$$all.get(0).getText()).toContain(message);
128
- expect(yield form.errors.$$all.get(0).getText()).toContain(message);
129
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "bar");
130
- expect(yield form.warnings.$$all.get(0).getText()).toContain(message);
131
- expect(yield form.errors.$$all.count()).toBe(0);
132
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
133
- for (const type of ["errors", "warnings"]) {
134
- expect(yield form[type].$$all.get(0).getText()).toContain(message);
135
- }
136
- }));
137
- it("cached non live errors are cleared when validated again against valid", () => __awaiter(void 0, void 0, void 0, function* () {
138
- const validators = getCustom(message, "live");
139
- const warnings = getCustom(message);
140
- const formData = { a: "bar" };
141
- yield form.setState({ schema, formData, validators, warnings });
142
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
143
- yield form.submit();
144
- yield test_utils_1.waitUntilBlockingLoaderHides();
145
- expect(yield form.warnings.$$all.get(0).getText()).toContain(message);
146
- expect(yield form.errors.$$all.get(0).getText()).toContain(message);
147
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "bar");
148
- expect(yield form.warnings.$$all.get(0).getText()).toContain(message);
149
- expect(yield form.errors.$$all.count()).toBe(0);
150
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "");
151
- yield test_utils_1.updateValue(form.$getInputWidget("a"), "bar");
152
- yield form.submit();
153
- for (const type of ["errors", "warnings"]) {
154
- expect(yield form[type].$$all.count()).toBe(0);
155
- }
156
- }));
157
- it("runs all validator types on submit", () => __awaiter(void 0, void 0, void 0, function* () {
158
- const validators = getCustom(message, "live");
159
- const _validators = Object.assign(Object.assign({}, validators), { b: validators.a });
160
- const warnings = Object.assign(Object.assign({}, validators), { b: validators.a });
161
- yield form.setState({ schema, formData, validators: _validators, warnings });
162
- yield test_utils_1.updateValue(form.$getInputWidget("b"), "");
163
- yield form.submit();
164
- expect(yield form.getSubmittedData()).not.toEqual(formData);
165
- expect(yield form.errors.$$all.count()).toBe(2);
166
- expect(yield form.warnings.$$all.count()).toBe(2);
167
- }));
168
- const response = {
169
- "error": {
170
- "statusCode": 422,
171
- "name": "Error",
172
- "message": "Unprocessable Entity",
173
- "details": {
174
- ".a": [
175
- "mock"
176
- ]
177
- }
178
- }
179
- };
180
- it("delays submit until async validators complete and doesn't submit when invalid", () => __awaiter(void 0, void 0, void 0, function* () {
181
- const validators = {
182
- a: {
183
- remote: {
184
- validator: "mock",
185
- message
186
- }
187
- }
188
- };
189
- const { resolve, remove } = yield form.setMockResponse("/documents/validate", false);
190
- const _formData = Object.assign(Object.assign({}, formData), { a: "empty isn't async validated so we have value here" });
191
- yield form.setState({ schema, formData: _formData, validators });
192
- yield form.startSubmit();
193
- expect(yield form.getSubmittedData()).not.toEqual(_formData);
194
- expect(yield form.errors.$$all.count()).toBe(0);
195
- yield resolve({ status: 422, json: response }, !!"raw");
196
- expect(yield form.errors.$$all.count()).toBe(1);
197
- expect(yield form.errors.$$all.get(0).getText()).toContain(message);
198
- yield remove();
199
- }));
200
- it("delays submit until async validators complete and submits when valid", () => __awaiter(void 0, void 0, void 0, function* () {
201
- const validators = {
202
- a: {
203
- remote: {
204
- validator: "mock",
205
- message
206
- }
207
- }
208
- };
209
- const { resolve, remove } = yield form.setMockResponse("/documents/validate", false);
210
- const _formData = Object.assign(Object.assign({}, formData), { a: "empty isn't async validated so we have value here" });
211
- yield form.setState({ schema, formData: _formData, validators });
212
- yield form.startSubmit();
213
- expect(yield form.getSubmittedData()).not.toEqual(_formData);
214
- expect(yield form.errors.$$all.count()).toBe(0);
215
- yield resolve({});
216
- expect(yield form.getSubmittedData()).toEqual(_formData);
217
- yield remove();
218
- }));
219
- it("delays all validators until async operations complete", () => __awaiter(void 0, void 0, void 0, function* () {
220
- const validators = {
221
- a: {
222
- remote: {
223
- validator: "mock",
224
- message
225
- }
226
- }
227
- };
228
- const { resolve, remove } = yield form.setMockResponse("/documents/validate", false);
229
- const _formData = Object.assign(Object.assign({}, formData), { a: "empty isn't async validated so we have value here" });
230
- yield form.setState({ schema, formData: _formData, validators });
231
- yield form.startSubmit();
232
- expect(yield form.getSubmittedData()).not.toEqual(_formData);
233
- expect(yield form.errors.$$all.count()).toBe(0);
234
- yield resolve({ status: 422, json: response }, !!"raw");
235
- expect(yield form.errors.$$all.count()).toBe(1);
236
- expect(yield form.errors.$$all.get(0).getText()).toContain(message);
237
- yield remove();
238
- }));
239
- const uiSchema = {
240
- c: {
241
- "ui:field": "ImageArrayField"
242
- }
243
- };
244
- const uiSchemaContext = {
245
- creator: properties.userId
246
- };
247
- const schemaForAsync = Object.assign(Object.assign({}, schema), { properties: Object.assign(Object.assign({}, schema.properties), { c: {
248
- type: "array",
249
- items: {
250
- type: "string"
251
- }
252
- } }) });
253
- const imageUploaded = "imgae uploaded";
254
- const asyncValidators = {
255
- b: {
256
- remote: {
257
- validator: "mock",
258
- message
259
- },
260
- presence: {
261
- message,
262
- options: {
263
- _live: true
264
- }
265
- }
266
- },
267
- c: {
268
- length: {
269
- maximum: 0,
270
- message: imageUploaded
271
- }
272
- }
273
- };
274
- it("validations aren't run when async validation running already", () => __awaiter(void 0, void 0, void 0, function* () {
275
- const { resolve, remove } = yield form.setMockResponse("/documents/validate", false);
276
- yield form.setState({ schema: schemaForAsync, formData, validators: asyncValidators, uiSchema, uiSchemaContext });
277
- const { resolve: imageResolve, remove: imageRemove } = yield form.mockImageUpload("c");
278
- yield form.startSubmit();
279
- expect(yield form.errors.$$all.count()).toBe(0);
280
- yield imageResolve();
281
- expect(yield form.errors.$$all.count()).toBe(0);
282
- yield resolve({});
283
- yield remove();
284
- yield imageRemove();
285
- }));
286
- it("revalidates when data is edited during async validation on submit", () => __awaiter(void 0, void 0, void 0, function* () {
287
- const { resolve, remove } = yield form.setMockResponse("/documents/validate", false);
288
- yield form.setState({ schema: schemaForAsync, formData, validators: asyncValidators, uiSchema, uiSchemaContext });
289
- const { resolve: imageResolve, remove: imageRemove } = yield form.mockImageUpload("c");
290
- yield form.startSubmit();
291
- expect(yield form.errors.$$all.count()).toBe(0);
292
- yield imageResolve();
293
- yield resolve({});
294
- yield test_utils_1.waitUntilBlockingLoaderHides();
295
- expect(yield form.errors.$$all.count()).toBe(1);
296
- expect(yield form.errors.$$all.get(0).getText()).toContain(imageUploaded);
297
- yield remove();
298
- yield imageRemove();
299
- }));
300
- it("shows blocking loader when validating", () => __awaiter(void 0, void 0, void 0, function* () {
301
- const { resolve, remove } = yield form.setMockResponse("/documents/validate", false);
302
- yield form.setState({ schema, formData, validators: asyncValidators });
303
- expect(yield form.isBlocked()).toBe(false);
304
- yield form.startSubmit();
305
- expect(yield form.isBlocked()).toBe(true);
306
- yield resolve({ status: 422, json: response }, !!"raw");
307
- yield test_utils_1.waitUntilBlockingLoaderHides();
308
- expect(yield form.isBlocked()).toBe(false);
309
- yield remove();
310
- }));
311
- describe("Custom validation bypass", () => {
312
- it("skips custom errors and warnings", () => __awaiter(void 0, void 0, void 0, function* () {
313
- const validators = getCustom(message);
314
- yield form.setState({ schema, formData, validators, warnings: validators });
315
- yield form.submitOnlySchemaValidations();
316
- yield form.waitUntilBlockingLoaderHides();
317
- expect(yield form.errors.$$all.count()).toBe(0);
318
- expect(yield form.warnings.$$all.count()).toBe(0);
319
- }));
320
- it("skips live errors and live warnings", () => __awaiter(void 0, void 0, void 0, function* () {
321
- const validators = getCustom(message, "live");
322
- yield form.setState({ schema, formData, validators, warnings: validators });
323
- yield form.submitOnlySchemaValidations();
324
- yield form.waitUntilBlockingLoaderHides();
325
- expect(yield form.errors.$$all.count()).toBe(0);
326
- expect(yield form.warnings.$$all.count()).toBe(0);
327
- }));
328
- it("runs schema validations", () => __awaiter(void 0, void 0, void 0, function* () {
329
- form = yield test_utils_1.createForm();
330
- yield form.setState({ schema: Object.assign(Object.assign({}, schema), { required: ["a"] }), formData });
331
- yield form.submitOnlySchemaValidations();
332
- yield form.waitUntilBlockingLoaderHides();
333
- expect(yield form.errors.$$all.count()).toBe(1);
334
- }));
335
- });
336
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const test_utils_1 = require("./test-utils");
13
- const protractor_1 = require("protractor");
14
- describe("water bird pair count form (MHL.65)", () => {
15
- let form;
16
- beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
17
- form = yield test_utils_1.createForm({ id: "MHL.65", localFormData: true });
18
- }));
19
- it("sets correct unitType to pair observations when using add button", () => __awaiter(void 0, void 0, void 0, function* () {
20
- yield form.$locateButton("gatherings_0_units", "add").click();
21
- const formData = yield form.getChangedData();
22
- expect(formData.gatherings[0].units[0].unitType[0]).toBe("pairObservation");
23
- }));
24
- it("sets correct unitType to pair observations when using insert shorthand", () => __awaiter(void 0, void 0, void 0, function* () {
25
- yield form.$locateButton("gatherings_0_units", "add").click();
26
- yield protractor_1.browser.driver.switchTo().activeElement().sendKeys(protractor_1.protractor.Key.chord(protractor_1.protractor.Key.ALT, "i"));
27
- const formData = yield form.getChangedData();
28
- expect(formData.gatherings[0].units[1].unitType[0]).toBe("pairObservation");
29
- }));
30
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const test_utils_1 = require("./test-utils");
13
- const protractor_1 = require("protractor");
14
- describe("WBC (MHL.3)", () => {
15
- let form;
16
- it("navigate to form", () => __awaiter(void 0, void 0, void 0, function* () {
17
- form = yield test_utils_1.createForm({ id: "MHL.3", localFormData: true, isAdmin: true });
18
- }));
19
- it("taxon census has aves", () => __awaiter(void 0, void 0, void 0, function* () {
20
- const formData = yield form.getPropsData();
21
- expect(formData.gatherings[0].taxonCensus[0].censusTaxonID).toBe("MX.37580");
22
- }));
23
- it("taxon census has correct values when yes is selected", () => __awaiter(void 0, void 0, void 0, function* () {
24
- const widget = form.getBooleanWidget("gatherings.0.taxonCensus");
25
- yield widget.$true.click();
26
- const formData = yield form.getChangedData();
27
- expect(formData.gatherings[0].taxonCensus.length).toBe(2);
28
- expect(formData.gatherings[0].taxonCensus[0].censusTaxonID).toBe("MX.37580");
29
- expect(formData.gatherings[0].taxonCensus[1].censusTaxonID).toBe("MX.37612");
30
- }));
31
- it("taxon census has correct values when no is selected", () => __awaiter(void 0, void 0, void 0, function* () {
32
- const widget = form.getBooleanWidget("gatherings.0.taxonCensus");
33
- yield widget.$false.click();
34
- const formData = yield form.getChangedData();
35
- expect(formData.gatherings[0].taxonCensus.length).toBe(1);
36
- expect(formData.gatherings[0].taxonCensus[0].censusTaxonID).toBe("MX.37580");
37
- }));
38
- it("added existing user is shown as suggested", () => __awaiter(void 0, void 0, void 0, function* () {
39
- // ID for button is broken, should be gatheringEvent.leg?
40
- yield form.$locateButton("gatheringEvent", "add").click();
41
- const $field = form.$locate("gatheringEvent.1.leg");
42
- const $input = form.$getInputWidget("gatheringEvent.1.leg");
43
- yield $input.sendKeys("unit");
44
- const $suggestionList = $field.$(".rw-list");
45
- const $$suggestions = $field.$$(".rw-list-option");
46
- yield protractor_1.browser.wait(protractor_1.protractor.ExpectedConditions.visibilityOf($suggestionList), 5000, "Suggestion list timeout");
47
- yield $$suggestions.first().click();
48
- yield protractor_1.browser.wait(protractor_1.protractor.ExpectedConditions.invisibilityOf($field.$(".react-spinner")), 5000, "Field input spinner didn't leave");
49
- expect(yield form.$locate("gatheringEvent.1.leg").$(".glyphicon-user").isDisplayed()).toBe(true);
50
- }));
51
- describe("namedPlaceNotes", () => {
52
- it("renders", () => __awaiter(void 0, void 0, void 0, function* () {
53
- expect(yield form.$locate("gatherings.0.namedPlaceNotes").isDisplayed()).toBe(true);
54
- }));
55
- it("is textarea", () => __awaiter(void 0, void 0, void 0, function* () {
56
- expect(yield form.$getTextareaWidget("gatherings.0.namedPlaceNotes").isDisplayed()).toBe(true);
57
- }));
58
- it("updates", () => __awaiter(void 0, void 0, void 0, function* () {
59
- yield test_utils_1.updateValue(form.$getTextareaWidget("gatherings.0.namedPlaceNotes"), "test");
60
- expect(yield form.$getTextareaWidget("gatherings.0.namedPlaceNotes").getAttribute("value")).toBe("test");
61
- expect((yield form.getChangedData()).gatheringEvent.namedPlaceNotes).toBe("test");
62
- }));
63
- it("doesn't spill into gatherings", () => __awaiter(void 0, void 0, void 0, function* () {
64
- expect((yield form.getChangedData()).gatherings[0]).not.toContain("namedPlaceNotes");
65
- }));
66
- });
67
- it("added existing user ID is shown", () => __awaiter(void 0, void 0, void 0, function* () {
68
- const $input = form.$getInputWidget("gatheringEvent.1.leg");
69
- expect(yield $input.getAttribute("value")).toMatch(/Unit.+ \(MA\.\d+\)/);
70
- }));
71
- it("entering descriptionBiotopeF doesn't clear observerCount", () => __awaiter(void 0, void 0, void 0, function* () {
72
- form = yield test_utils_1.createForm({ id: "MHL.3", localFormData: true, isAdmin: true });
73
- const $descriptionBiotopeF = form.$locate("gatherings.0.gatheringFact.descriptionBiotopeF");
74
- const $otherBiotopeFCheckbox = $descriptionBiotopeF.$$(".checkbox label input").get(2);
75
- yield $otherBiotopeFCheckbox.click();
76
- yield $otherBiotopeFCheckbox.click();
77
- yield $otherBiotopeFCheckbox.click();
78
- //await $descriptionBiotopeF.$("input.form-control").sendKeys("test");
79
- const formData = yield form.getChangedData();
80
- expect(formData.gatherings[0].gatheringFact.observerCount).toBe(1);
81
- }));
82
- });