@shopify/cli-kit 3.47.4 → 3.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/assets/cli-ruby/lib/project_types/extension/messages/messages.rb +18 -1
  2. package/assets/cli-ruby/lib/shopify_cli/constants.rb +1 -0
  3. package/assets/cli-ruby/lib/shopify_cli/environment.rb +7 -0
  4. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +8 -2
  5. package/dist/private/node/ui/alert.js +3 -1
  6. package/dist/private/node/ui/alert.js.map +1 -1
  7. package/dist/private/node/ui/components/Alert.d.ts +1 -1
  8. package/dist/private/node/ui/components/Alert.js.map +1 -1
  9. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +7 -2
  10. package/dist/private/node/ui/components/AutocompletePrompt.js +28 -91
  11. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
  12. package/dist/private/node/ui/components/AutocompletePrompt.test.js +317 -257
  13. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  14. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -0
  15. package/dist/private/node/ui/components/ConcurrentOutput.js +59 -32
  16. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  17. package/dist/private/node/ui/components/ConcurrentOutput.test.js +62 -22
  18. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  19. package/dist/private/node/ui/components/DangerousConfirmationPrompt.d.ts +12 -0
  20. package/dist/private/node/ui/components/DangerousConfirmationPrompt.js +77 -0
  21. package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -0
  22. package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js +101 -0
  23. package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js.map +1 -0
  24. package/dist/private/node/ui/components/List.d.ts +1 -0
  25. package/dist/private/node/ui/components/List.js +2 -2
  26. package/dist/private/node/ui/components/List.js.map +1 -1
  27. package/dist/private/node/ui/components/{GitDiff.d.ts → Prompts/GitDiff.d.ts} +4 -2
  28. package/dist/private/node/ui/components/{GitDiff.js → Prompts/GitDiff.js} +3 -2
  29. package/dist/private/node/ui/components/Prompts/GitDiff.js.map +1 -0
  30. package/dist/private/node/ui/components/Prompts/GitDiff.test.d.ts +1 -0
  31. package/dist/private/node/ui/components/{GitDiff.test.js → Prompts/GitDiff.test.js} +50 -28
  32. package/dist/private/node/ui/components/Prompts/GitDiff.test.js.map +1 -0
  33. package/dist/private/node/ui/components/Prompts/InfoMessage.d.ts +14 -0
  34. package/dist/private/node/ui/components/Prompts/InfoMessage.js +11 -0
  35. package/dist/private/node/ui/components/Prompts/InfoMessage.js.map +1 -0
  36. package/dist/private/node/ui/components/Prompts/InfoMessage.test.d.ts +1 -0
  37. package/dist/private/node/ui/components/Prompts/InfoMessage.test.js +21 -0
  38. package/dist/private/node/ui/components/Prompts/InfoMessage.test.js.map +1 -0
  39. package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +1 -0
  40. package/dist/private/node/ui/components/Prompts/InfoTable.js +11 -7
  41. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
  42. package/dist/private/node/ui/components/Prompts/InfoTable.test.js +6 -4
  43. package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
  44. package/dist/private/node/ui/components/Prompts/PromptLayout.d.ts +21 -0
  45. package/dist/private/node/ui/components/Prompts/PromptLayout.js +73 -0
  46. package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -0
  47. package/dist/private/node/ui/components/Prompts/PromptLayout.test.d.ts +1 -0
  48. package/dist/private/node/ui/components/Prompts/PromptLayout.test.js +129 -0
  49. package/dist/private/node/ui/components/Prompts/PromptLayout.test.js.map +1 -0
  50. package/dist/private/node/ui/components/Scrollbar.d.ts +10 -0
  51. package/dist/private/node/ui/components/Scrollbar.js +44 -0
  52. package/dist/private/node/ui/components/Scrollbar.js.map +1 -0
  53. package/dist/private/node/ui/components/Scrollbar.test.d.ts +1 -0
  54. package/dist/private/node/ui/components/Scrollbar.test.js +96 -0
  55. package/dist/private/node/ui/components/Scrollbar.test.js.map +1 -0
  56. package/dist/private/node/ui/components/SelectInput.d.ts +3 -6
  57. package/dist/private/node/ui/components/SelectInput.js +57 -41
  58. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  59. package/dist/private/node/ui/components/SelectInput.test.js +120 -192
  60. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  61. package/dist/private/node/ui/components/SelectPrompt.d.ts +7 -6
  62. package/dist/private/node/ui/components/SelectPrompt.js +11 -68
  63. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  64. package/dist/private/node/ui/components/SelectPrompt.test.js +135 -65
  65. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  66. package/dist/private/node/ui/components/Table/Row.js +2 -1
  67. package/dist/private/node/ui/components/Table/Row.js.map +1 -1
  68. package/dist/private/node/ui/components/Table/Table.js +2 -1
  69. package/dist/private/node/ui/components/Table/Table.js.map +1 -1
  70. package/dist/private/node/ui/components/Tasks.js +1 -8
  71. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  72. package/dist/private/node/ui/components/TextInput.d.ts +1 -0
  73. package/dist/private/node/ui/components/TextInput.js +10 -4
  74. package/dist/private/node/ui/components/TextInput.js.map +1 -1
  75. package/dist/private/node/ui/components/TextInput.test.js +27 -18
  76. package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
  77. package/dist/private/node/ui/components/TextPrompt.d.ts +2 -3
  78. package/dist/private/node/ui/components/TextPrompt.js +18 -16
  79. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  80. package/dist/private/node/ui/components/TextPrompt.test.js +25 -11
  81. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  82. package/dist/private/node/ui/hooks/use-prompt.d.ts +18 -0
  83. package/dist/private/node/ui/hooks/use-prompt.js +20 -0
  84. package/dist/private/node/ui/hooks/use-prompt.js.map +1 -0
  85. package/dist/private/node/ui/hooks/use-select-state.d.ts +4 -4
  86. package/dist/private/node/ui/hooks/use-select-state.js +9 -9
  87. package/dist/private/node/ui/hooks/use-select-state.js.map +1 -1
  88. package/dist/public/common/object.d.ts +16 -0
  89. package/dist/public/common/object.js +26 -0
  90. package/dist/public/common/object.js.map +1 -1
  91. package/dist/public/common/string.d.ts +16 -0
  92. package/dist/public/common/string.js +30 -0
  93. package/dist/public/common/string.js.map +1 -1
  94. package/dist/public/common/version.d.ts +1 -1
  95. package/dist/public/common/version.js +1 -1
  96. package/dist/public/common/version.js.map +1 -1
  97. package/dist/public/node/analytics.js +3 -1
  98. package/dist/public/node/analytics.js.map +1 -1
  99. package/dist/public/node/base-command.d.ts +1 -0
  100. package/dist/public/node/base-command.js +21 -1
  101. package/dist/public/node/base-command.js.map +1 -1
  102. package/dist/public/node/figures.d.ts +2 -0
  103. package/dist/public/node/figures.js +3 -0
  104. package/dist/public/node/figures.js.map +1 -0
  105. package/dist/public/node/metadata.d.ts +2 -1
  106. package/dist/public/node/metadata.js +5 -2
  107. package/dist/public/node/metadata.js.map +1 -1
  108. package/dist/public/node/monorail.d.ts +22 -1
  109. package/dist/public/node/monorail.js +1 -1
  110. package/dist/public/node/monorail.js.map +1 -1
  111. package/dist/public/node/output.d.ts +1 -1
  112. package/dist/public/node/output.js +1 -1
  113. package/dist/public/node/output.js.map +1 -1
  114. package/dist/public/node/ruby.d.ts +1 -0
  115. package/dist/public/node/ruby.js +1 -0
  116. package/dist/public/node/ruby.js.map +1 -1
  117. package/dist/public/node/system.js +2 -2
  118. package/dist/public/node/system.js.map +1 -1
  119. package/dist/public/node/themes/models/theme.d.ts +2 -1
  120. package/dist/public/node/themes/models/theme.js +2 -1
  121. package/dist/public/node/themes/models/theme.js.map +1 -1
  122. package/dist/public/node/themes/theme-urls.d.ts +1 -0
  123. package/dist/public/node/themes/theme-urls.js +4 -0
  124. package/dist/public/node/themes/theme-urls.js.map +1 -1
  125. package/dist/public/node/themes/themes-api.d.ts +9 -1
  126. package/dist/public/node/themes/themes-api.js +14 -3
  127. package/dist/public/node/themes/themes-api.js.map +1 -1
  128. package/dist/public/node/toml.d.ts +3 -2
  129. package/dist/public/node/toml.js +5 -2
  130. package/dist/public/node/toml.js.map +1 -1
  131. package/dist/public/node/ui.d.ts +82 -27
  132. package/dist/public/node/ui.js +97 -32
  133. package/dist/public/node/ui.js.map +1 -1
  134. package/dist/tsconfig.tsbuildinfo +1 -1
  135. package/package.json +14 -14
  136. package/dist/private/node/ui/components/GitDiff.js.map +0 -1
  137. package/dist/private/node/ui/components/GitDiff.test.js.map +0 -1
  138. /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
- " (1) First
33
- > (2) Second
34
- (3) Third
32
+ " First
33
+ > Second
34
+ Third
35
35
 
36
- Press ↑↓ arrows to select, enter to confirm"
36
+ Press ↑↓ arrows to select, enter to confirm."
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
- " (1) First
61
- > (2) Second
62
- (3) Third
60
+ " First
61
+ > Second
62
+ Third
63
63
 
64
- Press ↑↓ arrows to select, enter to confirm"
64
+ Press ↑↓ arrows to select, enter to confirm."
65
65
  `);
66
66
  expect(onChange).toHaveBeenCalledWith(items[1]);
67
67
  });
68
- test('handles single digit numeric shortcuts', async () => {
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
- await waitForInputsToBeReady();
86
- await sendInputAndWaitForChange(renderInstance, '2');
87
- expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
88
- " (1) First
89
- > (2) Second
90
- (3) Third
91
-
92
- Press ↑↓ arrows to select, enter to confirm"
93
- `);
94
- expect(onChange).toHaveBeenCalledWith(items[1]);
88
+ expect(getLastFrameAfterUnmount(renderInstance)).toMatch('SelectInput: Keys must be a single character');
95
89
  });
96
- test('handles keys with multiple digits', async () => {
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: 'Tenth',
109
- value: 'tenth',
110
- key: '10',
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
- await waitForInputsToBeReady();
115
- await sendInputAndWaitForChange(renderInstance, '1', '0');
116
- expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
117
- " (1) First
118
- (2) Second
119
- > (10) Tenth
120
-
121
- Press ↑↓ arrows to select, enter to confirm"
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, 500, '4');
129
+ await sendInputAndWait(renderInstance, 100, '4');
145
130
  expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
146
- "> (1) First
147
- (2) Second
148
- (3) Tenth
131
+ "> First
132
+ Second
133
+ Tenth
149
134
 
150
- Press ↑↓ arrows to select, enter to confirm"
135
+ Press ↑↓ arrows to select, enter to confirm."
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
- > (t) Third
178
-
179
- Press ↑↓ arrows to select, enter to confirm"
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', key: 'f' },
188
- { label: 'second', value: 'second', group: 'Automations', key: 's' },
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', key: 'a' },
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
  " Automations
201
- > (f) first
202
- (s) second
157
+ > first
158
+ second
203
159
 
204
160
  Merchant Admin
205
- (3) third
206
- (4) fourth
161
+ third
162
+ fourth
207
163
 
208
164
  Other
209
- (a) fifth
210
- (6) sixth
211
- (7) seventh
212
- (8) eighth
213
- (9) ninth
214
- (10) tenth
165
+ fifth
166
+ sixth
167
+ seventh
168
+ eighth
169
+ ninth
170
+ tenth
215
171
 
216
- Press ↑↓ arrows to select, enter to confirm"
172
+ Press ↑↓ arrows to select, enter to confirm."
217
173
  `);
218
174
  await waitForInputsToBeReady();
219
- await sendInputAndWaitForChange(renderInstance, 'a');
220
- expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
221
- " Automations
222
- (f) first
223
- (s) second
224
-
225
- Merchant Admin
226
- (3) third
227
- (4) fourth
228
-
229
- Other
230
- > (a) fifth
231
- (6) sixth
232
- (7) seventh
233
- (8) eighth
234
- (9) ninth
235
- (10) tenth
236
-
237
- Press ↑↓ arrows to select, enter to confirm"
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
  " Automations
244
- (f) first
245
- (s) second
179
+ first
180
+ second
246
181
 
247
182
  Merchant Admin
248
- (3) third
249
- (4) fourth
183
+ > third
184
+ fourth
250
185
 
251
186
  Other
252
- (a) fifth
253
- (6) sixth
254
- > (7) seventh
255
- (8) eighth
256
- (9) ninth
257
- (10) tenth
187
+ fifth
188
+ sixth
189
+ seventh
190
+ eighth
191
+ ninth
192
+ tenth
258
193
 
259
- Press ↑↓ arrows to select, enter to confirm"
194
+ Press ↑↓ arrows to select, enter to confirm."
260
195
  `);
261
- expect(onChange).toHaveBeenLastCalledWith(items[6]);
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
- Press ↑↓ arrows to select, enter to confirm"
223
+ Press ↑↓ arrows to select, enter to confirm."
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
- " (1) First
311
- > (2) Second
312
- (3) Third
245
+ " First
246
+ > Second
247
+ Third
313
248
 
314
- Press ↑↓ arrows to select, enter to confirm"
249
+ Press ↑↓ arrows to select, enter to confirm."
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
- "> (1) First
336
- (2) Second
337
- (3) Third
270
+ "> First
271
+ Second
272
+ Third
338
273
 
339
- 1-3 of many Keep scrolling to see more items
340
- Press ↑↓ arrows to select, enter to confirm"
274
+ Press ↑↓ arrows to select, enter to confirm.
275
+ 1-3 of many 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', key: 'f' },
346
- { label: 'second', value: 'second', key: 's' },
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', key: 'a' },
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: () => { }, limit: 5 }));
291
+ const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, availableLines: 10 }));
357
292
  expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
358
- " Automations
359
- > (a) fifth
360
- (2) sixth
361
-
362
- Merchant Admin
363
- (3) eighth
364
- (4) ninth
365
-
366
- Other
367
- (f) first
293
+ " Automations  
294
+ > fifth  
295
+ sixth  
296
+  
297
+ Merchant Admin  
298
+ eighth  
299
+ ninth  
300
+  
301
+ Other  
302
+ first  
368
303
 
369
- Showing 5 of 10 items.
370
- Press ↑↓ arrows to select, enter to confirm"
304
+ Press ↑↓ arrows to select, enter to confirm."
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
- " Automations
380
- (2) sixth
381
-
382
- Merchant Admin
383
- (3) eighth
384
- (4) ninth
313
+ " Automations  
314
+ sixth  
315
+  
316
+ Merchant Admin  
317
+ eighth  
318
+ ninth  
319
+  
320
+ Other  
321
+ first  
322
+ > second  
385
323
 
386
- Other
387
- (f) first
388
- > (s) second
389
-
390
- Showing 5 of 10 items.
391
- Press ↑↓ arrows to select, enter to confirm"
324
+ Press ↑↓ arrows to select, enter to confirm."
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 if submitWithShortcuts is true', async () => {
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, submitWithShortcuts: true }));
389
+ const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
457
390
  await waitForInputsToBeReady();
458
- await sendInputAndWait(renderInstance, 500, 's');
391
+ await sendInputAndWait(renderInstance, 100, 's');
459
392
  expect(onSubmit).toHaveBeenCalledWith(items[1]);
460
393
  });
461
- test('using a shortcut does not call onSubmit if submitWithShortcuts is false', async () => {
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
- key: 's',
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 sendInputAndWait(renderInstance, 500, 's');
483
- expect(onSubmit).not.toHaveBeenCalled();
413
+ await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
414
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
415
+ " First
416
+ Second
417
+ > Third
418
+
419
+ Press ↑↓ arrows to select, enter to confirm."
420
+ `);
421
+ await sendInputAndWait(renderInstance, 100, ENTER);
422
+ expect(onSubmit).toHaveBeenCalledWith(items[2]);
484
423
  });
485
- test('supports disabled options', async () => {
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
- " (f) First
510
- (s) Second
511
- > (t) Third
443
+ "> First
444
+ Second
445
+ Third
512
446
 
513
- Press ↑↓ arrows to select, enter to confirm"
447
+ Press ↑↓ arrows to select, enter to confirm."
514
448
  `);
449
+ await waitForInputsToBeReady();
515
450
  await sendInputAndWait(renderInstance, 100, ENTER);
516
- expect(onSubmit).toHaveBeenCalledWith(items[2]);
451
+ expect(onSubmit).toHaveBeenCalledWith(items[0]);
517
452
  });
518
- test('default value will be skipped if the option is disabled', async () => {
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, defaultValue: "second" }));
474
+ const renderInstance = render(React.createElement(SelectInput, { items: items, onChange: () => { }, onSubmit: onSubmit }));
475
+ await waitForInputsToBeReady();
539
476
  expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
540
- "> (f) First
477
+ " (f) First
541
478
  (s) Second
542
- (t) Third
479
+ > (t) Third
543
480
 
544
- Press ↑↓ arrows to select, enter to confirm"
481
+ Press ↑↓ arrows to select, enter or a shortcut to confirm."
545
482
  `);
546
- await waitForInputsToBeReady();
547
483
  await sendInputAndWait(renderInstance, 100, ENTER);
548
- expect(onSubmit).toHaveBeenCalledWith(items[0]);
484
+ expect(onSubmit).toHaveBeenCalledWith(items[2]);
549
485
  });
550
- test('selects the next non-disabled option if the first option is disabled', async () => {
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
- expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
574
- " (f) First
575
- (s) Second
576
- > (t) Third
577
-
578
- Press ↑↓ arrows to select, enter to confirm"
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