@shopify/cli-kit 3.47.5 → 3.48.1
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/assets/cli-ruby/lib/project_types/extension/messages/messages.rb +18 -1
- package/assets/cli-ruby/lib/shopify_cli/constants.rb +1 -0
- package/assets/cli-ruby/lib/shopify_cli/environment.rb +7 -0
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +8 -2
- package/dist/private/node/api/graphql.js +8 -1
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/api/urls.d.ts +6 -0
- package/dist/private/node/api/urls.js +16 -0
- package/dist/private/node/api/urls.js.map +1 -0
- package/dist/private/node/api.js +2 -1
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/ui/alert.js +3 -1
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.d.ts +1 -1
- package/dist/private/node/ui/components/Alert.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +7 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js +28 -91
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +317 -257
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js +59 -32
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +62 -22
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.d.ts +12 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js +77 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js +101 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/List.d.ts +1 -0
- package/dist/private/node/ui/components/List.js +2 -2
- package/dist/private/node/ui/components/List.js.map +1 -1
- package/dist/private/node/ui/components/{GitDiff.d.ts → Prompts/GitDiff.d.ts} +4 -2
- package/dist/private/node/ui/components/{GitDiff.js → Prompts/GitDiff.js} +3 -2
- package/dist/private/node/ui/components/Prompts/GitDiff.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/GitDiff.test.d.ts +1 -0
- package/dist/private/node/ui/components/{GitDiff.test.js → Prompts/GitDiff.test.js} +50 -28
- package/dist/private/node/ui/components/Prompts/GitDiff.test.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.d.ts +14 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.js +11 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.test.d.ts +1 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.test.js +21 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.test.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +1 -0
- package/dist/private/node/ui/components/Prompts/InfoTable.js +11 -7
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js +6 -4
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.d.ts +21 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.js +73 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.d.ts +1 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js +129 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js.map +1 -0
- package/dist/private/node/ui/components/Scrollbar.d.ts +10 -0
- package/dist/private/node/ui/components/Scrollbar.js +44 -0
- package/dist/private/node/ui/components/Scrollbar.js.map +1 -0
- package/dist/private/node/ui/components/Scrollbar.test.d.ts +1 -0
- package/dist/private/node/ui/components/Scrollbar.test.js +96 -0
- package/dist/private/node/ui/components/Scrollbar.test.js.map +1 -0
- package/dist/private/node/ui/components/SelectInput.d.ts +3 -6
- package/dist/private/node/ui/components/SelectInput.js +57 -41
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +120 -192
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.d.ts +7 -6
- package/dist/private/node/ui/components/SelectPrompt.js +11 -68
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +135 -65
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Table/Row.js +2 -1
- package/dist/private/node/ui/components/Table/Row.js.map +1 -1
- package/dist/private/node/ui/components/Table/Table.js +2 -1
- package/dist/private/node/ui/components/Table/Table.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.js +1 -8
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.d.ts +1 -0
- package/dist/private/node/ui/components/TextInput.js +10 -4
- package/dist/private/node/ui/components/TextInput.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.test.js +27 -18
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.d.ts +2 -3
- package/dist/private/node/ui/components/TextPrompt.js +18 -16
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +25 -11
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/hooks/use-prompt.d.ts +18 -0
- package/dist/private/node/ui/hooks/use-prompt.js +20 -0
- package/dist/private/node/ui/hooks/use-prompt.js.map +1 -0
- package/dist/private/node/ui/hooks/use-select-state.d.ts +4 -4
- package/dist/private/node/ui/hooks/use-select-state.js +9 -9
- package/dist/private/node/ui/hooks/use-select-state.js.map +1 -1
- package/dist/public/common/object.d.ts +16 -0
- package/dist/public/common/object.js +26 -0
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/string.d.ts +16 -0
- package/dist/public/common/string.js +30 -0
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/analytics.js +3 -1
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/partners.js +11 -2
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/base-command.d.ts +1 -0
- package/dist/public/node/base-command.js +21 -1
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/figures.d.ts +2 -0
- package/dist/public/node/figures.js +3 -0
- package/dist/public/node/figures.js.map +1 -0
- package/dist/public/node/http.js +5 -2
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/metadata.d.ts +2 -1
- package/dist/public/node/metadata.js +5 -2
- package/dist/public/node/metadata.js.map +1 -1
- package/dist/public/node/monorail.d.ts +22 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +2 -0
- package/dist/public/node/node-package-manager.js +5 -2
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.d.ts +1 -1
- package/dist/public/node/output.js +1 -1
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/ruby.d.ts +1 -0
- package/dist/public/node/ruby.js +1 -0
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/system.js +2 -2
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/themes/models/theme.d.ts +2 -1
- package/dist/public/node/themes/models/theme.js +2 -1
- package/dist/public/node/themes/models/theme.js.map +1 -1
- package/dist/public/node/themes/theme-urls.d.ts +1 -0
- package/dist/public/node/themes/theme-urls.js +4 -0
- package/dist/public/node/themes/theme-urls.js.map +1 -1
- package/dist/public/node/themes/themes-api.d.ts +9 -1
- package/dist/public/node/themes/themes-api.js +14 -3
- package/dist/public/node/themes/themes-api.js.map +1 -1
- package/dist/public/node/toml.d.ts +3 -2
- package/dist/public/node/toml.js +5 -2
- package/dist/public/node/toml.js.map +1 -1
- package/dist/public/node/ui.d.ts +82 -27
- package/dist/public/node/ui.js +97 -32
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -14
- package/dist/private/node/ui/components/GitDiff.js.map +0 -1
- package/dist/private/node/ui/components/GitDiff.test.js.map +0 -1
- /package/dist/private/node/ui/components/{GitDiff.test.d.ts → DangerousConfirmationPrompt.test.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SelectInput } from './SelectInput.js';
|
|
2
|
-
import { sendInputAndWait, sendInputAndWaitForChange, waitForInputsToBeReady, render } from '../../testing/ui.js';
|
|
2
|
+
import { sendInputAndWait, sendInputAndWaitForChange, waitForInputsToBeReady, render, getLastFrameAfterUnmount, } from '../../testing/ui.js';
|
|
3
3
|
import { platformAndArch } from '../../../../public/node/os.js';
|
|
4
4
|
import { describe, expect, test, vi } from 'vitest';
|
|
5
5
|
import React from 'react';
|
|
@@ -29,11 +29,11 @@ describe('SelectInput', async () => {
|
|
|
29
29
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
30
30
|
await sendInputAndWaitForChange(renderInstance, ARROW_UP);
|
|
31
31
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
32
|
-
"
|
|
33
|
-
[36m>[39m [
|
|
34
|
-
|
|
32
|
+
" First
|
|
33
|
+
[36m>[39m [36mSecond[39m
|
|
34
|
+
Third
|
|
35
35
|
|
|
36
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
36
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
37
37
|
`);
|
|
38
38
|
expect(onChange).toHaveBeenLastCalledWith(items[1]);
|
|
39
39
|
});
|
|
@@ -57,43 +57,37 @@ describe('SelectInput', async () => {
|
|
|
57
57
|
await waitForInputsToBeReady();
|
|
58
58
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
59
59
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
60
|
-
"
|
|
61
|
-
[36m>[39m [
|
|
62
|
-
|
|
60
|
+
" First
|
|
61
|
+
[36m>[39m [36mSecond[39m
|
|
62
|
+
Third
|
|
63
63
|
|
|
64
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
64
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
65
65
|
`);
|
|
66
66
|
expect(onChange).toHaveBeenCalledWith(items[1]);
|
|
67
67
|
});
|
|
68
|
-
test('
|
|
68
|
+
test('throws an error if a key has more than 1 character', async () => {
|
|
69
69
|
const onChange = vi.fn();
|
|
70
70
|
const items = [
|
|
71
71
|
{
|
|
72
72
|
label: 'First',
|
|
73
73
|
value: 'first',
|
|
74
|
+
key: 'a',
|
|
74
75
|
},
|
|
75
76
|
{
|
|
76
77
|
label: 'Second',
|
|
77
78
|
value: 'second',
|
|
79
|
+
key: 'b',
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
82
|
label: 'Third',
|
|
81
83
|
value: 'third',
|
|
84
|
+
key: 'ab',
|
|
82
85
|
},
|
|
83
86
|
];
|
|
84
87
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: onChange }));
|
|
85
|
-
|
|
86
|
-
await sendInputAndWaitForChange(renderInstance, '2');
|
|
87
|
-
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
88
|
-
" (1) First
|
|
89
|
-
[36m>[39m [36m(2) Second[39m
|
|
90
|
-
(3) Third
|
|
91
|
-
|
|
92
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
93
|
-
`);
|
|
94
|
-
expect(onChange).toHaveBeenCalledWith(items[1]);
|
|
88
|
+
expect(getLastFrameAfterUnmount(renderInstance)).toMatch('SelectInput: Keys must be a single character');
|
|
95
89
|
});
|
|
96
|
-
test(
|
|
90
|
+
test("throws an error if an item has key but others don't", async () => {
|
|
97
91
|
const onChange = vi.fn();
|
|
98
92
|
const items = [
|
|
99
93
|
{
|
|
@@ -105,22 +99,13 @@ describe('SelectInput', async () => {
|
|
|
105
99
|
value: 'second',
|
|
106
100
|
},
|
|
107
101
|
{
|
|
108
|
-
label: '
|
|
109
|
-
value: '
|
|
110
|
-
key: '
|
|
102
|
+
label: 'Third',
|
|
103
|
+
value: 'third',
|
|
104
|
+
key: 'a',
|
|
111
105
|
},
|
|
112
106
|
];
|
|
113
107
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: onChange }));
|
|
114
|
-
|
|
115
|
-
await sendInputAndWaitForChange(renderInstance, '1', '0');
|
|
116
|
-
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
117
|
-
" (1) First
|
|
118
|
-
(2) Second
|
|
119
|
-
[36m>[39m [36m(10) Tenth[39m
|
|
120
|
-
|
|
121
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
122
|
-
`);
|
|
123
|
-
expect(onChange).toHaveBeenCalledWith(items[2]);
|
|
108
|
+
expect(getLastFrameAfterUnmount(renderInstance)).toMatch('SelectInput: All items must have keys if one does');
|
|
124
109
|
});
|
|
125
110
|
test('handles pressing non existing keys', async () => {
|
|
126
111
|
const onChange = vi.fn();
|
|
@@ -141,54 +126,25 @@ describe('SelectInput', async () => {
|
|
|
141
126
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: onChange }));
|
|
142
127
|
await waitForInputsToBeReady();
|
|
143
128
|
// nothing changes when pressing a key that doesn't exist
|
|
144
|
-
await sendInputAndWait(renderInstance,
|
|
129
|
+
await sendInputAndWait(renderInstance, 100, '4');
|
|
145
130
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
146
|
-
"[36m>[39m [
|
|
147
|
-
|
|
148
|
-
|
|
131
|
+
"[36m>[39m [36mFirst[39m
|
|
132
|
+
Second
|
|
133
|
+
Tenth
|
|
149
134
|
|
|
150
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
135
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
151
136
|
`);
|
|
152
137
|
expect(onChange).not.toHaveBeenCalled();
|
|
153
138
|
});
|
|
154
|
-
test('handles custom keys', async () => {
|
|
155
|
-
const onChange = vi.fn();
|
|
156
|
-
const items = [
|
|
157
|
-
{
|
|
158
|
-
label: 'First',
|
|
159
|
-
value: 'first',
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
label: 'Second',
|
|
163
|
-
value: 'second',
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
label: 'Third',
|
|
167
|
-
value: 'third',
|
|
168
|
-
key: 't',
|
|
169
|
-
},
|
|
170
|
-
];
|
|
171
|
-
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: onChange }));
|
|
172
|
-
await waitForInputsToBeReady();
|
|
173
|
-
await sendInputAndWaitForChange(renderInstance, 't');
|
|
174
|
-
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
175
|
-
" (1) First
|
|
176
|
-
(2) Second
|
|
177
|
-
[36m>[39m [36m(t) Third[39m
|
|
178
|
-
|
|
179
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
180
|
-
`);
|
|
181
|
-
expect(onChange).toHaveBeenCalledWith(items[2]);
|
|
182
|
-
});
|
|
183
139
|
const runningOnWindows = platformAndArch().platform === 'windows';
|
|
184
140
|
test.skipIf(runningOnWindows)('support groups', async () => {
|
|
185
141
|
const onChange = vi.fn();
|
|
186
142
|
const items = [
|
|
187
|
-
{ label: 'first', value: 'first', group: 'Automations'
|
|
188
|
-
{ label: 'second', value: 'second', group: 'Automations'
|
|
143
|
+
{ label: 'first', value: 'first', group: 'Automations' },
|
|
144
|
+
{ label: 'second', value: 'second', group: 'Automations' },
|
|
189
145
|
{ label: 'third', value: 'third', group: 'Merchant Admin' },
|
|
190
146
|
{ label: 'fourth', value: 'fourth', group: 'Merchant Admin' },
|
|
191
|
-
{ label: 'fifth', value: 'fifth'
|
|
147
|
+
{ label: 'fifth', value: 'fifth' },
|
|
192
148
|
{ label: 'sixth', value: 'sixth' },
|
|
193
149
|
{ label: 'seventh', value: 'seventh' },
|
|
194
150
|
{ label: 'eighth', value: 'eighth' },
|
|
@@ -198,67 +154,46 @@ describe('SelectInput', async () => {
|
|
|
198
154
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: onChange }));
|
|
199
155
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
200
156
|
" [1mAutomations[22m
|
|
201
|
-
|
|
202
|
-
|
|
157
|
+
[36m>[39m [36mfirst[39m
|
|
158
|
+
second
|
|
203
159
|
|
|
204
160
|
[1mMerchant Admin[22m
|
|
205
|
-
|
|
206
|
-
|
|
161
|
+
third
|
|
162
|
+
fourth
|
|
207
163
|
|
|
208
164
|
[1mOther[22m
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
165
|
+
fifth
|
|
166
|
+
sixth
|
|
167
|
+
seventh
|
|
168
|
+
eighth
|
|
169
|
+
ninth
|
|
170
|
+
tenth
|
|
215
171
|
|
|
216
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
172
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
217
173
|
`);
|
|
218
174
|
await waitForInputsToBeReady();
|
|
219
|
-
await sendInputAndWaitForChange(renderInstance, 'a');
|
|
220
|
-
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
221
|
-
" [1mAutomations[22m
|
|
222
|
-
(f) first
|
|
223
|
-
(s) second
|
|
224
|
-
|
|
225
|
-
[1mMerchant Admin[22m
|
|
226
|
-
(3) third
|
|
227
|
-
(4) fourth
|
|
228
|
-
|
|
229
|
-
[1mOther[22m
|
|
230
|
-
[36m>[39m [36m(a) fifth[39m
|
|
231
|
-
(6) sixth
|
|
232
|
-
(7) seventh
|
|
233
|
-
(8) eighth
|
|
234
|
-
(9) ninth
|
|
235
|
-
(10) tenth
|
|
236
|
-
|
|
237
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
238
|
-
`);
|
|
239
|
-
expect(onChange).toHaveBeenCalledWith(items[4]);
|
|
240
175
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
241
176
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
242
177
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
243
178
|
" [1mAutomations[22m
|
|
244
|
-
|
|
245
|
-
|
|
179
|
+
first
|
|
180
|
+
second
|
|
246
181
|
|
|
247
182
|
[1mMerchant Admin[22m
|
|
248
|
-
|
|
249
|
-
|
|
183
|
+
[36m>[39m [36mthird[39m
|
|
184
|
+
fourth
|
|
250
185
|
|
|
251
186
|
[1mOther[22m
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
187
|
+
fifth
|
|
188
|
+
sixth
|
|
189
|
+
seventh
|
|
190
|
+
eighth
|
|
191
|
+
ninth
|
|
192
|
+
tenth
|
|
258
193
|
|
|
259
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
194
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
260
195
|
`);
|
|
261
|
-
expect(onChange).toHaveBeenLastCalledWith(items[
|
|
196
|
+
expect(onChange).toHaveBeenLastCalledWith(items[2]);
|
|
262
197
|
});
|
|
263
198
|
test('allows disabling shortcuts', async () => {
|
|
264
199
|
const onChange = vi.fn();
|
|
@@ -285,7 +220,7 @@ describe('SelectInput', async () => {
|
|
|
285
220
|
Second
|
|
286
221
|
Third
|
|
287
222
|
|
|
288
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
223
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
289
224
|
`);
|
|
290
225
|
expect(onChange).not.toHaveBeenCalled();
|
|
291
226
|
});
|
|
@@ -307,11 +242,11 @@ describe('SelectInput', async () => {
|
|
|
307
242
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, defaultValue: "second" }));
|
|
308
243
|
await waitForInputsToBeReady();
|
|
309
244
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
310
|
-
"
|
|
311
|
-
[36m>[39m [
|
|
312
|
-
|
|
245
|
+
" First
|
|
246
|
+
[36m>[39m [36mSecond[39m
|
|
247
|
+
Third
|
|
313
248
|
|
|
314
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
249
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
315
250
|
`);
|
|
316
251
|
});
|
|
317
252
|
test('shows if there are more pages', async () => {
|
|
@@ -332,42 +267,41 @@ describe('SelectInput', async () => {
|
|
|
332
267
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, morePagesMessage: "Keep scrolling to see more items", hasMorePages: true }));
|
|
333
268
|
await waitForInputsToBeReady();
|
|
334
269
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
335
|
-
"[36m>[39m [
|
|
336
|
-
|
|
337
|
-
|
|
270
|
+
"[36m>[39m [36mFirst[39m
|
|
271
|
+
Second
|
|
272
|
+
Third
|
|
338
273
|
|
|
339
|
-
[
|
|
340
|
-
[
|
|
274
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m
|
|
275
|
+
[1m1-3 of many[22m Keep scrolling to see more items"
|
|
341
276
|
`);
|
|
342
277
|
});
|
|
343
278
|
test('supports a limit of items to show', async () => {
|
|
344
279
|
const items = [
|
|
345
|
-
{ label: 'first', value: 'first'
|
|
346
|
-
{ label: 'second', value: 'second'
|
|
280
|
+
{ label: 'first', value: 'first' },
|
|
281
|
+
{ label: 'second', value: 'second' },
|
|
347
282
|
{ label: 'third', value: 'third' },
|
|
348
283
|
{ label: 'fourth', value: 'fourth' },
|
|
349
|
-
{ label: 'fifth', value: 'fifth', group: 'Automations'
|
|
284
|
+
{ label: 'fifth', value: 'fifth', group: 'Automations' },
|
|
350
285
|
{ label: 'sixth', value: 'sixth', group: 'Automations' },
|
|
351
286
|
{ label: 'seventh', value: 'seventh' },
|
|
352
287
|
{ label: 'eighth', value: 'eighth', group: 'Merchant Admin' },
|
|
353
288
|
{ label: 'ninth', value: 'ninth', group: 'Merchant Admin' },
|
|
354
289
|
{ label: 'tenth', value: 'tenth' },
|
|
355
290
|
];
|
|
356
|
-
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { },
|
|
291
|
+
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, availableLines: 10 }));
|
|
357
292
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
358
|
-
" [1mAutomations[22m
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
[1mMerchant Admin[22m
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
[1mOther[22m
|
|
367
|
-
|
|
293
|
+
" [1mAutomations[22m [46m [49m
|
|
294
|
+
[36m>[39m [36mfifth[39m [46m [49m
|
|
295
|
+
sixth [46m [49m
|
|
296
|
+
[46m [49m
|
|
297
|
+
[1mMerchant Admin[22m [46m [49m
|
|
298
|
+
eighth [100m [49m
|
|
299
|
+
ninth [100m [49m
|
|
300
|
+
[100m [49m
|
|
301
|
+
[1mOther[22m [100m [49m
|
|
302
|
+
first [100m [49m
|
|
368
303
|
|
|
369
|
-
[
|
|
370
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
304
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
371
305
|
`);
|
|
372
306
|
await waitForInputsToBeReady();
|
|
373
307
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
@@ -376,19 +310,18 @@ describe('SelectInput', async () => {
|
|
|
376
310
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
377
311
|
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
378
312
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
379
|
-
" [1mAutomations[22m
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
[1mMerchant Admin[22m
|
|
383
|
-
|
|
384
|
-
|
|
313
|
+
" [1mAutomations[22m [100m [49m
|
|
314
|
+
sixth [46m [49m
|
|
315
|
+
[46m [49m
|
|
316
|
+
[1mMerchant Admin[22m [46m [49m
|
|
317
|
+
eighth [46m [49m
|
|
318
|
+
ninth [46m [49m
|
|
319
|
+
[100m [49m
|
|
320
|
+
[1mOther[22m [100m [49m
|
|
321
|
+
first [100m [49m
|
|
322
|
+
[36m>[39m [36msecond[39m [100m [49m
|
|
385
323
|
|
|
386
|
-
[
|
|
387
|
-
(f) first
|
|
388
|
-
[36m>[39m [36m(s) second[39m
|
|
389
|
-
|
|
390
|
-
[2mShowing 5 of 10 items.[22m
|
|
391
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
324
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
392
325
|
`);
|
|
393
326
|
});
|
|
394
327
|
test('pressing enter calls onSubmit on the default option', async () => {
|
|
@@ -434,7 +367,7 @@ describe('SelectInput', async () => {
|
|
|
434
367
|
await sendInputAndWait(renderInstance, 100, ENTER);
|
|
435
368
|
expect(onSubmit).toHaveBeenCalledWith(items[1]);
|
|
436
369
|
});
|
|
437
|
-
test('using a shortcut calls onSubmit
|
|
370
|
+
test('using a shortcut calls onSubmit', async () => {
|
|
438
371
|
const onSubmit = vi.fn();
|
|
439
372
|
const items = [
|
|
440
373
|
{
|
|
@@ -453,75 +386,78 @@ describe('SelectInput', async () => {
|
|
|
453
386
|
key: 't',
|
|
454
387
|
},
|
|
455
388
|
];
|
|
456
|
-
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit
|
|
389
|
+
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
|
|
457
390
|
await waitForInputsToBeReady();
|
|
458
|
-
await sendInputAndWait(renderInstance,
|
|
391
|
+
await sendInputAndWait(renderInstance, 100, 's');
|
|
459
392
|
expect(onSubmit).toHaveBeenCalledWith(items[1]);
|
|
460
393
|
});
|
|
461
|
-
test('
|
|
394
|
+
test('supports disabled options', async () => {
|
|
462
395
|
const onSubmit = vi.fn();
|
|
463
396
|
const items = [
|
|
464
397
|
{
|
|
465
398
|
label: 'First',
|
|
466
399
|
value: 'first',
|
|
467
|
-
key: 'f',
|
|
468
400
|
},
|
|
469
401
|
{
|
|
470
402
|
label: 'Second',
|
|
471
403
|
value: 'second',
|
|
472
|
-
|
|
404
|
+
disabled: true,
|
|
473
405
|
},
|
|
474
406
|
{
|
|
475
407
|
label: 'Third',
|
|
476
408
|
value: 'third',
|
|
477
|
-
key: 't',
|
|
478
409
|
},
|
|
479
410
|
];
|
|
480
411
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
|
|
481
412
|
await waitForInputsToBeReady();
|
|
482
|
-
await
|
|
483
|
-
expect(
|
|
413
|
+
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
414
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
415
|
+
" First
|
|
416
|
+
[2mSecond[22m
|
|
417
|
+
[36m>[39m [36mThird[39m
|
|
418
|
+
|
|
419
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
420
|
+
`);
|
|
421
|
+
await sendInputAndWait(renderInstance, 100, ENTER);
|
|
422
|
+
expect(onSubmit).toHaveBeenCalledWith(items[2]);
|
|
484
423
|
});
|
|
485
|
-
test('
|
|
424
|
+
test('default value will be skipped if the option is disabled', async () => {
|
|
486
425
|
const onSubmit = vi.fn();
|
|
487
426
|
const items = [
|
|
488
427
|
{
|
|
489
428
|
label: 'First',
|
|
490
429
|
value: 'first',
|
|
491
|
-
key: 'f',
|
|
492
430
|
},
|
|
493
431
|
{
|
|
494
432
|
label: 'Second',
|
|
495
433
|
value: 'second',
|
|
496
|
-
key: 's',
|
|
497
434
|
disabled: true,
|
|
498
435
|
},
|
|
499
436
|
{
|
|
500
437
|
label: 'Third',
|
|
501
438
|
value: 'third',
|
|
502
|
-
key: 't',
|
|
503
439
|
},
|
|
504
440
|
];
|
|
505
|
-
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
|
|
506
|
-
await waitForInputsToBeReady();
|
|
507
|
-
await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
|
|
441
|
+
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit, defaultValue: "second" }));
|
|
508
442
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
509
|
-
"
|
|
510
|
-
[
|
|
511
|
-
|
|
443
|
+
"[36m>[39m [36mFirst[39m
|
|
444
|
+
[2mSecond[22m
|
|
445
|
+
Third
|
|
512
446
|
|
|
513
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
447
|
+
[2mPress ↑↓ arrows to select, enter to confirm.[22m"
|
|
514
448
|
`);
|
|
449
|
+
await waitForInputsToBeReady();
|
|
515
450
|
await sendInputAndWait(renderInstance, 100, ENTER);
|
|
516
|
-
expect(onSubmit).toHaveBeenCalledWith(items[
|
|
451
|
+
expect(onSubmit).toHaveBeenCalledWith(items[0]);
|
|
517
452
|
});
|
|
518
|
-
test('
|
|
453
|
+
test('selects the next non-disabled option if the first option is disabled', async () => {
|
|
519
454
|
const onSubmit = vi.fn();
|
|
520
455
|
const items = [
|
|
521
456
|
{
|
|
522
457
|
label: 'First',
|
|
523
458
|
value: 'first',
|
|
524
459
|
key: 'f',
|
|
460
|
+
disabled: true,
|
|
525
461
|
},
|
|
526
462
|
{
|
|
527
463
|
label: 'Second',
|
|
@@ -535,26 +471,25 @@ describe('SelectInput', async () => {
|
|
|
535
471
|
key: 't',
|
|
536
472
|
},
|
|
537
473
|
];
|
|
538
|
-
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit
|
|
474
|
+
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
|
|
475
|
+
await waitForInputsToBeReady();
|
|
539
476
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
540
|
-
"[
|
|
477
|
+
" [2m(f) First[22m
|
|
541
478
|
[2m(s) Second[22m
|
|
542
|
-
|
|
479
|
+
[36m>[39m [36m(t) Third[39m
|
|
543
480
|
|
|
544
|
-
[2mPress ↑↓ arrows to select, enter to confirm
|
|
481
|
+
[2mPress ↑↓ arrows to select, enter or a shortcut to confirm.[22m"
|
|
545
482
|
`);
|
|
546
|
-
await waitForInputsToBeReady();
|
|
547
483
|
await sendInputAndWait(renderInstance, 100, ENTER);
|
|
548
|
-
expect(onSubmit).toHaveBeenCalledWith(items[
|
|
484
|
+
expect(onSubmit).toHaveBeenCalledWith(items[2]);
|
|
549
485
|
});
|
|
550
|
-
test('
|
|
486
|
+
test("doesn't allow submitting disabled options with shortcuts", async () => {
|
|
551
487
|
const onSubmit = vi.fn();
|
|
552
488
|
const items = [
|
|
553
489
|
{
|
|
554
490
|
label: 'First',
|
|
555
491
|
value: 'first',
|
|
556
492
|
key: 'f',
|
|
557
|
-
disabled: true,
|
|
558
493
|
},
|
|
559
494
|
{
|
|
560
495
|
label: 'Second',
|
|
@@ -570,15 +505,8 @@ describe('SelectInput', async () => {
|
|
|
570
505
|
];
|
|
571
506
|
const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
|
|
572
507
|
await waitForInputsToBeReady();
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
[2m(s) Second[22m
|
|
576
|
-
[36m>[39m [36m(t) Third[39m
|
|
577
|
-
|
|
578
|
-
[2mPress ↑↓ arrows to select, enter to confirm[22m"
|
|
579
|
-
`);
|
|
580
|
-
await sendInputAndWait(renderInstance, 100, ENTER);
|
|
581
|
-
expect(onSubmit).toHaveBeenCalledWith(items[2]);
|
|
508
|
+
await sendInputAndWait(renderInstance, 100, 's');
|
|
509
|
+
expect(onSubmit).not.toHaveBeenCalled();
|
|
582
510
|
});
|
|
583
511
|
});
|
|
584
512
|
//# sourceMappingURL=SelectInput.test.js.map
|