@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.
- 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 +177 -150
- package/test-export/test-utils.js +214 -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,245 @@ 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, $locator = page.locator(".laji-form")) {
|
|
47
|
+
this.page = page;
|
|
48
|
+
this.$locator = $locator;
|
|
49
|
+
this.$form = this.$locator.locator(".rjsf");
|
|
57
50
|
this.createValidatorPO = (type) => ({
|
|
58
|
-
|
|
59
|
-
$panel:
|
|
51
|
+
$all: this.$locator.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel .list-group button`),
|
|
52
|
+
$panel: this.$locator.locator(`.laji-form-error-list:not(.laji-form-failed-jobs-list) .${type}-panel`)
|
|
60
53
|
});
|
|
61
54
|
this.errors = this.createValidatorPO("error");
|
|
62
55
|
this.warnings = this.createValidatorPO("warning");
|
|
63
56
|
this.failedJobs = {
|
|
64
|
-
$container:
|
|
57
|
+
$container: this.$locator.locator(".laji-form-failed-jobs-list"),
|
|
58
|
+
$errors: this.$locator.locator(".laji-form-failed-jobs-list").locator(".list-group-item")
|
|
65
59
|
};
|
|
66
|
-
this.$
|
|
67
|
-
this
|
|
68
|
-
this
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
60
|
+
this.$runningJobs = this.$locator.locator(".running-jobs");
|
|
61
|
+
this.$acknowledgeWarnings = this.$locator.locator(".laji-form-warning-list .panel-footer button");
|
|
62
|
+
this.$blocker = this.page.locator(".laji-form.blocking-loader");
|
|
63
|
+
this.$mapFieldFullscreenMap = this.page.locator(".laji-form.fullscreen .laji-form-map");
|
|
64
|
+
this.getImageArrayField = (lajiFormLocator) => {
|
|
65
|
+
const $container = this.$locate(lajiFormLocator).locator(".laji-form-medias");
|
|
66
|
+
const $imgContainers = this.$locate(lajiFormLocator).locator(".media-container");
|
|
67
|
+
const $modal = this.page.locator(".laji-form.media-modal");
|
|
68
|
+
const $addModal = this.page.locator(".laji-form.media-add-modal");
|
|
75
69
|
return {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
$container,
|
|
71
|
+
$imgContainers,
|
|
72
|
+
$imgs: $imgContainers.locator("img"),
|
|
73
|
+
$imgLoading: $imgContainers.locator(".react-spinner"),
|
|
74
|
+
$imgRemoves: $imgContainers.locator(".button-corner"),
|
|
75
|
+
$imgRemoveConfirmButton: (id) => this.$locateAddition(id, "delete-confirm-yes", true),
|
|
76
|
+
$dropzone: this.$locate(lajiFormLocator).locator(".laji-form-drop-zone"),
|
|
77
|
+
$modal,
|
|
78
|
+
$addModal,
|
|
79
|
+
$modalClose: $modal.locator(".modal-header .close"),
|
|
80
|
+
$addModalCancel: $addModal.locator(".cancel")
|
|
85
81
|
};
|
|
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
82
|
};
|
|
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
|
-
}
|
|
83
|
+
this.getTaxonAutosuggestWidget = (lajiFormLocator) => {
|
|
84
|
+
return {
|
|
85
|
+
$input: this.$locate(lajiFormLocator).locator("input"),
|
|
86
|
+
$suggestionsContainer: this.$locate(lajiFormLocator).locator(".rw-list"),
|
|
87
|
+
$suggestions: this.$locate(lajiFormLocator).locator(".rw-list-option"),
|
|
88
|
+
$getGlyph: (glyph) => this.$locate(lajiFormLocator).locator(glyph),
|
|
89
|
+
$suggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-ok"),
|
|
90
|
+
$nonsuggestedGlyph: this.$locate(lajiFormLocator).locator(".glyphicon-warning-sign"),
|
|
91
|
+
$powerUserButton: this.$locator.locator(".power-user-addon")
|
|
92
|
+
};
|
|
113
93
|
};
|
|
114
|
-
this.getTaxonAutosuggestWidget = this._getTaxonAutosuggestWidget(this);
|
|
115
94
|
this.getScopeField = (lajiFormLocator) => ({
|
|
116
95
|
$button: this.$locateButton(lajiFormLocator, "additionals"),
|
|
117
|
-
|
|
96
|
+
$listItems: this.$locate(lajiFormLocator).locator(".dropdown.open li a"),
|
|
97
|
+
modal: {
|
|
98
|
+
$container: this.page.locator(".scope-field-modal"),
|
|
99
|
+
$close: this.page.locator(".scope-field-modal .close"),
|
|
100
|
+
$loadingGroup: this.page.locator(".scope-field-modal .list-group .react-spinner"),
|
|
101
|
+
$groupTitles: this.page.locator(".scope-field-modal .list-group .list-group-item strong"),
|
|
102
|
+
$listItems: this.page.locator(".scope-field-modal .list-group-item"),
|
|
103
|
+
}
|
|
118
104
|
});
|
|
105
|
+
this.getLocationChooser = (lajiFormLocator) => {
|
|
106
|
+
const $peeker = this.$locateButton(lajiFormLocator, "location-peeker", true);
|
|
107
|
+
return {
|
|
108
|
+
$button: this.$locateButton(lajiFormLocator, "location"),
|
|
109
|
+
modal: {
|
|
110
|
+
$container: this.page.locator(".map-dialog"),
|
|
111
|
+
map: new test_utils_1.MapPageObject(this.page, this.page.locator(".map-dialog .laji-map"))
|
|
112
|
+
},
|
|
113
|
+
peeker: {
|
|
114
|
+
$popover: $peeker,
|
|
115
|
+
$map: $peeker.locator(".laji-map"),
|
|
116
|
+
$markers: $peeker.locator(".vector-marker path"),
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
};
|
|
119
120
|
this.getUnitListShorthandArrayField = (lajiFormLocator) => ({
|
|
120
121
|
$button: this.$locateButton(lajiFormLocator, "addUnitList"),
|
|
121
122
|
modal: {
|
|
122
|
-
$input:
|
|
123
|
-
$addButton:
|
|
123
|
+
$input: this.page.locator(".unit-list-shorthand-modal input"),
|
|
124
|
+
$addButton: this.page.locator(".unit-list-shorthand-modal button")
|
|
124
125
|
}
|
|
125
126
|
});
|
|
127
|
+
this.$getShortHandWidget = (lajiFormLocator) => this.$locateAddition(lajiFormLocator, "shortHandText");
|
|
128
|
+
this.getGeocoder = (lajiFormLocator = "") => ({
|
|
129
|
+
$btn: this.$locate(lajiFormLocator).locator(".geocoder-btn"),
|
|
130
|
+
$spinner: this.$locate(lajiFormLocator).locator(".geocoder-btn .react-spinner")
|
|
131
|
+
});
|
|
132
|
+
this.getNamedPlaceChooser = () => {
|
|
133
|
+
const $namedPlaceChooserModal = this.page.locator(".named-place-chooser-modal");
|
|
134
|
+
const $mapPopupContainer = this.page.locator(".named-place-popup");
|
|
135
|
+
return {
|
|
136
|
+
select: getEnumWidgetForContainer(this.page.locator("#named-place-chooser-select")),
|
|
137
|
+
mapPopup: {
|
|
138
|
+
$container: $mapPopupContainer,
|
|
139
|
+
$useBtn: $mapPopupContainer.locator(".btn-default")
|
|
140
|
+
},
|
|
141
|
+
$alert: $namedPlaceChooserModal.locator(".alert"),
|
|
142
|
+
$close: $namedPlaceChooserModal.locator(".close")
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/** Locates a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
|
|
147
|
+
$locate(path) {
|
|
148
|
+
return this.$locator.locator(exports.lajiFormLocator(path));
|
|
149
|
+
}
|
|
150
|
+
/** Locates a button for a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
|
|
151
|
+
$locateButton(path, selector, locateFromBody = false) {
|
|
152
|
+
return (locateFromBody ? this.page : this.$locator).locator(`#root${typeof path === "string" && path.length > 0 ? `_${path.replace(/\./g, "_")}` : ""}-${selector}`);
|
|
153
|
+
}
|
|
154
|
+
/** Locates some additional element for a field with a dot separated identifier, e.g. "gatherings.0.units.1" */
|
|
155
|
+
$locateAddition(path, selector, locateFromBody = false) {
|
|
156
|
+
return this.$locateButton(path, selector, locateFromBody);
|
|
157
|
+
}
|
|
158
|
+
getBooleanWidget(str) {
|
|
159
|
+
const $container = this.$locate(str).locator(".btn-toolbar");
|
|
160
|
+
return {
|
|
161
|
+
$container,
|
|
162
|
+
$true: $container.locator(".btn").nth(0),
|
|
163
|
+
$false: $container.locator(".btn").nth(1),
|
|
164
|
+
$undefined: this.$locate(str).locator(".btn").nth(2),
|
|
165
|
+
$active: $container.locator(".btn.active"),
|
|
166
|
+
$nonactive: $container.locator(".btn:not(.active)").first()
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
$getInputWidget(str) {
|
|
170
|
+
return this.$locate(str).locator("input");
|
|
171
|
+
}
|
|
172
|
+
$getTextareaWidget(str) {
|
|
173
|
+
return this.$locate(str).locator("textarea");
|
|
174
|
+
}
|
|
175
|
+
$getEnumWidget(str) {
|
|
176
|
+
const $container = this.$locate(str).locator(".rw-combobox");
|
|
177
|
+
return getEnumWidgetForContainer($container);
|
|
178
|
+
}
|
|
179
|
+
getDateWidget(str) {
|
|
180
|
+
const $widget = this.$locate(str).locator(".date-widget");
|
|
181
|
+
return {
|
|
182
|
+
$container: $widget,
|
|
183
|
+
$input: $widget.locator("input"),
|
|
184
|
+
buttons: {
|
|
185
|
+
$today: $widget.locator(".today"),
|
|
186
|
+
$yesterday: $widget.locator(".yesterday"),
|
|
187
|
+
$same: $widget.locator(".same"),
|
|
188
|
+
$date: $widget.locator(".rw-i-calendar"),
|
|
189
|
+
$time: $widget.locator(".rw-i-clock-o")
|
|
190
|
+
},
|
|
191
|
+
calendar: {
|
|
192
|
+
$today: $widget.locator(".rw-calendar-footer button"),
|
|
193
|
+
},
|
|
194
|
+
clock: {
|
|
195
|
+
"$01:00": $widget.locator(".rw-list li").nth(2),
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
$getFieldErrors(str) {
|
|
200
|
+
return this.$locate(str).locator(".laji-form-error-container li");
|
|
201
|
+
}
|
|
202
|
+
/** Draws a marker to the center of a laji-map rendered to the given locator. The locator defaults to "gatherings" */
|
|
203
|
+
putMarkerToMap(lajiFormLocator = "gatherings") {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const $map = this.$locate(lajiFormLocator).locator(".laji-map");
|
|
206
|
+
yield $map.scrollIntoViewIfNeeded();
|
|
207
|
+
const map = new test_utils_1.MapPageObject(this.page, $map);
|
|
208
|
+
yield map.drawMarker();
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
updateValue($input, value, blur = true) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
yield $input.fill(value);
|
|
214
|
+
if (blur) {
|
|
215
|
+
yield $input.press("Tab");
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.Form = Form;
|
|
221
|
+
class DemoPageForm extends Form {
|
|
222
|
+
constructor(page, params = {}) {
|
|
223
|
+
super(page);
|
|
224
|
+
this.getMockStr = (path, query) => `window.mockResponses[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
|
|
225
|
+
this.mockImageUpload = (lajiFormLocator) => __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const filePath = path.resolve(__dirname, "./mocks/pixel.png");
|
|
227
|
+
const imageResponse = [{ name: "data", filename: "pixel.png", id: "mock", expires: 1575979685 }];
|
|
228
|
+
const { resolve, remove } = yield this.setMockResponse("/images", false);
|
|
229
|
+
const mdResponse = require("./mocks/image-metadata.json");
|
|
230
|
+
const { resolve: metadataResolve, remove: metadataRemove } = yield this.setMockResponse("/images/mock", false);
|
|
231
|
+
yield this.getImageArrayField(lajiFormLocator).$dropzone.locator("input").setInputFiles(filePath);
|
|
232
|
+
return {
|
|
233
|
+
resolve: () => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
yield resolve(imageResponse);
|
|
235
|
+
yield metadataResolve(mdResponse);
|
|
236
|
+
}),
|
|
237
|
+
remove: () => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
yield remove();
|
|
239
|
+
yield metadataRemove();
|
|
240
|
+
})
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
// this.page = page;
|
|
126
244
|
this.props = params;
|
|
127
245
|
}
|
|
128
|
-
initialize(beforeInit
|
|
246
|
+
initialize(beforeInit) {
|
|
129
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
248
|
const query = (params) => Object.keys(params).reduce((q, key) => `${q}&${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`, "");
|
|
131
249
|
if (this.props.id) {
|
|
132
250
|
const _a = this.props, { id } = _a, _props = __rest(_a, ["id"]);
|
|
133
|
-
yield exports.navigateToForm(id, query(_props));
|
|
251
|
+
yield exports.navigateToForm(this.page, id, query(_props));
|
|
134
252
|
}
|
|
135
253
|
else {
|
|
136
|
-
yield exports.emptyForm();
|
|
254
|
+
yield exports.emptyForm(this.page);
|
|
137
255
|
}
|
|
138
256
|
beforeInit && (yield beforeInit(this));
|
|
139
257
|
yield this.setState(this.props);
|
|
140
|
-
this.contextId = contextId !== null && contextId !== void 0 ? contextId : yield this.e("lajiForm._id");
|
|
141
258
|
});
|
|
142
259
|
}
|
|
143
260
|
e(path) {
|
|
144
|
-
return
|
|
261
|
+
return this.page.evaluate(`window.lajiForm.${path}`);
|
|
145
262
|
}
|
|
146
263
|
setState(state) {
|
|
147
264
|
const onSubmit = "function(data) {window.submittedData = data.formData;}";
|
|
@@ -149,51 +266,32 @@ class Form {
|
|
|
149
266
|
return this.e(`setState({onSubmit: ${onSubmit}, onChange: ${onChange}, ...${JSON.stringify(state)}})`);
|
|
150
267
|
}
|
|
151
268
|
getState() {
|
|
152
|
-
return
|
|
153
|
-
|
|
269
|
+
return this.page.evaluate(() => {
|
|
270
|
+
const { formData } = window.lajiForm.lajiForm.state;
|
|
271
|
+
return { formData };
|
|
154
272
|
});
|
|
155
273
|
}
|
|
156
274
|
submit() {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
yield this.e("submit()");
|
|
159
|
-
yield waitUntilBlockingLoaderHides();
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
startSubmit() {
|
|
163
275
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
276
|
yield this.e("submit()");
|
|
165
277
|
});
|
|
166
278
|
}
|
|
167
279
|
submitOnlySchemaValidations() {
|
|
168
|
-
return
|
|
169
|
-
yield this.e("submitOnlySchemaValidations()");
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
waitUntilBlockingLoaderHides(timeout) {
|
|
173
|
-
return waitUntilBlockingLoaderHides(timeout);
|
|
280
|
+
return this.e("submitOnlySchemaValidations()");
|
|
174
281
|
}
|
|
175
282
|
getSubmittedData() {
|
|
176
|
-
return
|
|
283
|
+
return this.page.evaluate("window.submittedData");
|
|
177
284
|
}
|
|
178
285
|
getChangedData() {
|
|
179
|
-
return
|
|
286
|
+
return this.page.evaluate("window.changedData");
|
|
180
287
|
}
|
|
181
288
|
getPropsData() {
|
|
182
289
|
return this.e("lajiForm.props.formData");
|
|
183
290
|
}
|
|
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
291
|
setMockResponse(path, query) {
|
|
194
292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
yield
|
|
196
|
-
const mock = (method, response, raw) =>
|
|
293
|
+
yield this.page.evaluate(`window.setMockResponse(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
|
|
294
|
+
const mock = (method, response, raw) => this.page.evaluate(`${this.getMockStr(path, query)}.${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
|
|
197
295
|
return {
|
|
198
296
|
resolve: (response, raw) => mock("resolve", response, raw),
|
|
199
297
|
reject: (response, raw) => mock("reject", response, raw),
|
|
@@ -203,15 +301,15 @@ class Form {
|
|
|
203
301
|
}
|
|
204
302
|
createMockResponseQueue(path, query) {
|
|
205
303
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
yield
|
|
304
|
+
yield this.page.evaluate(`window.createMockResponseQueue(${JSON.stringify(path)}, ${JSON.stringify(query)})`);
|
|
207
305
|
const queueStr = `window.mockQueues[window.getMockQueryKey(${JSON.stringify(path)}, ${JSON.stringify(query)})]`;
|
|
208
306
|
const mock = (method, response, raw, pointer) => {
|
|
209
|
-
return
|
|
307
|
+
return this.page.evaluate(`${this.getMockStr(path, query)}[${pointer}].${method}(${JSON.stringify(response)}, ${JSON.stringify(raw)})`);
|
|
210
308
|
};
|
|
211
309
|
let pointer = 0;
|
|
212
310
|
return {
|
|
213
311
|
create: () => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
yield
|
|
312
|
+
yield this.page.evaluate(`${queueStr}.create()`);
|
|
215
313
|
const _pointer = pointer;
|
|
216
314
|
pointer = pointer + 1;
|
|
217
315
|
return {
|
|
@@ -219,127 +317,20 @@ class Form {
|
|
|
219
317
|
reject: (response, raw) => mock("reject", response, raw, _pointer),
|
|
220
318
|
};
|
|
221
319
|
}),
|
|
222
|
-
remove: () =>
|
|
320
|
+
remove: () => this.page.evaluate(`${queueStr}.remove()`)
|
|
223
321
|
};
|
|
224
322
|
});
|
|
225
323
|
}
|
|
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
324
|
}
|
|
273
|
-
exports.
|
|
274
|
-
|
|
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
|
-
}
|
|
289
|
-
exports.NamedPlaceChooserPO = NamedPlaceChooserPO;
|
|
290
|
-
function createForm(props, beforeInit) {
|
|
325
|
+
exports.DemoPageForm = DemoPageForm;
|
|
326
|
+
function createForm(page, props, beforeInit) {
|
|
291
327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
const form = new
|
|
328
|
+
const form = new DemoPageForm(page, props);
|
|
293
329
|
yield form.initialize(beforeInit);
|
|
294
330
|
return form;
|
|
295
331
|
});
|
|
296
332
|
}
|
|
297
333
|
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
334
|
const filterUUIDs = (any) => {
|
|
344
335
|
if (typeof any === "object" && !Array.isArray(any) && any !== null) {
|
|
345
336
|
return Object.keys(any).filter(key => key !== "_lajiFormId").reduce((_any, key) => (Object.assign(Object.assign({}, _any), { [key]: exports.filterUUIDs(any[key]) })), {});
|
|
@@ -352,3 +343,8 @@ const filterUUIDs = (any) => {
|
|
|
352
343
|
exports.filterUUIDs = filterUUIDs;
|
|
353
344
|
const maybeJSONPointerToLocator = (pointer) => pointer[0] === "/" ? pointer.slice(1).replace(/\//g, "_") : pointer;
|
|
354
345
|
exports.maybeJSONPointerToLocator = maybeJSONPointerToLocator;
|
|
346
|
+
const getRemoveUnit = (page) => (gatheringIdx, unitIdx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
347
|
+
yield page.locator(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete`).click();
|
|
348
|
+
return page.locator(`#root_gatherings_${gatheringIdx}_units_${unitIdx}-delete-confirm-yes`).click();
|
|
349
|
+
});
|
|
350
|
+
exports.getRemoveUnit = getRemoveUnit;
|