@luomus/laji-form 14.3.8 → 15.0.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.
- package/CHANGELOG.md +4 -0
- package/cypress/fixtures/example.json +5 -0
- closes suggestion list (failed).png +0 -0
- is marked as suggested (failed).png +0 -0
- package/dist/laji-form.js +1 -1
- package/lib/components/LajiForm.js +0 -1
- package/lib/components/fields/ImageArrayField.js +2 -4
- package/lib/components/fields/NamedPlaceSaverField.js +1 -1
- package/lib/components/fields/SectionArrayField.js +5 -1
- package/lib/components/fields/SingleActiveArrayField.js +1 -1
- package/lib/components/fields/UnitShorthandField.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.js +3 -2
- package/lib/components/templates/FieldTemplate.js +2 -2
- package/lib/utils.d.ts +6 -2
- package/lib/utils.js +13 -13
- package/llol +10 -0
- package/llol.pdf +10 -0
- package/migrate.sh +33 -0
- package/package.json +14 -21
- package/playwright-report/index.html +62 -0
- package/playwright.config.ts +77 -0
- package/q +196 -0
- package/rename.sh +24 -0
- package/test-export/test-utils.d.ts +176 -150
- package/test-export/test-utils.js +210 -218
- package/trip-report.spec.ts +594 -0
- package/tsconfig.test.json +1 -1
- package/lib/components/fields/AsArrayField.d.ts +0 -292
- package/lib/components/fields/AsArrayField.js +0 -39
- package/test-export/array-spec.d.ts +0 -1
- package/test-export/array-spec.js +0 -204
- package/test-export/bird-point-count-spec.d.ts +0 -1
- package/test-export/bird-point-count-spec.js +0 -62
- package/test-export/collection-contest-form-spec.d.ts +0 -1
- package/test-export/collection-contest-form-spec.js +0 -38
- package/test-export/dataset-form-spec.d.ts +0 -1
- package/test-export/dataset-form-spec.js +0 -50
- package/test-export/date-time-widget-spec.d.ts +0 -1
- package/test-export/date-time-widget-spec.js +0 -188
- package/test-export/geocoder-spec.d.ts +0 -1
- package/test-export/geocoder-spec.js +0 -135
- package/test-export/image-array-spec.d.ts +0 -1
- package/test-export/image-array-spec.js +0 -94
- package/test-export/inject-field-spec.d.ts +0 -1
- package/test-export/inject-field-spec.js +0 -148
- package/test-export/internal-uuids-spec.d.ts +0 -1
- package/test-export/internal-uuids-spec.js +0 -157
- package/test-export/invasive-species-eradication-np-spec.d.ts +0 -1
- package/test-export/invasive-species-eradication-np-spec.js +0 -18
- package/test-export/invasive-species-eradication-spec.d.ts +0 -1
- package/test-export/invasive-species-eradication-spec.js +0 -25
- package/test-export/line-transect-spec.d.ts +0 -1
- package/test-export/line-transect-spec.js +0 -121
- package/test-export/mobile-form-spec.d.ts +0 -1
- package/test-export/mobile-form-spec.js +0 -84
- package/test-export/nafi-spec.d.ts +0 -1
- package/test-export/nafi-spec.js +0 -85
- package/test-export/select-widget-spec.d.ts +0 -1
- package/test-export/select-widget-spec.js +0 -68
- package/test-export/single-item-array-field-spec.d.ts +0 -1
- package/test-export/single-item-array-field-spec.js +0 -92
- package/test-export/syke-butterfly-spec.d.ts +0 -1
- package/test-export/syke-butterfly-spec.js +0 -163
- package/test-export/transaction-form-spec.d.ts +0 -1
- package/test-export/transaction-form-spec.js +0 -63
- package/test-export/trip-report-autosuggest-spec.d.ts +0 -1
- package/test-export/trip-report-autosuggest-spec.js +0 -272
- package/test-export/trip-report-spec.d.ts +0 -1
- package/test-export/trip-report-spec.js +0 -456
- package/test-export/unit-list-shorthand-array-field-spec.d.ts +0 -1
- package/test-export/unit-list-shorthand-array-field-spec.js +0 -71
- package/test-export/validation-spec.d.ts +0 -1
- package/test-export/validation-spec.js +0 -336
- package/test-export/water-bird-spec.d.ts +0 -1
- package/test-export/water-bird-spec.js +0 -30
- package/test-export/wbc-spec.d.ts +0 -1
- package/test-export/wbc-spec.js +0 -82
|
@@ -20,128 +20,241 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
24
|
-
const protractor_1 = require("protractor");
|
|
23
|
+
exports.getRemoveUnit = exports.maybeJSONPointerToLocator = exports.filterUUIDs = exports.createForm = exports.DemoPageForm = exports.Form = exports.getFocusedElement = exports.lajiFormLocator = exports.navigateToForm = exports.emptyForm = void 0;
|
|
25
24
|
const path = require("path");
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const getLocatorForContextId = (contextId) => (path) => `#_laji-form_${contextId}_root${typeof path === "string" && path.length ? `_${path.replace(/\./g, "_")}` : ""}`;
|
|
29
|
-
exports.getLocatorForContextId = getLocatorForContextId;
|
|
30
|
-
const emptyForm = (params = "") => __awaiter(void 0, void 0, void 0, function* () { return protractor_1.browser.get(`http://${HOST}:${PORT}?test=true&settings=false&mockApi=true&${params}`); });
|
|
25
|
+
const test_utils_1 = require("@luomus/laji-map/test-export/test-utils");
|
|
26
|
+
const emptyForm = (page, params = "") => __awaiter(void 0, void 0, void 0, function* () { return page.goto(`/?test=true&settings=false&mockApi=true&${params}`); });
|
|
31
27
|
exports.emptyForm = emptyForm;
|
|
32
|
-
const navigateToForm = (formID, params = "") => __awaiter(void 0, void 0, void 0, function* () { return
|
|
28
|
+
const navigateToForm = (page, formID, params = "") => __awaiter(void 0, void 0, void 0, function* () { return page.goto(`/?id=${formID}&local=true&settings=false&mockApi=true${params}`); });
|
|
33
29
|
exports.navigateToForm = navigateToForm;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const getFocusedElement = () => protractor_1.browser.driver.switchTo().activeElement();
|
|
30
|
+
const lajiFormLocator = (path) => `#_laji-form_root${typeof path === "string" && path.length ? `_${path.replace(/\./g, "_")}` : ""}`;
|
|
31
|
+
exports.lajiFormLocator = lajiFormLocator;
|
|
32
|
+
const getFocusedElement = (page) => page.locator("*:focus");
|
|
38
33
|
exports.getFocusedElement = getFocusedElement;
|
|
39
|
-
const getFocusedId = () => exports.getFocusedElement().getAttribute("id");
|
|
40
|
-
exports.getFocusedId = getFocusedId;
|
|
41
34
|
function getEnumWidgetForContainer($container) {
|
|
42
35
|
return {
|
|
43
36
|
$container,
|
|
44
37
|
openEnums: () => __awaiter(this, void 0, void 0, function* () {
|
|
45
38
|
yield $container.click();
|
|
46
|
-
yield protractor_1.browser.wait(protractor_1.protractor.ExpectedConditions.visibilityOf($container.$$(".rw-list-option").first()), 300, "select list timeout");
|
|
47
39
|
}),
|
|
48
|
-
$enumContainer: $container
|
|
49
|
-
|
|
50
|
-
$input: $container
|
|
40
|
+
$enumContainer: $container.locator(".rw-popup-container"),
|
|
41
|
+
$enums: $container.locator(".rw-list-option"),
|
|
42
|
+
$input: $container.locator("input")
|
|
51
43
|
};
|
|
52
44
|
}
|
|
53
45
|
class Form {
|
|
54
|
-
constructor(
|
|
55
|
-
this
|
|
56
|
-
this
|
|
46
|
+
constructor(page) {
|
|
47
|
+
this.page = page;
|
|
48
|
+
this.$form = this.page.locator(".laji-form .rjsf");
|
|
57
49
|
this.createValidatorPO = (type) => ({
|
|
58
|
-
|
|
59
|
-
$panel:
|
|
50
|
+
$all: this.page.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel .list-group button`),
|
|
51
|
+
$panel: this.page.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel`)
|
|
60
52
|
});
|
|
61
53
|
this.errors = this.createValidatorPO("error");
|
|
62
54
|
this.warnings = this.createValidatorPO("warning");
|
|
63
55
|
this.failedJobs = {
|
|
64
|
-
$container:
|
|
56
|
+
$container: this.page.locator(".laji-form-failed-jobs-list"),
|
|
57
|
+
$errors: this.page.locator(".laji-form-failed-jobs-list").locator(".list-group-item")
|
|
65
58
|
};
|
|
66
|
-
this.$
|
|
67
|
-
this
|
|
68
|
-
this
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
59
|
+
this.$runningJobs = this.page.locator(".running-jobs");
|
|
60
|
+
this.$acknowledgeWarnings = this.page.locator(".laji-form-warning-list .panel-footer button");
|
|
61
|
+
this.$blocker = this.page.locator(".laji-form.blocking-loader");
|
|
62
|
+
this.$mapFieldFullscreenMap = this.page.locator(".laji-form.fullscreen .laji-form-map");
|
|
63
|
+
this.getImageArrayField = (lajiFormLocator) => {
|
|
64
|
+
const $container = this.$locate(lajiFormLocator).locator(".laji-form-medias");
|
|
65
|
+
const $imgContainers = this.$locate(lajiFormLocator).locator(".media-container");
|
|
66
|
+
const $modal = this.page.locator(".laji-form.media-modal");
|
|
67
|
+
const $addModal = this.page.locator(".laji-form.media-add-modal");
|
|
75
68
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
$container,
|
|
70
|
+
$imgContainers,
|
|
71
|
+
$imgs: $imgContainers.locator("img"),
|
|
72
|
+
$imgLoading: $imgContainers.locator(".react-spinner"),
|
|
73
|
+
$imgRemoves: $imgContainers.locator(".button-corner"),
|
|
74
|
+
$imgRemoveConfirmButton: (id) => this.$locateAddition(id, "delete-confirm-yes"),
|
|
75
|
+
$dropzone: this.$locate(lajiFormLocator).locator(".laji-form-drop-zone"),
|
|
76
|
+
$modal,
|
|
77
|
+
$addModal,
|
|
78
|
+
$modalClose: $modal.locator(".modal-header .close"),
|
|
79
|
+
$addModalCancel: $addModal.locator(".cancel")
|
|
85
80
|
};
|
|
86
|
-
});
|
|
87
|
-
this._getImageArrayField = (form) => (lajiFormLocator) => new class ImageArrayFieldPO {
|
|
88
|
-
constructor() {
|
|
89
|
-
this.$container = form.$locate(lajiFormLocator).$(".laji-form-medias");
|
|
90
|
-
this.$$imgs = form.$locate(lajiFormLocator).$$(".media-container");
|
|
91
|
-
this.$$imgInteractives = this.$$imgs.$$(".media-container a");
|
|
92
|
-
this.$$imgRemoves = this.$$imgs.$$(".button-corner");
|
|
93
|
-
this.$imgRemoveConfirmButton = (id) => form.$locateAddition(id, "delete-confirm-yes");
|
|
94
|
-
this.$dropzone = form.$locate(lajiFormLocator).$(".laji-form-drop-zone");
|
|
95
|
-
this.$modal = protractor_1.$(".laji-form.media-modal");
|
|
96
|
-
this.$modalClose = this.$modal.$(".close");
|
|
97
|
-
}
|
|
98
81
|
};
|
|
99
|
-
this.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.$
|
|
103
|
-
this.$
|
|
104
|
-
|
|
105
|
-
this
|
|
106
|
-
this
|
|
107
|
-
this.
|
|
108
|
-
|
|
109
|
-
this.$powerUserButton = protractor_1.$(".power-user-addon");
|
|
110
|
-
this.powerUserButtonIsActive = () => __awaiter(this, void 0, void 0, function* () { return (yield this.$powerUserButton.getAttribute("class")).includes("active"); });
|
|
111
|
-
this.waitForPopoverToHide = () => protractor_1.browser.wait(exports.EC.invisibilityOf(form.$locate(lajiFormLocator).$(".popover-content")), 5000, "Popover didn't hide");
|
|
112
|
-
}
|
|
82
|
+
this.getTaxonAutosuggestWidget = (lajiFormLocator) => {
|
|
83
|
+
return {
|
|
84
|
+
$input: this.$locate(lajiFormLocator).locator("input"),
|
|
85
|
+
$suggestionsContainer: this.$locate(lajiFormLocator).locator(".rw-list"),
|
|
86
|
+
$suggestions: this.$locate(lajiFormLocator).locator(".rw-list-option"),
|
|
87
|
+
$getGlyph: (glyph) => this.$locate(lajiFormLocator).locator(glyph),
|
|
88
|
+
$suggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-ok"),
|
|
89
|
+
$nonsuggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-warning-sign"),
|
|
90
|
+
$powerUserButton: this.page.locator(".power-user-addon")
|
|
91
|
+
};
|
|
113
92
|
};
|
|
114
|
-
this.getTaxonAutosuggestWidget = this._getTaxonAutosuggestWidget(this);
|
|
115
93
|
this.getScopeField = (lajiFormLocator) => ({
|
|
116
94
|
$button: this.$locateButton(lajiFormLocator, "additionals"),
|
|
117
|
-
|
|
95
|
+
$listItems: this.$locate(lajiFormLocator).locator(".dropdown.open li a"),
|
|
96
|
+
modal: {
|
|
97
|
+
$container: this.page.locator(".scope-field-modal"),
|
|
98
|
+
$close: this.page.locator(".scope-field-modal .close"),
|
|
99
|
+
$loadingGroup: this.page.locator(".scope-field-modal .list-group .react-spinner"),
|
|
100
|
+
$groupTitles: this.page.locator(".scope-field-modal .list-group .list-group-item strong"),
|
|
101
|
+
$listItems: this.page.locator(".scope-field-modal .list-group-item"),
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
this.getLocationChooser = (lajiFormLocator) => ({
|
|
105
|
+
$button: this.$locateButton(lajiFormLocator, "location"),
|
|
106
|
+
modal: {
|
|
107
|
+
$container: this.page.locator(".map-dialog"),
|
|
108
|
+
map: new test_utils_1.MapPageObject(this.page, this.page.locator(".map-dialog .laji-map"))
|
|
109
|
+
},
|
|
110
|
+
peeker: {
|
|
111
|
+
$popover: this.$locateButton(lajiFormLocator, "location-peeker"),
|
|
112
|
+
$map: this.$locateButton(lajiFormLocator, "location-peeker").locator(".laji-map"),
|
|
113
|
+
$markers: this.$locateButton(lajiFormLocator, "location-peeker").locator(".vector-marker path"),
|
|
114
|
+
}
|
|
118
115
|
});
|
|
119
116
|
this.getUnitListShorthandArrayField = (lajiFormLocator) => ({
|
|
120
117
|
$button: this.$locateButton(lajiFormLocator, "addUnitList"),
|
|
121
118
|
modal: {
|
|
122
|
-
$input:
|
|
123
|
-
$addButton:
|
|
119
|
+
$input: this.page.locator(".unit-list-shorthand-modal input"),
|
|
120
|
+
$addButton: this.page.locator(".unit-list-shorthand-modal button")
|
|
124
121
|
}
|
|
125
122
|
});
|
|
123
|
+
this.$getShortHandWidget = (lajiFormLocator) => this.$locateAddition(lajiFormLocator, "shortHandText");
|
|
124
|
+
this.getGeocoder = (lajiFormLocator = "") => ({
|
|
125
|
+
$btn: this.$locate(lajiFormLocator).locator(".geocoder-btn"),
|
|
126
|
+
$spinner: this.$locate(lajiFormLocator).locator(".geocoder-btn .react-spinner")
|
|
127
|
+
});
|
|
128
|
+
this.getNamedPlaceChooser = () => {
|
|
129
|
+
const $namedPlaceChooserModal = this.page.locator(".named-place-chooser-modal");
|
|
130
|
+
const $mapPopupContainer = this.page.locator(".named-place-popup");
|
|
131
|
+
return {
|
|
132
|
+
select: getEnumWidgetForContainer(this.page.locator("#named-place-chooser-select")),
|
|
133
|
+
mapPopup: {
|
|
134
|
+
$container: $mapPopupContainer,
|
|
135
|
+
$useBtn: $mapPopupContainer.locator(".btn-default")
|
|
136
|
+
},
|
|
137
|
+
$alert: $namedPlaceChooserModal.locator(".alert"),
|
|
138
|
+
$close: $namedPlaceChooserModal.locator(".close")
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Locates a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
|
|
143
|
+
$locate(path) {
|
|
144
|
+
return this.page.locator(exports.lajiFormLocator(path));
|
|
145
|
+
}
|
|
146
|
+
/** Locates a button for a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
|
|
147
|
+
$locateButton(path, selector) {
|
|
148
|
+
return this.page.locator(`#root${typeof path === "string" && path.length > 0 ? `_${path.replace(/\./g, "_")}` : ""}-${selector}`);
|
|
149
|
+
}
|
|
150
|
+
/** Locates some additional element for a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
|
|
151
|
+
$locateAddition(path, selector) {
|
|
152
|
+
return this.$locateButton(path, selector);
|
|
153
|
+
}
|
|
154
|
+
getBooleanWidget(str) {
|
|
155
|
+
const $container = this.$locate(str).locator(".btn-toolbar");
|
|
156
|
+
return {
|
|
157
|
+
$container,
|
|
158
|
+
$true: $container.locator(".btn").nth(0),
|
|
159
|
+
$false: $container.locator(".btn").nth(1),
|
|
160
|
+
$undefined: this.$locate(str).locator(".btn").nth(2),
|
|
161
|
+
$active: $container.locator(".btn.active"),
|
|
162
|
+
$nonactive: $container.locator(".btn:not(.active)").first()
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
$getInputWidget(str) {
|
|
166
|
+
return this.$locate(str).locator("input");
|
|
167
|
+
}
|
|
168
|
+
$getTextareaWidget(str) {
|
|
169
|
+
return this.$locate(str).locator("textarea");
|
|
170
|
+
}
|
|
171
|
+
$getEnumWidget(str) {
|
|
172
|
+
const $container = this.$locate(str).locator(".rw-combobox");
|
|
173
|
+
return getEnumWidgetForContainer($container);
|
|
174
|
+
}
|
|
175
|
+
getDateWidget(str) {
|
|
176
|
+
const $widget = this.$locate(str).locator(".date-widget");
|
|
177
|
+
return {
|
|
178
|
+
$container: $widget,
|
|
179
|
+
$input: $widget.locator("input"),
|
|
180
|
+
buttons: {
|
|
181
|
+
$today: $widget.locator(".today"),
|
|
182
|
+
$yesterday: $widget.locator(".yesterday"),
|
|
183
|
+
$same: $widget.locator(".same"),
|
|
184
|
+
$date: $widget.locator(".rw-i-calendar"),
|
|
185
|
+
$time: $widget.locator(".rw-i-clock-o")
|
|
186
|
+
},
|
|
187
|
+
calendar: {
|
|
188
|
+
$today: $widget.locator(".rw-calendar-footer button"),
|
|
189
|
+
},
|
|
190
|
+
clock: {
|
|
191
|
+
"$01:00": $widget.locator(".rw-list li").nth(2),
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
$getFieldErrors(str) {
|
|
196
|
+
return this.$locate(str).locator(".laji-form-error-container li");
|
|
197
|
+
}
|
|
198
|
+
/** Draws a marker to the center of a laji-map rendered to the given locator. The locator defaults to "gatherings" */
|
|
199
|
+
putMarkerToMap(lajiFormLocator = "gatherings") {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const $map = this.$locate(lajiFormLocator).locator(".laji-map");
|
|
202
|
+
yield $map.scrollIntoViewIfNeeded();
|
|
203
|
+
const map = new test_utils_1.MapPageObject(this.page, $map);
|
|
204
|
+
yield map.drawMarker();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
updateValue($input, value, blur = true) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
yield $input.fill(value);
|
|
210
|
+
if (blur) {
|
|
211
|
+
yield $input.press("Tab");
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.Form = Form;
|
|
217
|
+
class DemoPageForm extends Form {
|
|
218
|
+
constructor(page, params = {}) {
|
|
219
|
+
super(page);
|
|
220
|
+
this.getMockStr = (path, query) => `window.mockResponses[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
|
|
221
|
+
this.mockImageUpload = (lajiFormLocator) => __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
const filePath = path.resolve(__dirname, "./mocks/pixel.png");
|
|
223
|
+
const imageResponse = [{ name: "data", filename: "pixel.png", id: "mock", expires: 1575979685 }];
|
|
224
|
+
const { resolve, remove } = yield this.setMockResponse("/images", false);
|
|
225
|
+
const mdResponse = require("./mocks/image-metadata.json");
|
|
226
|
+
const { resolve: metadataResolve, remove: metadataRemove } = yield this.setMockResponse("/images/mock", false);
|
|
227
|
+
yield this.getImageArrayField(lajiFormLocator).$dropzone.locator("input").setInputFiles(filePath);
|
|
228
|
+
return {
|
|
229
|
+
resolve: () => __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
yield resolve(imageResponse);
|
|
231
|
+
yield metadataResolve(mdResponse);
|
|
232
|
+
}),
|
|
233
|
+
remove: () => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
yield remove();
|
|
235
|
+
yield metadataRemove();
|
|
236
|
+
})
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
// this.page = page;
|
|
126
240
|
this.props = params;
|
|
127
241
|
}
|
|
128
|
-
initialize(beforeInit
|
|
242
|
+
initialize(beforeInit) {
|
|
129
243
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
244
|
const query = (params) => Object.keys(params).reduce((q, key) => `${q}&${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`, "");
|
|
131
245
|
if (this.props.id) {
|
|
132
246
|
const _a = this.props, { id } = _a, _props = __rest(_a, ["id"]);
|
|
133
|
-
yield exports.navigateToForm(id, query(_props));
|
|
247
|
+
yield exports.navigateToForm(this.page, id, query(_props));
|
|
134
248
|
}
|
|
135
249
|
else {
|
|
136
|
-
yield exports.emptyForm();
|
|
250
|
+
yield exports.emptyForm(this.page);
|
|
137
251
|
}
|
|
138
252
|
beforeInit && (yield beforeInit(this));
|
|
139
253
|
yield this.setState(this.props);
|
|
140
|
-
this.contextId = contextId !== null && contextId !== void 0 ? contextId : yield this.e("lajiForm._id");
|
|
141
254
|
});
|
|
142
255
|
}
|
|
143
256
|
e(path) {
|
|
144
|
-
return
|
|
257
|
+
return this.page.evaluate(`window.lajiForm.${path}`);
|
|
145
258
|
}
|
|
146
259
|
setState(state) {
|
|
147
260
|
const onSubmit = "function(data) {window.submittedData = data.formData;}";
|
|
@@ -149,51 +262,32 @@ class Form {
|
|
|
149
262
|
return this.e(`setState({onSubmit: ${onSubmit}, onChange: ${onChange}, ...${JSON.stringify(state)}})`);
|
|
150
263
|
}
|
|
151
264
|
getState() {
|
|
152
|
-
return
|
|
153
|
-
|
|
265
|
+
return this.page.evaluate(() => {
|
|
266
|
+
const { formData } = window.lajiForm.lajiForm.state;
|
|
267
|
+
return { formData };
|
|
154
268
|
});
|
|
155
269
|
}
|
|
156
270
|
submit() {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
yield this.e("submit()");
|
|
159
|
-
yield waitUntilBlockingLoaderHides();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
startSubmit() {
|
|
163
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
272
|
yield this.e("submit()");
|
|
165
273
|
});
|
|
166
274
|
}
|
|
167
275
|
submitOnlySchemaValidations() {
|
|
168
|
-
return
|
|
169
|
-
yield this.e("submitOnlySchemaValidations()");
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
waitUntilBlockingLoaderHides(timeout) {
|
|
173
|
-
return waitUntilBlockingLoaderHides(timeout);
|
|
276
|
+
return this.e("submitOnlySchemaValidations()");
|
|
174
277
|
}
|
|
175
278
|
getSubmittedData() {
|
|
176
|
-
return
|
|
279
|
+
return this.page.evaluate("window.submittedData");
|
|
177
280
|
}
|
|
178
281
|
getChangedData() {
|
|
179
|
-
return
|
|
282
|
+
return this.page.evaluate("window.changedData");
|
|
180
283
|
}
|
|
181
284
|
getPropsData() {
|
|
182
285
|
return this.e("lajiForm.props.formData");
|
|
183
286
|
}
|
|
184
|
-
$locate(path) {
|
|
185
|
-
return protractor_1.$(exports.getLocatorForContextId(this.contextId)(path));
|
|
186
|
-
}
|
|
187
|
-
$locateButton(path, selector) {
|
|
188
|
-
return protractor_1.$(`#root${typeof path === "string" && path.length > 0 ? `_${path.replace(/\./g, "_")}` : ""}-${selector}`);
|
|
189
|
-
}
|
|
190
|
-
$locateAddition(path, selector) {
|
|
191
|
-
return this.$locateButton(path, selector);
|
|
192
|
-
}
|
|
193
287
|
setMockResponse(path, query) {
|
|
194
288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
yield
|
|
196
|
-
const mock = (method, response, raw) =>
|
|
289
|
+
yield this.page.evaluate(`window.setMockResponse(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
|
|
290
|
+
const mock = (method, response, raw) => this.page.evaluate(`${this.getMockStr(path, query)}.${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
|
|
197
291
|
return {
|
|
198
292
|
resolve: (response, raw) => mock("resolve", response, raw),
|
|
199
293
|
reject: (response, raw) => mock("reject", response, raw),
|
|
@@ -203,15 +297,15 @@ class Form {
|
|
|
203
297
|
}
|
|
204
298
|
createMockResponseQueue(path, query) {
|
|
205
299
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
yield
|
|
300
|
+
yield this.page.evaluate(`window.createMockResponseQueue(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
|
|
207
301
|
const queueStr = `window.mockQueues[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
|
|
208
302
|
const mock = (method, response, raw, pointer) => {
|
|
209
|
-
return
|
|
303
|
+
return this.page.evaluate(`${this.getMockStr(path, query)}[${pointer}].${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
|
|
210
304
|
};
|
|
211
305
|
let pointer = 0;
|
|
212
306
|
return {
|
|
213
307
|
create: () => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
yield
|
|
308
|
+
yield this.page.evaluate(`${queueStr}.create()`);
|
|
215
309
|
const _pointer = pointer;
|
|
216
310
|
pointer = pointer + 1;
|
|
217
311
|
return {
|
|
@@ -219,127 +313,20 @@ class Form {
|
|
|
219
313
|
reject: (response, raw) => mock("reject", response, raw, _pointer),
|
|
220
314
|
};
|
|
221
315
|
}),
|
|
222
|
-
remove: () =>
|
|
316
|
+
remove: () => this.page.evaluate(`${queueStr}.remove()`)
|
|
223
317
|
};
|
|
224
318
|
});
|
|
225
319
|
}
|
|
226
|
-
getBooleanWidget(str) {
|
|
227
|
-
const $container = this.$locate(str).$(".btn-toolbar");
|
|
228
|
-
return {
|
|
229
|
-
$container,
|
|
230
|
-
$true: $container.$$(".btn").get(0),
|
|
231
|
-
$false: $container.$$(".btn").get(1),
|
|
232
|
-
$undefined: this.$locate(str).$$(".btn").get(2),
|
|
233
|
-
$active: $container.$(".btn.active"),
|
|
234
|
-
$nonactive: $container.$$(".btn").filter(($btn) => __awaiter(this, void 0, void 0, function* () { return !(yield $btn.getAttribute("class")).includes("active"); })).first()
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
$getInputWidget(str) {
|
|
238
|
-
return this.$locate(str).$("input");
|
|
239
|
-
}
|
|
240
|
-
$getTextareaWidget(str) {
|
|
241
|
-
return this.$locate(str).$("textarea");
|
|
242
|
-
}
|
|
243
|
-
$getEnumWidget(str) {
|
|
244
|
-
const $container = this.$locate(str).$(".rw-combobox");
|
|
245
|
-
return getEnumWidgetForContainer($container);
|
|
246
|
-
}
|
|
247
|
-
getDateWidget(str) {
|
|
248
|
-
const $widget = this.$locate(str).$(".date-widget");
|
|
249
|
-
return {
|
|
250
|
-
$container: $widget,
|
|
251
|
-
$input: $widget.$("input"),
|
|
252
|
-
buttons: {
|
|
253
|
-
$today: $widget.$(".today"),
|
|
254
|
-
$yesterday: $widget.$(".yesterday"),
|
|
255
|
-
$same: $widget.$(".same"),
|
|
256
|
-
$date: $widget.$(".rw-i-calendar"),
|
|
257
|
-
$time: $widget.$(".rw-i-clock-o")
|
|
258
|
-
},
|
|
259
|
-
calendar: {
|
|
260
|
-
$today: $widget.$(".rw-calendar-footer button"),
|
|
261
|
-
waitAnimation: () => protractor_1.browser.wait(exports.EC.visibilityOf($widget.$(".rw-calendar-footer button")), 1000, "Calendar didn't show")
|
|
262
|
-
},
|
|
263
|
-
clock: {
|
|
264
|
-
"$01:00": $widget.$$(".rw-list li").get(2),
|
|
265
|
-
waitAnimation: () => protractor_1.browser.wait(exports.EC.visibilityOf($widget.$(".rw-list")), 1000, "Clock didn't show")
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
$$getFieldErrors(str) {
|
|
270
|
-
return this.$locate(str).$$(".laji-form-error-container li");
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
exports.Form = Form;
|
|
274
|
-
const isDisplayed = ($elem) => __awaiter(void 0, void 0, void 0, function* () { return (yield $elem.isPresent()) && (yield $elem.isDisplayed()); });
|
|
275
|
-
exports.isDisplayed = isDisplayed;
|
|
276
|
-
const $mapPopupContainer = protractor_1.$(".named-place-popup");
|
|
277
|
-
const $namedPlaceChooserModal = protractor_1.$(".named-place-chooser-modal");
|
|
278
|
-
class NamedPlaceChooserPO {
|
|
279
|
-
constructor() {
|
|
280
|
-
this.select = getEnumWidgetForContainer(protractor_1.$("#named-place-chooser-select"));
|
|
281
|
-
this.mapPopup = {
|
|
282
|
-
$container: $mapPopupContainer,
|
|
283
|
-
$useBtn: $mapPopupContainer.$(".btn-default")
|
|
284
|
-
};
|
|
285
|
-
this.$alert = $namedPlaceChooserModal.$(".alert");
|
|
286
|
-
this.$close = $namedPlaceChooserModal.$(".close");
|
|
287
|
-
}
|
|
288
320
|
}
|
|
289
|
-
exports.
|
|
290
|
-
function createForm(props, beforeInit) {
|
|
321
|
+
exports.DemoPageForm = DemoPageForm;
|
|
322
|
+
function createForm(page, props, beforeInit) {
|
|
291
323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
const form = new
|
|
324
|
+
const form = new DemoPageForm(page, props);
|
|
293
325
|
yield form.initialize(beforeInit);
|
|
294
326
|
return form;
|
|
295
327
|
});
|
|
296
328
|
}
|
|
297
329
|
exports.createForm = createForm;
|
|
298
|
-
function waitUntilBlockingLoaderHides(timeout) {
|
|
299
|
-
return protractor_1.browser.wait(protractor_1.protractor.ExpectedConditions.invisibilityOf(protractor_1.$(".laji-form.blocking-loader")), timeout || 20000, "Blocking loader timeout");
|
|
300
|
-
}
|
|
301
|
-
exports.waitUntilBlockingLoaderHides = waitUntilBlockingLoaderHides;
|
|
302
|
-
function putForeignMarkerToMap() {
|
|
303
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
-
const $gatheringsMap = exports.lajiFormLocate("gatherings").$(".laji-map");
|
|
305
|
-
const $markerButton = protractor_1.$(".leaflet-draw-draw-marker");
|
|
306
|
-
yield $markerButton.click();
|
|
307
|
-
yield protractor_1.browser.actions().mouseMove($gatheringsMap.getWebElement(), { x: -100, y: -100 }).perform();
|
|
308
|
-
yield protractor_1.browser.actions().click().perform();
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
exports.putForeignMarkerToMap = putForeignMarkerToMap;
|
|
312
|
-
function removeUnit(gatheringIdx, unitIdx) {
|
|
313
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
-
yield protractor_1.$(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete`).click();
|
|
315
|
-
return protractor_1.$(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete-confirm-yes`).click();
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
exports.removeUnit = removeUnit;
|
|
319
|
-
const updateValue = ($input, value, blur = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
320
|
-
const current = (yield $input.getAttribute("value")) || "";
|
|
321
|
-
yield $input.click();
|
|
322
|
-
yield $input.sendKeys(...Array(current.length).fill(protractor_1.protractor.Key.BACK_SPACE), value);
|
|
323
|
-
if (blur) {
|
|
324
|
-
return $input.sendKeys(protractor_1.protractor.Key.TAB);
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
exports.updateValue = updateValue;
|
|
328
|
-
exports.mockImageMetadata = {
|
|
329
|
-
"id": "mock",
|
|
330
|
-
"capturerVerbatim": [
|
|
331
|
-
"mock"
|
|
332
|
-
],
|
|
333
|
-
"intellectualOwner": "mock",
|
|
334
|
-
"intellectualRights": "MZ.intellectualRightsCC-BY-SA-4.0",
|
|
335
|
-
"fullURL": "https://imagetest.laji.fi/MM.97056/pixel_full.jpg",
|
|
336
|
-
"largeURL": "https://imagetest.laji.fi/MM.97056/pixel_large.jpg",
|
|
337
|
-
"squareThumbnailURL": "https://imagetest.laji.fi/MM.97056/pixel_square.jpg",
|
|
338
|
-
"thumbnailURL": "https://imagetest.laji.fi/MM.97056/pixel_thumb.jpg",
|
|
339
|
-
"originalURL": "https://imagetest.laji.fi/MM.97056/pixel.png",
|
|
340
|
-
"uploadedBy": "MA.308",
|
|
341
|
-
"@context": "http://schema.laji.fi/context/image-en.jsonld"
|
|
342
|
-
};
|
|
343
330
|
const filterUUIDs = (any) => {
|
|
344
331
|
if (typeof any === "object" && !Array.isArray(any) && any !== null) {
|
|
345
332
|
return Object.keys(any).filter(key => key !== "_lajiFormId").reduce((_any, key) => (Object.assign(Object.assign({}, _any), { [key]: exports.filterUUIDs(any[key]) })), {});
|
|
@@ -352,3 +339,8 @@ const filterUUIDs = (any) => {
|
|
|
352
339
|
exports.filterUUIDs = filterUUIDs;
|
|
353
340
|
const maybeJSONPointerToLocator = (pointer) => pointer[0] === "/" ? pointer.slice(1).replace(/\//g, "_") : pointer;
|
|
354
341
|
exports.maybeJSONPointerToLocator = maybeJSONPointerToLocator;
|
|
342
|
+
const getRemoveUnit = (page) => (gatheringIdx, unitIdx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
343
|
+
yield page.locator(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete`).click();
|
|
344
|
+
return page.locator(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete-confirm-yes`).click();
|
|
345
|
+
});
|
|
346
|
+
exports.getRemoveUnit = getRemoveUnit;
|