@sprucelabs/heartwood-view-controllers 111.1.34 → 111.1.35
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/build/esm/tests/utilities/buttonAssert.d.ts +2 -2
- package/build/esm/tests/utilities/buttonAssert.js +18 -1
- package/build/esm/tests/utilities/interactor.js +3 -3
- package/build/tests/utilities/buttonAssert.d.ts +2 -2
- package/build/tests/utilities/buttonAssert.js +16 -0
- package/build/tests/utilities/interactor.js +3 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Card, FormViewController, Navigation, ViewController } from '../../types/heartwood.types';
|
|
1
|
+
import { Button, Card, FormViewController, Navigation, SkillViewController, ViewController } from '../../types/heartwood.types';
|
|
2
2
|
import BigFormViewController from '../../viewControllers/BigForm.vc';
|
|
3
3
|
import ButtonBarViewController from '../../viewControllers/ButtonBar.vc';
|
|
4
4
|
import ButtonGroupViewController from '../../viewControllers/ButtonGroup.vc';
|
|
@@ -20,7 +20,7 @@ declare const buttonAssert: {
|
|
|
20
20
|
buttonIsSelected(vc: ViewController<Card>, id: string): void;
|
|
21
21
|
};
|
|
22
22
|
export default buttonAssert;
|
|
23
|
-
export declare function pluckButtons(vc: ViewController<Card> | ViewController<Navigation> | FormViewController<any> | BigFormViewController<any
|
|
23
|
+
export declare function pluckButtons(vc: ViewController<Card> | ViewController<Navigation> | FormViewController<any> | BigFormViewController<any> | SkillViewController, ids: string[]): {
|
|
24
24
|
found: string[];
|
|
25
25
|
missing: string[];
|
|
26
26
|
foundButtons: Button[];
|
|
@@ -114,9 +114,26 @@ const buttonAssert = {
|
|
|
114
114
|
};
|
|
115
115
|
export default buttonAssert;
|
|
116
116
|
export function pluckButtons(vc, ids) {
|
|
117
|
-
var _a
|
|
117
|
+
var _a;
|
|
118
118
|
assertOptions({ vc, ids }, ['vc', 'ids']);
|
|
119
119
|
const model = renderUtil.render(vc);
|
|
120
|
+
//@ts-ignore
|
|
121
|
+
if (model.layouts) {
|
|
122
|
+
const sv = model;
|
|
123
|
+
for (const layout of (_a = sv.layouts) !== null && _a !== void 0 ? _a : []) {
|
|
124
|
+
const cards = layout === null || layout === void 0 ? void 0 : layout.cards;
|
|
125
|
+
for (const card of cards !== null && cards !== void 0 ? cards : []) {
|
|
126
|
+
const results = pluckButtonsFromViewModel(card, ids);
|
|
127
|
+
if (results.found.length > 0) {
|
|
128
|
+
return results;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return pluckButtonsFromViewModel(model, ids);
|
|
134
|
+
}
|
|
135
|
+
function pluckButtonsFromViewModel(model, ids) {
|
|
136
|
+
var _a, _b, _c, _d;
|
|
120
137
|
const buttons = [
|
|
121
138
|
//@ts-ignore
|
|
122
139
|
...((_d = (_b = (_a = model.criticalError) === null || _a === void 0 ? void 0 : _a.buttons) !== null && _b !== void 0 ? _b : (_c = model.footer) === null || _c === void 0 ? void 0 : _c.buttons) !== null && _d !== void 0 ? _d : []),
|
|
@@ -66,7 +66,7 @@ const interactor = {
|
|
|
66
66
|
},
|
|
67
67
|
clickButton(vc, buttonId) {
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const match =
|
|
69
|
+
const match = pluckButtonFromView(vc, buttonId);
|
|
70
70
|
yield this.click(match);
|
|
71
71
|
});
|
|
72
72
|
},
|
|
@@ -86,7 +86,7 @@ const interactor = {
|
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
87
|
var _a, _b;
|
|
88
88
|
assertOptions({ vc, buttonId }, ['vc', 'buttonId']);
|
|
89
|
-
const button =
|
|
89
|
+
const button = pluckButtonFromView(vc, buttonId);
|
|
90
90
|
assert.isTrue(button.shouldShowHintIcon, `Make sure have 'shouldShowHintIcon' set to true in your button: '${buttonId}'`);
|
|
91
91
|
assert.isFunction(button.onClickHintIcon, `You gotta set 'onClickHintIcon' on your button with the id: '${(_a = button.id) !== null && _a !== void 0 ? _a : '***missing***'}'`);
|
|
92
92
|
return (_b = button.onClickHintIcon) === null || _b === void 0 ? void 0 : _b.call(button);
|
|
@@ -412,7 +412,7 @@ const interactor = {
|
|
|
412
412
|
},
|
|
413
413
|
};
|
|
414
414
|
export default interactor;
|
|
415
|
-
function
|
|
415
|
+
function pluckButtonFromView(vc, buttonId) {
|
|
416
416
|
const { foundButtons } = pluckButtons(vc, [buttonId]);
|
|
417
417
|
const match = foundButtons[0];
|
|
418
418
|
assert.isTruthy(match, `Could not find a button in '${getVcName(vc)}' with the id '${buttonId}'`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Card, FormViewController, Navigation, ViewController } from '../../types/heartwood.types';
|
|
1
|
+
import { Button, Card, FormViewController, Navigation, SkillViewController, ViewController } from '../../types/heartwood.types';
|
|
2
2
|
import BigFormViewController from '../../viewControllers/BigForm.vc';
|
|
3
3
|
import ButtonBarViewController from '../../viewControllers/ButtonBar.vc';
|
|
4
4
|
import ButtonGroupViewController from '../../viewControllers/ButtonGroup.vc';
|
|
@@ -20,7 +20,7 @@ declare const buttonAssert: {
|
|
|
20
20
|
buttonIsSelected(vc: ViewController<Card>, id: string): void;
|
|
21
21
|
};
|
|
22
22
|
export default buttonAssert;
|
|
23
|
-
export declare function pluckButtons(vc: ViewController<Card> | ViewController<Navigation> | FormViewController<any> | BigFormViewController<any
|
|
23
|
+
export declare function pluckButtons(vc: ViewController<Card> | ViewController<Navigation> | FormViewController<any> | BigFormViewController<any> | SkillViewController, ids: string[]): {
|
|
24
24
|
found: string[];
|
|
25
25
|
missing: string[];
|
|
26
26
|
foundButtons: Button[];
|
|
@@ -116,6 +116,22 @@ exports.default = buttonAssert;
|
|
|
116
116
|
function pluckButtons(vc, ids) {
|
|
117
117
|
(0, schema_1.assertOptions)({ vc, ids }, ['vc', 'ids']);
|
|
118
118
|
const model = render_utility_1.default.render(vc);
|
|
119
|
+
//@ts-ignore
|
|
120
|
+
if (model.layouts) {
|
|
121
|
+
const sv = model;
|
|
122
|
+
for (const layout of sv.layouts ?? []) {
|
|
123
|
+
const cards = layout?.cards;
|
|
124
|
+
for (const card of cards ?? []) {
|
|
125
|
+
const results = pluckButtonsFromViewModel(card, ids);
|
|
126
|
+
if (results.found.length > 0) {
|
|
127
|
+
return results;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return pluckButtonsFromViewModel(model, ids);
|
|
133
|
+
}
|
|
134
|
+
function pluckButtonsFromViewModel(model, ids) {
|
|
119
135
|
const buttons = [
|
|
120
136
|
//@ts-ignore
|
|
121
137
|
...(model.criticalError?.buttons ?? model.footer?.buttons ?? []),
|
|
@@ -59,7 +59,7 @@ const interactor = {
|
|
|
59
59
|
});
|
|
60
60
|
},
|
|
61
61
|
async clickButton(vc, buttonId) {
|
|
62
|
-
const match =
|
|
62
|
+
const match = pluckButtonFromView(vc, buttonId);
|
|
63
63
|
await this.click(match);
|
|
64
64
|
},
|
|
65
65
|
async clickButtonInGroup(buttonGroupVc, buttonIdOrIdx) {
|
|
@@ -74,7 +74,7 @@ const interactor = {
|
|
|
74
74
|
},
|
|
75
75
|
async clickButtonHint(vc, buttonId) {
|
|
76
76
|
(0, schema_1.assertOptions)({ vc, buttonId }, ['vc', 'buttonId']);
|
|
77
|
-
const button =
|
|
77
|
+
const button = pluckButtonFromView(vc, buttonId);
|
|
78
78
|
test_utils_1.assert.isTrue(button.shouldShowHintIcon, `Make sure have 'shouldShowHintIcon' set to true in your button: '${buttonId}'`);
|
|
79
79
|
test_utils_1.assert.isFunction(button.onClickHintIcon, `You gotta set 'onClickHintIcon' on your button with the id: '${button.id ?? '***missing***'}'`);
|
|
80
80
|
return button.onClickHintIcon?.();
|
|
@@ -330,7 +330,7 @@ const interactor = {
|
|
|
330
330
|
},
|
|
331
331
|
};
|
|
332
332
|
exports.default = interactor;
|
|
333
|
-
function
|
|
333
|
+
function pluckButtonFromView(vc, buttonId) {
|
|
334
334
|
const { foundButtons } = (0, buttonAssert_1.pluckButtons)(vc, [buttonId]);
|
|
335
335
|
const match = foundButtons[0];
|
|
336
336
|
test_utils_1.assert.isTruthy(match, `Could not find a button in '${(0, assertSupport_1.getVcName)(vc)}' with the id '${buttonId}'`);
|
package/package.json
CHANGED