@luomus/laji-form 15.1.1 → 15.1.2
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 +3 -3
- 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
|
@@ -1,204 +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("Array", () => {
|
|
15
|
-
let form;
|
|
16
|
-
describe("copy button", () => {
|
|
17
|
-
const uiSchemaForCopy = (type, filter) => ({
|
|
18
|
-
"ui:options": {
|
|
19
|
-
"buttons": [{
|
|
20
|
-
fn: "copy", type, filter
|
|
21
|
-
}]
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
form = yield test_utils_1.createForm();
|
|
26
|
-
}));
|
|
27
|
-
describe("nested object", () => {
|
|
28
|
-
const schema = {
|
|
29
|
-
type: "array",
|
|
30
|
-
items: {
|
|
31
|
-
type: "object",
|
|
32
|
-
properties: {
|
|
33
|
-
a: { type: "string" },
|
|
34
|
-
b: { type: "string" },
|
|
35
|
-
1: {
|
|
36
|
-
type: "object",
|
|
37
|
-
properties: {
|
|
38
|
-
a: { type: "string" },
|
|
39
|
-
b: { type: "string" },
|
|
40
|
-
2: {
|
|
41
|
-
type: "object",
|
|
42
|
-
properties: {
|
|
43
|
-
a: { type: "string" },
|
|
44
|
-
b: { type: "string" },
|
|
45
|
-
default: { type: "string", default: "default" },
|
|
46
|
-
3: {
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: {
|
|
49
|
-
a: { type: "string" },
|
|
50
|
-
b: { type: "string" },
|
|
51
|
-
default: { type: "string", default: "default" },
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const allButDefaultFilled = [{
|
|
62
|
-
a: "foo",
|
|
63
|
-
b: "foo",
|
|
64
|
-
1: {
|
|
65
|
-
a: "foo",
|
|
66
|
-
b: "foo",
|
|
67
|
-
2: {
|
|
68
|
-
a: "foo",
|
|
69
|
-
b: "foo",
|
|
70
|
-
3: {
|
|
71
|
-
a: "foo",
|
|
72
|
-
b: "foo",
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}];
|
|
77
|
-
it("works with whitelist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
yield form.setState({ schema, formData: allButDefaultFilled, uiSchema: uiSchemaForCopy("whitelist", ["a", "/1/a", "/1/2/a"]) });
|
|
79
|
-
yield form.$locateButton("", "copy").click();
|
|
80
|
-
expect((yield form.getChangedData())[1]).toEqual({
|
|
81
|
-
a: "foo",
|
|
82
|
-
1: {
|
|
83
|
-
a: "foo",
|
|
84
|
-
2: {
|
|
85
|
-
a: "foo",
|
|
86
|
-
default: "default",
|
|
87
|
-
3: {
|
|
88
|
-
default: "default"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}));
|
|
94
|
-
it("works with blacklist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
-
yield form.setState({ schema, formData: allButDefaultFilled, uiSchema: uiSchemaForCopy("blacklist", ["a", "/1/a", "/1/2/a"]) });
|
|
96
|
-
yield form.$locateButton("", "copy").click();
|
|
97
|
-
expect((yield form.getChangedData())[1]).toEqual({
|
|
98
|
-
a: null,
|
|
99
|
-
b: "foo",
|
|
100
|
-
1: {
|
|
101
|
-
a: null,
|
|
102
|
-
b: "foo",
|
|
103
|
-
2: {
|
|
104
|
-
a: null,
|
|
105
|
-
b: "foo",
|
|
106
|
-
default: "default",
|
|
107
|
-
3: {
|
|
108
|
-
a: "foo",
|
|
109
|
-
b: "foo",
|
|
110
|
-
default: "default"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}));
|
|
116
|
-
});
|
|
117
|
-
describe("copying form nonexisting array item", () => {
|
|
118
|
-
const schema = {
|
|
119
|
-
type: "array",
|
|
120
|
-
items: {
|
|
121
|
-
type: "object",
|
|
122
|
-
properties: {
|
|
123
|
-
arr: {
|
|
124
|
-
type: "array",
|
|
125
|
-
items: {
|
|
126
|
-
type: "object",
|
|
127
|
-
properties: {
|
|
128
|
-
a: { type: "string" },
|
|
129
|
-
b: { type: "string" },
|
|
130
|
-
default: { type: "string", default: "default" }
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const formData = [{
|
|
138
|
-
arr: [{
|
|
139
|
-
a: "foo",
|
|
140
|
-
b: "foo"
|
|
141
|
-
}]
|
|
142
|
-
}];
|
|
143
|
-
it("works with whitelist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
-
yield form.setState({ schema, formData, uiSchema: uiSchemaForCopy("whitelist", ["/arr/0/a", "/arr/1/b"]) });
|
|
145
|
-
yield form.$locateButton("", "copy").click();
|
|
146
|
-
expect((yield form.getChangedData())[1]).toEqual({
|
|
147
|
-
arr: [
|
|
148
|
-
{
|
|
149
|
-
a: "foo",
|
|
150
|
-
default: "default"
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
b: null,
|
|
154
|
-
default: "default"
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
});
|
|
158
|
-
}));
|
|
159
|
-
it("works with blacklist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
-
yield form.setState({ schema, formData, uiSchema: uiSchemaForCopy("blacklist", ["/arr/0/a", "/arr/1/b"]) });
|
|
161
|
-
yield form.$locateButton("", "copy").click();
|
|
162
|
-
expect((yield form.getChangedData())[1]).toEqual({
|
|
163
|
-
arr: [
|
|
164
|
-
{
|
|
165
|
-
a: null,
|
|
166
|
-
b: "foo",
|
|
167
|
-
default: "default"
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
b: null,
|
|
171
|
-
default: "default"
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
});
|
|
175
|
-
}));
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
describe("keyboard shortcut", () => {
|
|
179
|
-
let form;
|
|
180
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
|
-
const shortcuts = { "alt+i": { fn: "insert" } };
|
|
182
|
-
const props = { schema: { type: "array", items: { type: "string" } }, uiSchema: { "ui:shortcuts": shortcuts } };
|
|
183
|
-
form = yield test_utils_1.createForm(props);
|
|
184
|
-
}));
|
|
185
|
-
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
186
|
-
yield form.setState({ formData: [] });
|
|
187
|
-
}));
|
|
188
|
-
describe("insert", () => {
|
|
189
|
-
it("works", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
190
|
-
yield form.$locateButton("", "add").click();
|
|
191
|
-
expect(yield form.$locate("0").isDisplayed()).toBe(true);
|
|
192
|
-
yield protractor_1.browser.driver.switchTo().activeElement().sendKeys(protractor_1.protractor.Key.chord(protractor_1.protractor.Key.ALT, "i"));
|
|
193
|
-
expect(yield form.$locate("1").isDisplayed()).toBe(true);
|
|
194
|
-
}));
|
|
195
|
-
it("keeps entered value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
-
yield form.$locateButton("", "add").click();
|
|
197
|
-
yield protractor_1.browser.driver.switchTo().activeElement().sendKeys("test");
|
|
198
|
-
yield protractor_1.browser.driver.switchTo().activeElement().sendKeys(protractor_1.protractor.Key.chord(protractor_1.protractor.Key.ALT, "i"));
|
|
199
|
-
expect(yield form.$locate("1").isDisplayed()).toBe(true);
|
|
200
|
-
expect(yield form.$getInputWidget("0").getAttribute("value")).toBe("test");
|
|
201
|
-
}));
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,62 +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("Bird point count (MHL.75)", () => {
|
|
15
|
-
let form;
|
|
16
|
-
let $addUnit;
|
|
17
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
form = yield test_utils_1.createForm({ id: "MHL.75" });
|
|
19
|
-
$addUnit = form.$locateButton("gatherings.0.units", "add");
|
|
20
|
-
}));
|
|
21
|
-
it("adds gathering", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
yield test_utils_1.putForeignMarkerToMap();
|
|
23
|
-
expect(yield test_utils_1.isDisplayed(form.$locate("gatherings.0"))).toBe(true);
|
|
24
|
-
}));
|
|
25
|
-
it("adds unit", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
yield $addUnit.click();
|
|
27
|
-
expect(yield test_utils_1.isDisplayed(form.$locate("gatherings.0.units.0"))).toBe(true);
|
|
28
|
-
}));
|
|
29
|
-
it("unit pair count doesn't lose value when typed and new unit entered by shortcut key", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const text = "123";
|
|
31
|
-
yield form.$getInputWidget("gatherings.0.units.0.unitFact.pairCountInner").sendKeys(text);
|
|
32
|
-
yield protractor_1.browser.driver.switchTo().activeElement().sendKeys(protractor_1.protractor.Key.chord(protractor_1.protractor.Key.ALT, "u"));
|
|
33
|
-
expect(yield form.$getInputWidget("gatherings.0.units.0.unitFact.pairCountInner").getAttribute("value")).toBe(text);
|
|
34
|
-
// Cleanup
|
|
35
|
-
yield form.$locateButton("gatherings.0.units.0", "delete").click();
|
|
36
|
-
yield form.$locateButton("gatherings.0.units.0", "delete").click();
|
|
37
|
-
}));
|
|
38
|
-
it("when two units and 1st is removed, the autosuggest input value updated to the value of the 1st", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
const taxonAutosuggest1 = form.getTaxonAutosuggestWidget("gatherings.0.units.0.identifications.0.taxonVerbatim");
|
|
40
|
-
const taxonAutosuggest2 = form.getTaxonAutosuggestWidget("gatherings.0.units.1.identifications.0.taxonVerbatim");
|
|
41
|
-
const mockQueue = yield form.createMockResponseQueue("/autocomplete/taxon");
|
|
42
|
-
const peippoMock = yield mockQueue.create();
|
|
43
|
-
const mustarastasMock = yield mockQueue.create();
|
|
44
|
-
yield $addUnit.click();
|
|
45
|
-
yield test_utils_1.updateValue(taxonAutosuggest1.$input, "peippo");
|
|
46
|
-
yield peippoMock.resolve([{
|
|
47
|
-
key: "MX.36237",
|
|
48
|
-
value: "peippo",
|
|
49
|
-
}]);
|
|
50
|
-
yield taxonAutosuggest1.waitForPopoverToHide();
|
|
51
|
-
yield $addUnit.click();
|
|
52
|
-
yield test_utils_1.updateValue(taxonAutosuggest2.$input, "mustarastas");
|
|
53
|
-
yield mustarastasMock.resolve([{
|
|
54
|
-
key: "MX.33106",
|
|
55
|
-
value: "mustarastas",
|
|
56
|
-
}]);
|
|
57
|
-
yield taxonAutosuggest2.waitForPopoverToHide();
|
|
58
|
-
yield mockQueue.remove();
|
|
59
|
-
yield form.$locateButton("gatherings.0.units.0", "delete").click();
|
|
60
|
-
expect(yield taxonAutosuggest1.$input.getAttribute("value")).toBe("mustarastas");
|
|
61
|
-
}));
|
|
62
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +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("Collection contest form (MHL.25)", () => {
|
|
14
|
-
let form;
|
|
15
|
-
describe("Without data", () => {
|
|
16
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
form = yield test_utils_1.createForm({ id: "MHL.25" });
|
|
18
|
-
}));
|
|
19
|
-
it("adds observation", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
yield form.$locateButton("gatherings", "add").click();
|
|
21
|
-
}));
|
|
22
|
-
it("shows gathering date and hides unit date", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
expect(yield form.$locate("gatherings.0.dateBegin").isDisplayed()).toBe(true);
|
|
24
|
-
expect(yield form.$locate("gatherings.0.units.0.unitGathering.dateBegin").isPresent()).toBe(false);
|
|
25
|
-
}));
|
|
26
|
-
describe("injected date field", () => {
|
|
27
|
-
let dateWidget;
|
|
28
|
-
it("is date widget", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
dateWidget = form.getDateWidget("gatherings.0.dateBegin");
|
|
30
|
-
expect(yield dateWidget.$input.isDisplayed()).toBe(true);
|
|
31
|
-
}));
|
|
32
|
-
it("onChange works", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
yield dateWidget.buttons.$today.click();
|
|
34
|
-
expect((yield dateWidget.$input.getAttribute("value")).length).not.toBe(0);
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,50 +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("dataset form (MHL.731)", () => {
|
|
15
|
-
let form;
|
|
16
|
-
let nameInEnglishInput$;
|
|
17
|
-
let nameInFinnishInput$;
|
|
18
|
-
const uiSchemaContext = {
|
|
19
|
-
defaultPersonsResponsible: "Test, User"
|
|
20
|
-
};
|
|
21
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
form = yield test_utils_1.createForm({ id: "MHL.731" });
|
|
23
|
-
yield form.setState({ uiSchemaContext });
|
|
24
|
-
nameInEnglishInput$ = form.$locate("datasetName_en").$("input");
|
|
25
|
-
nameInFinnishInput$ = form.$locate("datasetName_fi").$("input");
|
|
26
|
-
}));
|
|
27
|
-
it("sets correct name to dataset when adding a name in one language", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
const name = "name";
|
|
29
|
-
yield nameInEnglishInput$.sendKeys(name + protractor_1.protractor.Key.TAB);
|
|
30
|
-
const formData = yield form.getChangedData();
|
|
31
|
-
expect(formData.datasetName["en"]).toBe(name);
|
|
32
|
-
}));
|
|
33
|
-
it("sets correct name to dataset when adding a name in two languages", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const name1 = "name in English";
|
|
35
|
-
const name2 = "name in Finnish";
|
|
36
|
-
yield nameInEnglishInput$.clear();
|
|
37
|
-
yield nameInEnglishInput$.sendKeys(name1);
|
|
38
|
-
yield nameInFinnishInput$.sendKeys(name2 + protractor_1.protractor.Key.TAB);
|
|
39
|
-
const formData = yield form.getChangedData();
|
|
40
|
-
expect(formData.datasetName["en"]).toBe(name1);
|
|
41
|
-
expect(formData.datasetName["fi"]).toBe(name2);
|
|
42
|
-
}));
|
|
43
|
-
it("sets correct name to personsResponsible field when clicking a me button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
yield form.$locate("personsResponsible").$("button").click();
|
|
45
|
-
const $input = form.$locate("personsResponsible").$("input");
|
|
46
|
-
expect(yield $input.getAttribute("value")).toBe("Test, User");
|
|
47
|
-
const formData = yield form.getChangedData();
|
|
48
|
-
expect(formData.personsResponsible).toBe("Test, User");
|
|
49
|
-
}));
|
|
50
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,188 +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 moment = require("moment");
|
|
14
|
-
describe("Date & time widgets", () => {
|
|
15
|
-
let form;
|
|
16
|
-
let widget;
|
|
17
|
-
const schema = {
|
|
18
|
-
type: "string"
|
|
19
|
-
};
|
|
20
|
-
const formData = null;
|
|
21
|
-
const today = moment();
|
|
22
|
-
const today0100 = moment(`${moment().format("YYYY-MM-DD")}T01:00`);
|
|
23
|
-
const yesterday = moment().add(-1, "days");
|
|
24
|
-
const ISO8601DateFormat = "YYYY-MM-DD";
|
|
25
|
-
const ISO8601TimeFormat = "HH:mm";
|
|
26
|
-
const ISO8601FullFormat = `${ISO8601DateFormat}T${ISO8601TimeFormat}`;
|
|
27
|
-
const displayDateFormat = "DD.MM.YYYY";
|
|
28
|
-
const displayTimeFormat = "HH.mm";
|
|
29
|
-
const displayFullFormat = `${displayDateFormat}, ${displayTimeFormat}`;
|
|
30
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
form = yield test_utils_1.createForm();
|
|
32
|
-
widget = form.getDateWidget("");
|
|
33
|
-
}));
|
|
34
|
-
describe("DateTimeWidget", () => {
|
|
35
|
-
const uiSchema = {
|
|
36
|
-
"ui:widget": "DateTimeWidget",
|
|
37
|
-
};
|
|
38
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
yield form.setState({ schema, uiSchema, formData });
|
|
40
|
-
}));
|
|
41
|
-
it("renders date button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$date)).toBe(true);
|
|
43
|
-
}));
|
|
44
|
-
it("renders time button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$time)).toBe(true);
|
|
46
|
-
}));
|
|
47
|
-
it("selecting date from calendar adds only date", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
yield widget.buttons.$date.click();
|
|
49
|
-
yield widget.calendar.waitAnimation();
|
|
50
|
-
yield widget.calendar.$today.click();
|
|
51
|
-
expect(yield widget.$input.getAttribute("value")).toBe(today.format(displayDateFormat));
|
|
52
|
-
expect(yield form.getChangedData()).toBe(today.format(ISO8601DateFormat));
|
|
53
|
-
}));
|
|
54
|
-
it("selecting time adds time", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
yield widget.buttons.$time.click();
|
|
56
|
-
yield widget.clock.waitAnimation();
|
|
57
|
-
yield widget.clock["$01:00"].click();
|
|
58
|
-
expect(yield widget.$input.getAttribute("value")).toBe(today0100.format(displayFullFormat));
|
|
59
|
-
expect(yield form.getChangedData()).toBe(today0100.format(ISO8601FullFormat));
|
|
60
|
-
}));
|
|
61
|
-
it("time can be typed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
yield test_utils_1.updateValue(widget.$input, `${today.format(displayDateFormat)}, 10`);
|
|
63
|
-
expect(yield widget.$input.getAttribute("value")).toBe(`${today.format(displayDateFormat)}, 10.00`);
|
|
64
|
-
expect(yield form.getChangedData()).toBe(`${today.format(ISO8601DateFormat)}T10:00`);
|
|
65
|
-
}));
|
|
66
|
-
it("time can be removed by clearing it from input", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
yield test_utils_1.updateValue(widget.$input, today.format(displayDateFormat));
|
|
68
|
-
expect(yield widget.$input.getAttribute("value")).toBe(today.format(displayDateFormat));
|
|
69
|
-
expect(yield form.getChangedData()).toBe(today.format(ISO8601DateFormat));
|
|
70
|
-
}));
|
|
71
|
-
it("whole value can be cleared", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
-
yield test_utils_1.updateValue(widget.$input, "");
|
|
73
|
-
expect(yield widget.$input.getAttribute("value")).toBe("");
|
|
74
|
-
expect(yield form.getChangedData()).toBe(null);
|
|
75
|
-
}));
|
|
76
|
-
it("date can be typed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
-
yield test_utils_1.updateValue(widget.$input, "2.4.2012");
|
|
78
|
-
expect(yield widget.$input.getAttribute("value")).toBe("02.04.2012");
|
|
79
|
-
expect(yield form.getChangedData()).toBe("2012-04-02");
|
|
80
|
-
}));
|
|
81
|
-
describe("today & yesterday buttons", () => {
|
|
82
|
-
it("not displayed by default", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$today)).toBe(false);
|
|
84
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$yesterday)).toBe(false);
|
|
85
|
-
}));
|
|
86
|
-
it("displayed if showButtons true", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
-
yield form.setState({ uiSchema: Object.assign(Object.assign({}, uiSchema), { "ui:options": { showButtons: true } }) });
|
|
88
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$today)).toBe(true);
|
|
89
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$yesterday)).toBe(true);
|
|
90
|
-
}));
|
|
91
|
-
it("yesterday works", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
-
yield widget.buttons.$yesterday.click();
|
|
93
|
-
expect(yield widget.$input.getAttribute("value")).toBe(yesterday.format(displayDateFormat));
|
|
94
|
-
expect(yield form.getChangedData()).toBe(yesterday.format(ISO8601DateFormat));
|
|
95
|
-
}));
|
|
96
|
-
it("today works", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
yield widget.buttons.$today.click();
|
|
98
|
-
expect(yield widget.$input.getAttribute("value")).toBe(today.format(displayDateFormat));
|
|
99
|
-
expect(yield form.getChangedData()).toBe(today.format(ISO8601DateFormat));
|
|
100
|
-
}));
|
|
101
|
-
});
|
|
102
|
-
describe("typing only year when option allowOnlyYear", () => {
|
|
103
|
-
const year = "" + moment().year();
|
|
104
|
-
it("is off should enter full date", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
-
yield test_utils_1.updateValue(widget.$input, year);
|
|
106
|
-
expect(yield widget.$input.getAttribute("value")).toBe(`01.01.${year}`);
|
|
107
|
-
expect(yield form.getChangedData()).toBe(today.format(`${year}-01-01`));
|
|
108
|
-
}));
|
|
109
|
-
it("is on works", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
yield form.setState({ uiSchema: Object.assign(Object.assign({}, uiSchema), { "ui:options": { allowOnlyYear: true } }) });
|
|
111
|
-
yield test_utils_1.updateValue(widget.$input, year);
|
|
112
|
-
expect(yield widget.$input.getAttribute("value")).toBe(year);
|
|
113
|
-
expect(yield form.getChangedData()).toBe(year);
|
|
114
|
-
}));
|
|
115
|
-
});
|
|
116
|
-
describe("same button", () => {
|
|
117
|
-
let startWidget;
|
|
118
|
-
let endWidget;
|
|
119
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
-
yield form.setState({
|
|
121
|
-
schema: { type: "object", properties: { start: { type: "string" }, end: { type: "string" } } },
|
|
122
|
-
uiSchema: {
|
|
123
|
-
start: Object.assign(Object.assign({}, uiSchema), { "ui:options": { showButtons: true } }),
|
|
124
|
-
end: Object.assign(Object.assign({}, uiSchema), { "ui:options": { showButtons: { same: { path: "/start" } } } })
|
|
125
|
-
},
|
|
126
|
-
formData: {}
|
|
127
|
-
});
|
|
128
|
-
startWidget = form.getDateWidget("start");
|
|
129
|
-
endWidget = form.getDateWidget("end");
|
|
130
|
-
}));
|
|
131
|
-
it("not displayed by if showButtons true", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
-
expect(yield test_utils_1.isDisplayed(startWidget.buttons.$same)).toBe(false);
|
|
133
|
-
}));
|
|
134
|
-
it("displayed if showButtons has {same: true}", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
-
expect(yield test_utils_1.isDisplayed(endWidget.buttons.$same)).toBe(true);
|
|
136
|
-
}));
|
|
137
|
-
it("click works", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
yield test_utils_1.updateValue(startWidget.$input, "2.4.2012");
|
|
139
|
-
yield endWidget.buttons.$same.click();
|
|
140
|
-
expect(yield endWidget.$input.getAttribute("value")).toBe("02.04.2012");
|
|
141
|
-
expect((yield form.getChangedData()).end).toBe("2012-04-02");
|
|
142
|
-
}));
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe("DateWidget", () => {
|
|
146
|
-
const uiSchema = {
|
|
147
|
-
"ui:widget": "DateWidget",
|
|
148
|
-
};
|
|
149
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
-
yield form.setState({ schema, uiSchema, formData });
|
|
151
|
-
}));
|
|
152
|
-
it("renders date button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$date)).toBe(true);
|
|
154
|
-
}));
|
|
155
|
-
it("doesn't render time button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$time)).not.toBe(true);
|
|
157
|
-
}));
|
|
158
|
-
it("clears time if typed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
-
yield test_utils_1.updateValue(widget.$input, `${today.format(displayDateFormat)}, 10.00`);
|
|
160
|
-
expect(yield widget.$input.getAttribute("value")).toBe(today.format(displayDateFormat));
|
|
161
|
-
expect(yield form.getChangedData()).toBe(today.format(ISO8601DateFormat));
|
|
162
|
-
}));
|
|
163
|
-
});
|
|
164
|
-
describe("TimeWidget", () => {
|
|
165
|
-
const uiSchema = {
|
|
166
|
-
"ui:widget": "TimeWidget",
|
|
167
|
-
};
|
|
168
|
-
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
-
yield test_utils_1.updateValue(widget.$input, "");
|
|
170
|
-
yield form.setState({ schema, uiSchema });
|
|
171
|
-
}));
|
|
172
|
-
it("renders time button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$time)).toBe(true);
|
|
174
|
-
}));
|
|
175
|
-
it("doesn't render date button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$date)).not.toBe(true);
|
|
177
|
-
}));
|
|
178
|
-
it("time can be typed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
-
yield test_utils_1.updateValue(widget.$input, "10.00");
|
|
180
|
-
expect(yield widget.$input.getAttribute("value")).toBe("10.00");
|
|
181
|
-
expect(yield form.getChangedData()).toBe("10:00");
|
|
182
|
-
}));
|
|
183
|
-
it("showTimeList hides time button", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
184
|
-
yield form.setState({ uiSchema: Object.assign(Object.assign({}, uiSchema), { "ui:options": { showTimeList: false } }) });
|
|
185
|
-
expect(yield test_utils_1.isDisplayed(widget.buttons.$time)).toBe(false);
|
|
186
|
-
}));
|
|
187
|
-
});
|
|
188
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|