@luomus/laji-form 15.1.1 → 15.1.3
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/dist/laji-form.js +1 -1
- package/dist/styles.css +90 -81
- package/package.json +5 -4
- package/test-export/test-utils.d.ts +194 -121
- package/test-export/test-utils.js +221 -207
- package/tsconfig.test.json +1 -1
- 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
- package/xsel -b +0 -9
|
@@ -1,135 +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("Geocoder", () => {
|
|
15
|
-
let form;
|
|
16
|
-
const schema = {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
country: {
|
|
20
|
-
type: "string"
|
|
21
|
-
},
|
|
22
|
-
municipality: {
|
|
23
|
-
type: "string"
|
|
24
|
-
},
|
|
25
|
-
biologicalProvince: {
|
|
26
|
-
type: "string"
|
|
27
|
-
},
|
|
28
|
-
geometry: {
|
|
29
|
-
type: "object",
|
|
30
|
-
properties: {
|
|
31
|
-
coordinates: {
|
|
32
|
-
type: "array",
|
|
33
|
-
items: {
|
|
34
|
-
type: "number"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
type: {
|
|
38
|
-
type: "string"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const uiSchema = {
|
|
45
|
-
"ui:field": "GeocoderField"
|
|
46
|
-
};
|
|
47
|
-
const formData = { geometry: { type: "Point", coordinates: [25, 60] } };
|
|
48
|
-
const response = {
|
|
49
|
-
"status": "OK",
|
|
50
|
-
"results": [
|
|
51
|
-
{
|
|
52
|
-
"address_components": [
|
|
53
|
-
{
|
|
54
|
-
"long_name": "Nylandia",
|
|
55
|
-
"short_name": "N",
|
|
56
|
-
"types": [
|
|
57
|
-
"biogeographicalProvince"
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"types": [
|
|
62
|
-
"biogeographicalProvince"
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"address_components": [
|
|
67
|
-
{
|
|
68
|
-
"short_name": "Helsinki",
|
|
69
|
-
"types": [
|
|
70
|
-
"municipality"
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
"formatted_address": "Helsinki",
|
|
75
|
-
"types": [
|
|
76
|
-
"municipality"
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
};
|
|
81
|
-
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
form = yield test_utils_1.createForm();
|
|
83
|
-
}));
|
|
84
|
-
it("parses location in Finland correctly", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
-
const { resolve, remove } = yield form.setMockResponse("/coordinates/location", false);
|
|
86
|
-
yield form.setState({ schema, uiSchema, formData });
|
|
87
|
-
expect(yield form.$locate("country").$("input").getAttribute("value")).toBe("");
|
|
88
|
-
expect(yield form.$locate("municipality").$("input").getAttribute("value")).toBe("");
|
|
89
|
-
expect(yield form.$locate("biologicalProvince").$("input").getAttribute("value")).toBe("");
|
|
90
|
-
yield resolve(response);
|
|
91
|
-
yield remove();
|
|
92
|
-
expect(yield form.$locate("country").$("input").getAttribute("value")).toBe("Suomi");
|
|
93
|
-
expect(yield form.$locate("municipality").$("input").getAttribute("value")).toBe("Helsinki");
|
|
94
|
-
expect(yield form.$locate("biologicalProvince").$("input").getAttribute("value")).toBe("Nylandia");
|
|
95
|
-
}));
|
|
96
|
-
const $runningJobs = protractor_1.$(".running-jobs");
|
|
97
|
-
it("blocks submit until done", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
-
const { resolve, remove } = yield form.setMockResponse("/coordinates/location", false);
|
|
99
|
-
yield form.setState({ schema, uiSchema, formData });
|
|
100
|
-
yield form.e("submit()");
|
|
101
|
-
expect(yield $runningJobs.isDisplayed()).toBe(true);
|
|
102
|
-
yield resolve(response);
|
|
103
|
-
yield remove();
|
|
104
|
-
expect(yield $runningJobs.isPresent()).toBe(false);
|
|
105
|
-
expect(yield form.$locate("country").$("input").getAttribute("value")).toBe("Suomi");
|
|
106
|
-
expect(yield form.getSubmittedData()).not.toBe(null);
|
|
107
|
-
}));
|
|
108
|
-
describe("rejecting", () => {
|
|
109
|
-
it("blocks submit", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
const { reject, remove } = yield form.setMockResponse("/coordinates/location", false);
|
|
111
|
-
yield form.setState({ schema, uiSchema, formData });
|
|
112
|
-
yield form.setState({ formData: {} });
|
|
113
|
-
yield form.setState({ formData });
|
|
114
|
-
yield form.e("submit()");
|
|
115
|
-
expect(yield form.getSubmittedData()).toBe(null);
|
|
116
|
-
expect(yield $runningJobs.isDisplayed()).toBe(true);
|
|
117
|
-
yield reject();
|
|
118
|
-
yield remove();
|
|
119
|
-
expect(yield protractor_1.$$(".laji-form-failed-jobs-list .list-group-item").count()).toBe(1);
|
|
120
|
-
expect(yield $runningJobs.isPresent()).toBe(false);
|
|
121
|
-
expect(yield form.getSubmittedData()).not.toBe(null);
|
|
122
|
-
}));
|
|
123
|
-
it("and then locating again removes old bg job", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
-
const { resolve, remove } = yield form.setMockResponse("/coordinates/location", false);
|
|
125
|
-
yield form.setState({ schema, uiSchema, formData });
|
|
126
|
-
yield form.e("submit()");
|
|
127
|
-
expect(yield protractor_1.$$(".laji-form-failed-jobs-list .list-group-item").count()).toBe(0);
|
|
128
|
-
expect(yield $runningJobs.isDisplayed()).toBe(true);
|
|
129
|
-
yield resolve(response);
|
|
130
|
-
yield remove();
|
|
131
|
-
expect(yield protractor_1.$$(".laji-form-failed-jobs-list .list-group-item").count()).toBe(0);
|
|
132
|
-
expect(yield $runningJobs.isPresent()).toBe(false);
|
|
133
|
-
}));
|
|
134
|
-
});
|
|
135
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,94 +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
|
-
const properties = require("../properties.json");
|
|
15
|
-
describe("Image array", () => {
|
|
16
|
-
let form;
|
|
17
|
-
let imgArrayField;
|
|
18
|
-
const schema = {
|
|
19
|
-
type: "array",
|
|
20
|
-
items: {
|
|
21
|
-
type: "string"
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const uiSchema = {
|
|
25
|
-
"ui:field": "ImageArrayField",
|
|
26
|
-
"ui:options": {
|
|
27
|
-
"deleteConfirmPlacement": "bottom"
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const uiSchemaContext = {
|
|
31
|
-
creator: properties.userId
|
|
32
|
-
};
|
|
33
|
-
describe("", () => {
|
|
34
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
form = yield test_utils_1.createForm();
|
|
36
|
-
yield form.setState({ schema, uiSchema, uiSchemaContext });
|
|
37
|
-
imgArrayField = form.getImageArrayField("");
|
|
38
|
-
}));
|
|
39
|
-
it("renders correctly", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
expect(yield imgArrayField.$container.isDisplayed()).toBe(true);
|
|
41
|
-
expect(yield imgArrayField.$dropzone.isDisplayed()).toBe(true);
|
|
42
|
-
}));
|
|
43
|
-
it("adds image", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
const { resolve, remove } = yield form.mockImageUpload("");
|
|
45
|
-
yield resolve();
|
|
46
|
-
expect(yield imgArrayField.$$imgs.count()).toBe(1);
|
|
47
|
-
yield remove();
|
|
48
|
-
}));
|
|
49
|
-
it("open metadata modal on click", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
const { resolve, remove } = yield form.setMockResponse("/images/mock", false);
|
|
51
|
-
yield imgArrayField.$$imgInteractives.first().click();
|
|
52
|
-
yield resolve(test_utils_1.mockImageMetadata);
|
|
53
|
-
yield protractor_1.browser.wait(protractor_1.protractor.ExpectedConditions.visibilityOf(imgArrayField.$modal), 5000, "metadata modal didn't show up");
|
|
54
|
-
expect(yield imgArrayField.$modal.isDisplayed()).toBe(true);
|
|
55
|
-
yield remove();
|
|
56
|
-
yield imgArrayField.$modalClose.click();
|
|
57
|
-
}));
|
|
58
|
-
it("deletes image", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
yield protractor_1.browser.sleep(1000);
|
|
60
|
-
expect(yield imgArrayField.$$imgs.count()).toBe(1);
|
|
61
|
-
expect(yield imgArrayField.$$imgRemoves.first().isDisplayed()).toBe(true);
|
|
62
|
-
const { resolve, remove } = yield form.setMockResponse("/images/mock", false);
|
|
63
|
-
yield imgArrayField.$$imgRemoves.first().click();
|
|
64
|
-
yield imgArrayField.$imgRemoveConfirmButton("0").click();
|
|
65
|
-
expect(yield imgArrayField.$$imgs.count()).toBe(0);
|
|
66
|
-
yield resolve();
|
|
67
|
-
yield remove();
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
it("Image saves even if the image component unmounts", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
const _schema = {
|
|
72
|
-
type: "array",
|
|
73
|
-
minItems: 1,
|
|
74
|
-
items: {
|
|
75
|
-
type: "object",
|
|
76
|
-
properties: {
|
|
77
|
-
images: schema
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const _uiSchema = {
|
|
82
|
-
items: {
|
|
83
|
-
images: uiSchema
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
yield form.setState({ schema: _schema, uiSchema: _uiSchema, formData: [{}] });
|
|
87
|
-
const { resolve, remove } = yield form.mockImageUpload("0");
|
|
88
|
-
yield form.setState({ uiSchema: Object.assign(Object.assign({}, _uiSchema), { "ui:field": "HiddenField" }) });
|
|
89
|
-
yield resolve();
|
|
90
|
-
yield form.setState({ uiSchema: _uiSchema });
|
|
91
|
-
expect(yield protractor_1.$$(".media-container").count()).toBe(1);
|
|
92
|
-
yield remove();
|
|
93
|
-
}));
|
|
94
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,148 +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
|
-
const merge = require("deepmerge");
|
|
15
|
-
describe("InjectField", () => {
|
|
16
|
-
const schema = {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
a: {
|
|
20
|
-
type: "object",
|
|
21
|
-
properties: {
|
|
22
|
-
aa: {
|
|
23
|
-
type: "object",
|
|
24
|
-
properties: {
|
|
25
|
-
aaa: { type: "string" }
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
ab: { type: "string" }
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
b: {
|
|
32
|
-
type: "object",
|
|
33
|
-
properties: {
|
|
34
|
-
ba: { type: "string" }
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const uiSchemaBase = {
|
|
40
|
-
a: {
|
|
41
|
-
"classNames": "foobar",
|
|
42
|
-
aa: {
|
|
43
|
-
aaa: {
|
|
44
|
-
"classNames": "foo"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
b: {
|
|
49
|
-
ba: {
|
|
50
|
-
"classNames": "bar"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const test = (injections) => {
|
|
55
|
-
let uiSchema = uiSchemaBase;
|
|
56
|
-
for (let injection of injections) {
|
|
57
|
-
const [target, field] = injection;
|
|
58
|
-
uiSchema = merge(uiSchema, {
|
|
59
|
-
"ui:field": "InjectField",
|
|
60
|
-
"ui:options": {
|
|
61
|
-
injections: [
|
|
62
|
-
{
|
|
63
|
-
fields: [field],
|
|
64
|
-
target
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
let form;
|
|
71
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
-
form = yield test_utils_1.createForm({ schema, uiSchema });
|
|
73
|
-
}));
|
|
74
|
-
it("displays all fields and their ids are kept intact", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
for (let locator of ["a", "a.aa", "a.ab", "a.ab", "b", "b.ba"]) {
|
|
76
|
-
expect(yield form.$locate(locator).isPresent()).toBe(true, `${locator} not displayed`);
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
79
|
-
it("displays injected field as child of target", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
-
for (let injection of injections) {
|
|
81
|
-
const [target, field] = injection;
|
|
82
|
-
expect(yield protractor_1.$(test_utils_1.lajiFormLocator(test_utils_1.maybeJSONPointerToLocator(target)))
|
|
83
|
-
.$(test_utils_1.lajiFormLocator(test_utils_1.maybeJSONPointerToLocator(field)))
|
|
84
|
-
.isDisplayed()).toBe(true);
|
|
85
|
-
}
|
|
86
|
-
}));
|
|
87
|
-
it("uiSchema is kept for injected fields and target", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
-
expect(yield form.$locate("a").getAttribute("className")).toMatch(uiSchemaBase.a.classNames);
|
|
89
|
-
expect(yield form.$locate("a.aa.aaa").getAttribute("className")).toMatch(uiSchemaBase.a.aa.aaa.classNames);
|
|
90
|
-
expect(yield form.$locate("b.ba").getAttribute("className")).toMatch(uiSchemaBase.b.ba.classNames);
|
|
91
|
-
}));
|
|
92
|
-
it("modifying formData works and doesn't spill properties", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
-
yield test_utils_1.updateValue(form.$getInputWidget("a.aa.aaa"), "foo");
|
|
94
|
-
yield test_utils_1.updateValue(form.$getInputWidget("a.ab"), "foofoo");
|
|
95
|
-
yield test_utils_1.updateValue(form.$getInputWidget("b.ba"), "bar");
|
|
96
|
-
expect(yield form.$getInputWidget("a.aa.aaa").getAttribute("value")).toBe("foo");
|
|
97
|
-
expect(yield form.$getInputWidget("a.ab").getAttribute("value")).toBe("foofoo");
|
|
98
|
-
expect(yield form.$getInputWidget("b.ba").getAttribute("value")).toBe("bar");
|
|
99
|
-
expect(yield form.getChangedData()).toEqual({
|
|
100
|
-
a: {
|
|
101
|
-
aa: {
|
|
102
|
-
aaa: "foo"
|
|
103
|
-
},
|
|
104
|
-
ab: "foofoo"
|
|
105
|
-
},
|
|
106
|
-
b: {
|
|
107
|
-
ba: "bar"
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}));
|
|
111
|
-
it("errors are rendered", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
-
yield form.setState({ formData: {
|
|
113
|
-
a: {
|
|
114
|
-
aa: {
|
|
115
|
-
aaa: 1
|
|
116
|
-
},
|
|
117
|
-
ab: 1
|
|
118
|
-
},
|
|
119
|
-
b: {
|
|
120
|
-
ba: 1
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
yield form.submit();
|
|
125
|
-
expect(yield form.$$getFieldErrors("a.aa.aaa").count()).toBe(1);
|
|
126
|
-
expect(yield form.$$getFieldErrors("a.ab").count()).toBe(1);
|
|
127
|
-
expect(yield form.$$getFieldErrors("b.ba").count()).toBe(1);
|
|
128
|
-
}));
|
|
129
|
-
};
|
|
130
|
-
describe("simple field, simple target", () => {
|
|
131
|
-
test([["b", "a"]]);
|
|
132
|
-
});
|
|
133
|
-
describe("simple field, simple JSON pointer target", () => {
|
|
134
|
-
test([["/b", "a"]]);
|
|
135
|
-
});
|
|
136
|
-
describe("simple target, JSON pointer field", () => {
|
|
137
|
-
test([["b", "/a/aa/aaa"]]);
|
|
138
|
-
});
|
|
139
|
-
describe("JSON pointer target, JSON Pointer field", () => {
|
|
140
|
-
test([["/a/aa", "/b/ba"]]);
|
|
141
|
-
});
|
|
142
|
-
describe("second injection depending on first injection", () => {
|
|
143
|
-
test([
|
|
144
|
-
["/a/aa", "/a/ab"],
|
|
145
|
-
["/b", "/a/aa"]
|
|
146
|
-
]);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,157 +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
|
-
describe("Internal UUIDs", () => {
|
|
14
|
-
let form;
|
|
15
|
-
const schema = {
|
|
16
|
-
type: "object",
|
|
17
|
-
properties: {
|
|
18
|
-
arrayOfObjects: {
|
|
19
|
-
type: "array",
|
|
20
|
-
items: {
|
|
21
|
-
type: "object",
|
|
22
|
-
properties: {
|
|
23
|
-
string: {
|
|
24
|
-
type: "string"
|
|
25
|
-
},
|
|
26
|
-
innerArrayOfObjects: {
|
|
27
|
-
type: "array",
|
|
28
|
-
items: {
|
|
29
|
-
type: "object",
|
|
30
|
-
properties: {
|
|
31
|
-
string: {
|
|
32
|
-
type: "string"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
object: {
|
|
41
|
-
type: "object",
|
|
42
|
-
properties: {
|
|
43
|
-
innerObject: {
|
|
44
|
-
type: "object",
|
|
45
|
-
properties: {
|
|
46
|
-
arrayOfObjects: {
|
|
47
|
-
type: "array",
|
|
48
|
-
items: {
|
|
49
|
-
type: "object",
|
|
50
|
-
properties: {
|
|
51
|
-
string: {
|
|
52
|
-
type: "string"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
number: {
|
|
62
|
-
type: "number"
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const formData = {
|
|
67
|
-
arrayOfObjects: [
|
|
68
|
-
{
|
|
69
|
-
string: "foo",
|
|
70
|
-
innerArrayOfObjects: [
|
|
71
|
-
{
|
|
72
|
-
string: "foo"
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
object: {
|
|
78
|
-
innerObject: {
|
|
79
|
-
arrayOfObjects: [
|
|
80
|
-
{
|
|
81
|
-
string: "foo"
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
number: 2
|
|
87
|
-
};
|
|
88
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
form = yield test_utils_1.createForm();
|
|
90
|
-
yield form.setState({ schema, formData });
|
|
91
|
-
}));
|
|
92
|
-
it("are generated on initialization", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
-
const { formData } = yield form.getState();
|
|
94
|
-
yield expect(formData.arrayOfObjects[0]._lajiFormId).not.toBe(undefined);
|
|
95
|
-
yield expect(formData.arrayOfObjects[0].innerArrayOfObjects[0]._lajiFormId).not.toBe(undefined);
|
|
96
|
-
yield expect(formData.object.innerObject.arrayOfObjects[0]._lajiFormId).not.toBe(undefined);
|
|
97
|
-
}));
|
|
98
|
-
it("keeps data intact on id generation", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
const { formData } = yield form.getState();
|
|
100
|
-
yield expect(formData.arrayOfObjects[0].string).toBe("foo");
|
|
101
|
-
yield expect(formData.arrayOfObjects[0].innerArrayOfObjects[0].string).toBe("foo");
|
|
102
|
-
yield expect(formData.object.innerObject.arrayOfObjects[0].string).toBe("foo");
|
|
103
|
-
yield expect(formData.number).toBe(2);
|
|
104
|
-
}));
|
|
105
|
-
it("are removed on submit", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
yield form.submit();
|
|
107
|
-
const submitted = yield form.getSubmittedData();
|
|
108
|
-
yield expect(submitted.arrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
109
|
-
yield expect(submitted.arrayOfObjects[0].innerArrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
110
|
-
yield expect(submitted.object.innerObject.arrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
111
|
-
}));
|
|
112
|
-
it("keeps data intact when ids removed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
-
yield form.submit();
|
|
114
|
-
const submitted = yield form.getSubmittedData();
|
|
115
|
-
yield expect(submitted.arrayOfObjects[0].string).toBe("foo");
|
|
116
|
-
yield expect(submitted.arrayOfObjects[0].innerArrayOfObjects[0].string).toBe("foo");
|
|
117
|
-
yield expect(submitted.object.innerObject.arrayOfObjects[0].string).toBe("foo");
|
|
118
|
-
yield expect(submitted.number).toBe(2);
|
|
119
|
-
}));
|
|
120
|
-
it("are removed on change by default", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
-
yield form.$locateButton("arrayOfObjects", "add").click();
|
|
122
|
-
const changed = yield form.getChangedData();
|
|
123
|
-
yield expect(changed.arrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
124
|
-
yield expect(changed.arrayOfObjects[0].innerArrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
125
|
-
yield expect(changed.object.innerObject.arrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
126
|
-
}));
|
|
127
|
-
it("are not removed on change if optimizeOnChange", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
-
yield form.setState({ optimizeOnChange: true });
|
|
129
|
-
yield form.$locateButton("arrayOfObjects", "add").click();
|
|
130
|
-
const changed = yield form.getChangedData();
|
|
131
|
-
yield expect(changed.arrayOfObjects[0]._lajiFormId).not.toBe(undefined);
|
|
132
|
-
yield form.setState({ optimizeOnChange: false });
|
|
133
|
-
}));
|
|
134
|
-
it("are added to new array items", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
yield form.setState({ optimizeOnChange: true, formData: Object.assign({}, formData) });
|
|
136
|
-
yield form.$locateButton("arrayOfObjects", "add").click();
|
|
137
|
-
const changed = yield form.getChangedData();
|
|
138
|
-
yield expect(changed.arrayOfObjects[1]._lajiFormId).not.toBe(undefined);
|
|
139
|
-
}));
|
|
140
|
-
describe("use pre-existing ids", () => {
|
|
141
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
yield form.setState({
|
|
143
|
-
formData: Object.assign(Object.assign({}, formData), { arrayOfObjects: [Object.assign(Object.assign({}, formData.arrayOfObjects[0]), { id: "ID" })] })
|
|
144
|
-
});
|
|
145
|
-
}));
|
|
146
|
-
it("instead of _lajiFormId", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
-
const { formData } = yield form.getState();
|
|
148
|
-
yield expect(formData.arrayOfObjects[0].id).toBe("ID");
|
|
149
|
-
yield expect(formData.arrayOfObjects[0]).not.toContain("_lajiFormId");
|
|
150
|
-
}));
|
|
151
|
-
it("and they are kept intact when ids are removed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
-
yield form.submit();
|
|
153
|
-
const submitted = yield form.getSubmittedData();
|
|
154
|
-
yield expect(submitted.arrayOfObjects[0].id).toBe("ID");
|
|
155
|
-
}));
|
|
156
|
-
});
|
|
157
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +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
|
-
describe("invasive species eradication named place form (MHL.32)", () => {
|
|
14
|
-
it("renders", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
// Just check that no error occurs.
|
|
16
|
-
yield test_utils_1.createForm({ id: "MHL.32", localFormData: true });
|
|
17
|
-
}));
|
|
18
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +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 test_utils_2 = require("laji-map/test-export/test-utils");
|
|
14
|
-
describe("invasive species eradication form (MHL.33)", () => {
|
|
15
|
-
let form;
|
|
16
|
-
it("renders", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
// Just check that no error occurs.
|
|
18
|
-
form = yield test_utils_1.createForm({ id: "MHL.33", localFormData: true });
|
|
19
|
-
}));
|
|
20
|
-
it("geometry can be drawn", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
const map = new test_utils_2.MapPageObject();
|
|
22
|
-
yield map.drawRectangle();
|
|
23
|
-
expect((yield form.getChangedData()).gatherings[0].geometry.geometries[0].type).toBe("Polygon");
|
|
24
|
-
}));
|
|
25
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|