@shopify/cli-kit 3.35.0 → 3.36.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 (184) hide show
  1. package/dist/content-tokens.js +1 -1
  2. package/dist/content-tokens.js.map +1 -1
  3. package/dist/error.js +2 -2
  4. package/dist/error.js.map +1 -1
  5. package/dist/index.d.ts +0 -3
  6. package/dist/index.js +0 -3
  7. package/dist/index.js.map +1 -1
  8. package/dist/metadata.d.ts +1 -1
  9. package/dist/metadata.js.map +1 -1
  10. package/dist/monorail.d.ts +1 -1
  11. package/dist/monorail.js +1 -1
  12. package/dist/monorail.js.map +1 -1
  13. package/dist/output.js +0 -4
  14. package/dist/output.js.map +1 -1
  15. package/dist/plugins.d.ts +1 -1
  16. package/dist/plugins.js.map +1 -1
  17. package/dist/{typing → private/common/ts}/deep-required.d.ts +3 -3
  18. package/dist/{typing → private/common/ts}/deep-required.js +0 -0
  19. package/dist/private/common/ts/deep-required.js.map +1 -0
  20. package/dist/{typing → private/common/ts}/overloaded-parameters.d.ts +0 -0
  21. package/dist/{typing → private/common/ts}/overloaded-parameters.js +0 -0
  22. package/dist/private/common/ts/overloaded-parameters.js.map +1 -0
  23. package/dist/private/node/api/graphql.js +1 -2
  24. package/dist/private/node/api/graphql.js.map +1 -1
  25. package/dist/private/node/api/headers.d.ts +9 -0
  26. package/dist/private/node/api/headers.js +26 -0
  27. package/dist/private/node/api/headers.js.map +1 -1
  28. package/dist/private/node/constants.js +3 -3
  29. package/dist/private/node/constants.js.map +1 -1
  30. package/dist/private/node/session/device-authorization.js +1 -1
  31. package/dist/private/node/session/device-authorization.js.map +1 -1
  32. package/dist/private/node/session/exchange.js +1 -1
  33. package/dist/private/node/session/exchange.js.map +1 -1
  34. package/dist/private/node/session/identity-token-validation.js +1 -1
  35. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  36. package/dist/private/node/session/post-auth.js +3 -3
  37. package/dist/private/node/session/post-auth.js.map +1 -1
  38. package/dist/{typing → private/node}/simple-definitions.d.ts +0 -0
  39. package/dist/{typing → private/node}/simple-definitions.js +0 -0
  40. package/dist/private/node/simple-definitions.js.map +1 -0
  41. package/dist/private/node/ui/alert.d.ts +1 -1
  42. package/dist/private/node/ui/alert.js +2 -2
  43. package/dist/private/node/ui/alert.js.map +1 -1
  44. package/dist/private/node/ui/components/Alert.d.ts +5 -0
  45. package/dist/private/node/ui/components/Alert.js +9 -6
  46. package/dist/private/node/ui/components/Alert.js.map +1 -1
  47. package/dist/private/node/ui/components/Alert.test.js +30 -4
  48. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  49. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +12 -0
  50. package/dist/private/node/ui/components/AutocompletePrompt.js +111 -0
  51. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -0
  52. package/dist/private/node/ui/components/AutocompletePrompt.test.d.ts +1 -0
  53. package/dist/private/node/ui/components/AutocompletePrompt.test.js +473 -0
  54. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -0
  55. package/dist/private/node/ui/components/Banner.d.ts +0 -1
  56. package/dist/private/node/ui/components/Banner.js +4 -4
  57. package/dist/private/node/ui/components/Banner.js.map +1 -1
  58. package/dist/private/node/ui/components/Banner.test.js +10 -5
  59. package/dist/private/node/ui/components/Banner.test.js.map +1 -1
  60. package/dist/private/node/ui/components/FatalError.js +1 -1
  61. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  62. package/dist/private/node/ui/components/FatalError.test.js +4 -8
  63. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  64. package/dist/private/node/ui/components/{Table.d.ts → Prompts/InfoTable.d.ts} +2 -2
  65. package/dist/private/node/ui/components/{Table.js → Prompts/InfoTable.js} +6 -6
  66. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -0
  67. package/dist/private/node/ui/components/SelectInput.d.ts +9 -2
  68. package/dist/private/node/ui/components/SelectInput.js +96 -52
  69. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  70. package/dist/private/node/ui/components/SelectInput.test.js +140 -54
  71. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  72. package/dist/private/node/ui/components/SelectPrompt.d.ts +4 -3
  73. package/dist/private/node/ui/components/SelectPrompt.js +17 -11
  74. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  75. package/dist/private/node/ui/components/SelectPrompt.test.js +113 -23
  76. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  77. package/dist/private/node/ui/components/Tasks.d.ts +6 -5
  78. package/dist/private/node/ui/components/Tasks.js +32 -11
  79. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  80. package/dist/private/node/ui/components/Tasks.test.js +55 -9
  81. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  82. package/dist/private/node/ui/components/TextInput.d.ts +4 -1
  83. package/dist/private/node/ui/components/TextInput.js +22 -13
  84. package/dist/private/node/ui/components/TextInput.js.map +1 -1
  85. package/dist/private/node/ui/components/TextInput.test.js +47 -40
  86. package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
  87. package/dist/private/node/ui/components/TextPrompt.d.ts +3 -1
  88. package/dist/private/node/ui/components/TextPrompt.js +28 -15
  89. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  90. package/dist/private/node/ui/components/TextPrompt.test.js +71 -15
  91. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  92. package/dist/private/node/ui/components/TokenizedText.d.ts +3 -0
  93. package/dist/private/node/ui/components/TokenizedText.js +33 -1
  94. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  95. package/dist/private/node/ui/utilities.d.ts +2 -0
  96. package/dist/private/node/ui/utilities.js +6 -0
  97. package/dist/private/node/ui/utilities.js.map +1 -0
  98. package/dist/{typing → public/common/ts}/pick-by-prefix.d.ts +4 -3
  99. package/dist/{typing → public/common/ts}/pick-by-prefix.js +0 -0
  100. package/dist/public/common/ts/pick-by-prefix.js.map +1 -0
  101. package/dist/public/common/version.d.ts +1 -1
  102. package/dist/public/common/version.js +1 -1
  103. package/dist/public/common/version.js.map +1 -1
  104. package/dist/public/node/api/admin.js +1 -1
  105. package/dist/public/node/api/admin.js.map +1 -1
  106. package/dist/public/node/api/http.d.ts +0 -0
  107. package/dist/public/node/api/http.js +2 -0
  108. package/dist/public/node/api/http.js.map +1 -0
  109. package/dist/public/node/api/oxygen.js +1 -1
  110. package/dist/public/node/api/oxygen.js.map +1 -1
  111. package/dist/public/node/archiver.js +2 -1
  112. package/dist/public/node/archiver.js.map +1 -1
  113. package/dist/public/node/cli.js +2 -2
  114. package/dist/public/node/cli.js.map +1 -1
  115. package/dist/public/node/environment/spin.js +2 -2
  116. package/dist/public/node/environment/spin.js.map +1 -1
  117. package/dist/public/node/error-handler.js +7 -5
  118. package/dist/public/node/error-handler.js.map +1 -1
  119. package/dist/public/node/framework.js +2 -2
  120. package/dist/public/node/framework.js.map +1 -1
  121. package/dist/public/node/fs.d.ts +22 -4
  122. package/dist/public/node/fs.js +34 -6
  123. package/dist/public/node/fs.js.map +1 -1
  124. package/dist/public/node/github.js +1 -1
  125. package/dist/public/node/github.js.map +1 -1
  126. package/dist/{http/fetch.d.ts → public/node/http.d.ts} +18 -7
  127. package/dist/{http/fetch.js → public/node/http.js} +22 -9
  128. package/dist/public/node/http.js.map +1 -0
  129. package/dist/public/node/liquid.js +4 -4
  130. package/dist/public/node/liquid.js.map +1 -1
  131. package/dist/public/node/node-package-manager.d.ts +22 -1
  132. package/dist/public/node/node-package-manager.js +22 -11
  133. package/dist/public/node/node-package-manager.js.map +1 -1
  134. package/dist/public/node/path.d.ts +22 -0
  135. package/dist/{path.js → public/node/path.js} +8 -20
  136. package/dist/public/node/path.js.map +1 -0
  137. package/dist/public/node/presets.js +4 -4
  138. package/dist/public/node/presets.js.map +1 -1
  139. package/dist/public/node/ruby.js +23 -27
  140. package/dist/public/node/ruby.js.map +1 -1
  141. package/dist/public/node/ui.d.ts +50 -9
  142. package/dist/public/node/ui.js +69 -8
  143. package/dist/public/node/ui.js.map +1 -1
  144. package/dist/public/node/vscode.js +4 -4
  145. package/dist/public/node/vscode.js.map +1 -1
  146. package/dist/testing/ui.d.ts +4 -1
  147. package/dist/testing/ui.js +24 -1
  148. package/dist/testing/ui.js.map +1 -1
  149. package/dist/tsconfig.tsbuildinfo +1 -1
  150. package/dist/ui/executor.d.ts +2 -14
  151. package/dist/ui/executor.js +38 -72
  152. package/dist/ui/executor.js.map +1 -1
  153. package/dist/ui.js +6 -23
  154. package/dist/ui.js.map +1 -1
  155. package/package.json +3 -5
  156. package/dist/http/fetch.js.map +0 -1
  157. package/dist/http/formdata.d.ts +0 -3
  158. package/dist/http/formdata.js +0 -6
  159. package/dist/http/formdata.js.map +0 -1
  160. package/dist/http.d.ts +0 -26
  161. package/dist/http.js +0 -31
  162. package/dist/http.js.map +0 -1
  163. package/dist/npm.d.ts +0 -27
  164. package/dist/npm.js +0 -20
  165. package/dist/npm.js.map +0 -1
  166. package/dist/path.d.ts +0 -25
  167. package/dist/path.js.map +0 -1
  168. package/dist/private/node/ui/components/Table.js.map +0 -1
  169. package/dist/typing/deep-required.js.map +0 -1
  170. package/dist/typing/overloaded-parameters.js.map +0 -1
  171. package/dist/typing/pick-by-prefix.js.map +0 -1
  172. package/dist/typing/simple-definitions.js.map +0 -1
  173. package/dist/ui/inquirer/autocomplete.d.ts +0 -11
  174. package/dist/ui/inquirer/autocomplete.js +0 -110
  175. package/dist/ui/inquirer/autocomplete.js.map +0 -1
  176. package/dist/ui/inquirer/input.d.ts +0 -16
  177. package/dist/ui/inquirer/input.js +0 -45
  178. package/dist/ui/inquirer/input.js.map +0 -1
  179. package/dist/ui/inquirer/password.d.ts +0 -7
  180. package/dist/ui/inquirer/password.js +0 -8
  181. package/dist/ui/inquirer/password.js.map +0 -1
  182. package/dist/ui/inquirer/select.d.ts +0 -14
  183. package/dist/ui/inquirer/select.js +0 -26
  184. package/dist/ui/inquirer/select.js.map +0 -1
@@ -0,0 +1,473 @@
1
+ import { AutocompletePrompt } from './AutocompletePrompt.js';
2
+ import { getLastFrameAfterUnmount, sendInputAndWait, sendInputAndWaitForChange, sendInputAndWaitForContent, waitForContent, waitForInputsToBeReady, } from '../../../../testing/ui.js';
3
+ import { describe, expect, test, vi } from 'vitest';
4
+ import React from 'react';
5
+ import { render } from 'ink-testing-library';
6
+ const ARROW_DOWN = '\u001B[B';
7
+ const ENTER = '\r';
8
+ const DELETE = '\u007F';
9
+ const DATABASE = [
10
+ { label: 'first', value: 'first' },
11
+ { label: 'second', value: 'second' },
12
+ { label: 'third', value: 'third' },
13
+ { label: 'fourth', value: 'fourth' },
14
+ { label: 'fifth', value: 'fifth' },
15
+ { label: 'sixth', value: 'sixth' },
16
+ { label: 'seventh', value: 'seventh' },
17
+ { label: 'eighth', value: 'eighth' },
18
+ { label: 'ninth', value: 'ninth' },
19
+ { label: 'tenth', value: 'tenth' },
20
+ { label: 'eleventh', value: 'eleventh' },
21
+ { label: 'twelfth', value: 'twelfth' },
22
+ { label: 'thirteenth', value: 'thirteenth' },
23
+ { label: 'fourteenth', value: 'fourteenth' },
24
+ { label: 'fifteenth', value: 'fifteenth' },
25
+ { label: 'sixteenth', value: 'sixteenth' },
26
+ { label: 'seventeenth', value: 'seventeenth' },
27
+ { label: 'eighteenth', value: 'eighteenth' },
28
+ { label: 'nineteenth', value: 'nineteenth' },
29
+ { label: 'twentieth', value: 'twentieth' },
30
+ { label: 'twenty-first', value: 'twenty-first' },
31
+ { label: 'twenty-second', value: 'twenty-second' },
32
+ { label: 'twenty-third', value: 'twenty-third' },
33
+ { label: 'twenty-fourth', value: 'twenty-fourth' },
34
+ { label: 'twenty-fifth', value: 'twenty-fifth' },
35
+ { label: 'twenty-sixth', value: 'twenty-sixth' },
36
+ { label: 'twenty-seventh', value: 'twenty-seventh' },
37
+ { label: 'twenty-eighth', value: 'twenty-eighth' },
38
+ { label: 'twenty-ninth', value: 'twenty-ninth' },
39
+ { label: 'thirtieth', value: 'thirtieth' },
40
+ { label: 'thirty-first', value: 'thirty-first' },
41
+ { label: 'thirty-second', value: 'thirty-second' },
42
+ { label: 'thirty-third', value: 'thirty-third' },
43
+ { label: 'thirty-fourth', value: 'thirty-fourth' },
44
+ { label: 'thirty-fifth', value: 'thirty-fifth' },
45
+ { label: 'thirty-sixth', value: 'thirty-sixth' },
46
+ { label: 'thirty-seventh', value: 'thirty-seventh' },
47
+ { label: 'thirty-eighth', value: 'thirty-eighth' },
48
+ { label: 'thirty-ninth', value: 'thirty-ninth' },
49
+ { label: 'fortieth', value: 'fortieth' },
50
+ { label: 'forty-first', value: 'forty-first' },
51
+ { label: 'forty-second', value: 'forty-second' },
52
+ { label: 'forty-third', value: 'forty-third' },
53
+ { label: 'forty-fourth', value: 'forty-fourth' },
54
+ { label: 'forty-fifth', value: 'forty-fifth' },
55
+ { label: 'forty-sixth', value: 'forty-sixth' },
56
+ { label: 'forty-seventh', value: 'forty-seventh' },
57
+ { label: 'forty-eighth', value: 'forty-eighth' },
58
+ { label: 'forty-ninth', value: 'forty-ninth' },
59
+ { label: 'fiftieth', value: 'fiftieth' },
60
+ ];
61
+ describe('AutocompletePrompt', async () => {
62
+ test('choose an answer', async () => {
63
+ const onEnter = vi.fn();
64
+ const items = [
65
+ { label: 'first', value: 'first' },
66
+ { label: 'second', value: 'second' },
67
+ { label: 'third', value: 'third' },
68
+ ];
69
+ const infoTable = { Add: ['new-ext'], Remove: ['integrated-demand-ext', 'order-discount'] };
70
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: items, infoTable: infoTable, onSubmit: onEnter, search: () => Promise.resolve([]) }));
71
+ await waitForInputsToBeReady();
72
+ await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
73
+ await sendInputAndWaitForChange(renderInstance, ENTER);
74
+ expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`
75
+ "? Associate your project with the org Castile Ventures?
76
+ ✔ second
77
+ "
78
+ `);
79
+ expect(onEnter).toHaveBeenCalledWith(items[1].value);
80
+ });
81
+ test('renders groups', async () => {
82
+ const items = [
83
+ { label: 'first', value: 'first', group: 'Automations', key: 'f' },
84
+ { label: 'second', value: 'second', group: 'Automations', key: 's' },
85
+ { label: 'third', value: 'third', group: 'Merchant Admin' },
86
+ { label: 'fourth', value: 'fourth', group: 'Merchant Admin' },
87
+ { label: 'fifth', value: 'fifth', key: 'a' },
88
+ { label: 'sixth', value: 'sixth' },
89
+ { label: 'seventh', value: 'seventh' },
90
+ { label: 'eighth', value: 'eighth' },
91
+ { label: 'ninth', value: 'ninth' },
92
+ { label: 'tenth', value: 'tenth' },
93
+ ];
94
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: items, onSubmit: () => { }, search: () => Promise.resolve([]) }));
95
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
96
+ "? Associate your project with the org Castile Ventures?
97
+
98
+ Automations
99
+ > first
100
+ second
101
+
102
+ Merchant Admin
103
+ third
104
+ fourth
105
+
106
+ Other
107
+ fifth
108
+ sixth
109
+ seventh
110
+ eighth
111
+ ninth
112
+ tenth
113
+
114
+ Press ↑↓ arrows to select, enter to confirm
115
+ "
116
+ `);
117
+ });
118
+ test('supports an info table', async () => {
119
+ const items = [
120
+ { label: 'first', value: 'first' },
121
+ { label: 'second', value: 'second' },
122
+ { label: 'third', value: 'third' },
123
+ { label: 'fourth', value: 'fourth' },
124
+ ];
125
+ const infoTable = {
126
+ Add: ['new-ext'],
127
+ Remove: ['integrated-demand-ext', 'order-discount'],
128
+ };
129
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: items, infoTable: infoTable, onSubmit: () => { }, search: () => Promise.resolve([]) }));
130
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
131
+ "? Associate your project with the org Castile Ventures?
132
+
133
+ Add: • new-ext
134
+
135
+ Remove: • integrated-demand-ext
136
+ • order-discount
137
+
138
+ > first
139
+ second
140
+ third
141
+ fourth
142
+
143
+ Press ↑↓ arrows to select, enter to confirm
144
+ "
145
+ `);
146
+ });
147
+ test("doesn't submit if there are no choices", async () => {
148
+ const onEnter = vi.fn();
149
+ const searchPromise = Promise.resolve([]);
150
+ const search = () => {
151
+ return searchPromise;
152
+ };
153
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: DATABASE, onSubmit: onEnter, search: search }));
154
+ await waitForInputsToBeReady();
155
+ await sendInputAndWaitForContent(renderInstance, 'No results found', 'a');
156
+ // prompt doesn't change when enter is pressed
157
+ await sendInputAndWait(renderInstance, 100, ENTER);
158
+ expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`
159
+ "? Associate your project with the org Castile Ventures? a 
160
+
161
+ No results found.
162
+ "
163
+ `);
164
+ expect(onEnter).not.toHaveBeenCalled();
165
+ });
166
+ test('has a loading state', async () => {
167
+ const onEnter = vi.fn();
168
+ const searchPromise = new Promise((resolve) => {
169
+ setTimeout(() => resolve([{ label: 'a', value: 'b' }]), 2000);
170
+ });
171
+ const search = () => {
172
+ return searchPromise;
173
+ };
174
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: DATABASE, onSubmit: onEnter, search: search }));
175
+ await waitForInputsToBeReady();
176
+ await sendInputAndWaitForContent(renderInstance, 'Loading...', 'a');
177
+ // prompt doesn't change when enter is pressed
178
+ await sendInputAndWait(renderInstance, 100, ENTER);
179
+ expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`
180
+ "? Associate your project with the org Castile Ventures? a 
181
+
182
+ Loading...
183
+ "
184
+ `);
185
+ expect(onEnter).not.toHaveBeenCalled();
186
+ });
187
+ test('allows searching with pagination', async () => {
188
+ const onEnter = vi.fn();
189
+ const search = async (term) => {
190
+ return DATABASE.filter((item) => item.label.includes(term));
191
+ };
192
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: DATABASE, onSubmit: onEnter, search: search }));
193
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
194
+ "? Associate your project with the org Castile Ventures? Type to search...
195
+
196
+ > first
197
+ second
198
+ third
199
+ fourth
200
+ fifth
201
+ sixth
202
+ seventh
203
+ eighth
204
+ ninth
205
+ tenth
206
+ eleventh
207
+ twelfth
208
+ thirteenth
209
+ fourteenth
210
+ fifteenth
211
+ sixteenth
212
+ seventeenth
213
+ eighteenth
214
+ nineteenth
215
+ twentieth
216
+ twenty-first
217
+ twenty-second
218
+ twenty-third
219
+ twenty-fourth
220
+ twenty-fifth
221
+
222
+ Press ↑↓ arrows to select, enter to confirm
223
+ "
224
+ `);
225
+ await waitForInputsToBeReady();
226
+ await sendInputAndWaitForContent(renderInstance, 'thirty-sixth', 'i');
227
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
228
+ "? Associate your project with the org Castile Ventures? i 
229
+
230
+ > first
231
+ third
232
+ fifth
233
+ sixth
234
+ eighth
235
+ ninth
236
+ thirteenth
237
+ fifteenth
238
+ sixteenth
239
+ eighteenth
240
+ nineteenth
241
+ twentieth
242
+ twenty-first
243
+ twenty-third
244
+ twenty-fifth
245
+ twenty-sixth
246
+ twenty-eighth
247
+ twenty-ninth
248
+ thirtieth
249
+ thirty-first
250
+ thirty-second
251
+ thirty-third
252
+ thirty-fourth
253
+ thirty-fifth
254
+ thirty-sixth
255
+
256
+ Press ↑↓ arrows to select, enter to confirm
257
+ "
258
+ `);
259
+ await sendInputAndWaitForChange(renderInstance, DELETE);
260
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
261
+ "? Associate your project with the org Castile Ventures? Type to search...
262
+
263
+ > first
264
+ second
265
+ third
266
+ fourth
267
+ fifth
268
+ sixth
269
+ seventh
270
+ eighth
271
+ ninth
272
+ tenth
273
+ eleventh
274
+ twelfth
275
+ thirteenth
276
+ fourteenth
277
+ fifteenth
278
+ sixteenth
279
+ seventeenth
280
+ eighteenth
281
+ nineteenth
282
+ twentieth
283
+ twenty-first
284
+ twenty-second
285
+ twenty-third
286
+ twenty-fourth
287
+ twenty-fifth
288
+
289
+ Press ↑↓ arrows to select, enter to confirm
290
+ "
291
+ `);
292
+ await sendInputAndWaitForContent(renderInstance, 'thirty-sixth', 'i');
293
+ await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
294
+ await sendInputAndWaitForChange(renderInstance, ARROW_DOWN);
295
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
296
+ "? Associate your project with the org Castile Ventures? i 
297
+
298
+ first
299
+ third
300
+ > fifth
301
+ sixth
302
+ eighth
303
+ ninth
304
+ thirteenth
305
+ fifteenth
306
+ sixteenth
307
+ eighteenth
308
+ nineteenth
309
+ twentieth
310
+ twenty-first
311
+ twenty-third
312
+ twenty-fifth
313
+ twenty-sixth
314
+ twenty-eighth
315
+ twenty-ninth
316
+ thirtieth
317
+ thirty-first
318
+ thirty-second
319
+ thirty-third
320
+ thirty-fourth
321
+ thirty-fifth
322
+ thirty-sixth
323
+
324
+ Press ↑↓ arrows to select, enter to confirm
325
+ "
326
+ `);
327
+ await sendInputAndWaitForChange(renderInstance, ENTER);
328
+ expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`
329
+ "? Associate your project with the org Castile Ventures?
330
+ ✔ fifth
331
+ "
332
+ `);
333
+ expect(onEnter).toHaveBeenCalledWith('fifth');
334
+ });
335
+ test('allows selecting the first item after searching and triggering the loading state', async () => {
336
+ const onEnter = vi.fn();
337
+ const search = async (term) => {
338
+ await new Promise((resolve) => setTimeout(resolve, 300));
339
+ return DATABASE.filter((item) => item.label.includes(term));
340
+ };
341
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: DATABASE, onSubmit: onEnter, search: search }));
342
+ await waitForInputsToBeReady();
343
+ await sendInputAndWaitForContent(renderInstance, 'Loading...', 'e');
344
+ await waitForContent(renderInstance, 'Press ↑↓ arrows to select, enter to confirm');
345
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
346
+ "? Associate your project with the org Castile Ventures? e 
347
+
348
+ > second
349
+ seventh
350
+ eighth
351
+ tenth
352
+ eleventh
353
+ twelfth
354
+ thirteenth
355
+ fourteenth
356
+ fifteenth
357
+ sixteenth
358
+ seventeenth
359
+ eighteenth
360
+ nineteenth
361
+ twentieth
362
+ twenty-first
363
+ twenty-second
364
+ twenty-third
365
+ twenty-fourth
366
+ twenty-fifth
367
+ twenty-sixth
368
+ twenty-seventh
369
+ twenty-eighth
370
+ twenty-ninth
371
+ thirtieth
372
+ thirty-second
373
+
374
+ Press ↑↓ arrows to select, enter to confirm
375
+ "
376
+ `);
377
+ await sendInputAndWaitForChange(renderInstance, ENTER);
378
+ expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`
379
+ "? Associate your project with the org Castile Ventures?
380
+ ✔ second
381
+ "
382
+ `);
383
+ expect(onEnter).toHaveBeenCalledWith('second');
384
+ });
385
+ test('displays an error message if the search fails', async () => {
386
+ const search = (_term) => {
387
+ return Promise.reject(new Error('Something went wrong'));
388
+ };
389
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: DATABASE, onSubmit: () => { }, search: search }));
390
+ await waitForInputsToBeReady();
391
+ await sendInputAndWaitForContent(renderInstance, 'There has been an error', 'i');
392
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
393
+ "? Associate your project with the org Castile Ventures? i 
394
+
395
+ There has been an error while searching. Please try again later.
396
+ "
397
+ `);
398
+ });
399
+ test('immediately shows the initial items if the search is empty', async () => {
400
+ const search = (term) => {
401
+ return Promise.resolve(DATABASE.filter((item) => item.label.includes(term)));
402
+ };
403
+ const renderInstance = render(React.createElement(AutocompletePrompt, { message: "Associate your project with the org Castile Ventures?", choices: DATABASE, onSubmit: () => { }, search: search }));
404
+ await waitForInputsToBeReady();
405
+ await sendInputAndWaitForContent(renderInstance, 'thirty-sixth', 'i');
406
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
407
+ "? Associate your project with the org Castile Ventures? i 
408
+
409
+ > first
410
+ third
411
+ fifth
412
+ sixth
413
+ eighth
414
+ ninth
415
+ thirteenth
416
+ fifteenth
417
+ sixteenth
418
+ eighteenth
419
+ nineteenth
420
+ twentieth
421
+ twenty-first
422
+ twenty-third
423
+ twenty-fifth
424
+ twenty-sixth
425
+ twenty-eighth
426
+ twenty-ninth
427
+ thirtieth
428
+ thirty-first
429
+ thirty-second
430
+ thirty-third
431
+ thirty-fourth
432
+ thirty-fifth
433
+ thirty-sixth
434
+
435
+ Press ↑↓ arrows to select, enter to confirm
436
+ "
437
+ `);
438
+ await sendInputAndWaitForChange(renderInstance, DELETE);
439
+ expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
440
+ "? Associate your project with the org Castile Ventures? Type to search...
441
+
442
+ > first
443
+ second
444
+ third
445
+ fourth
446
+ fifth
447
+ sixth
448
+ seventh
449
+ eighth
450
+ ninth
451
+ tenth
452
+ eleventh
453
+ twelfth
454
+ thirteenth
455
+ fourteenth
456
+ fifteenth
457
+ sixteenth
458
+ seventeenth
459
+ eighteenth
460
+ nineteenth
461
+ twentieth
462
+ twenty-first
463
+ twenty-second
464
+ twenty-third
465
+ twenty-fourth
466
+ twenty-fifth
467
+
468
+ Press ↑↓ arrows to select, enter to confirm
469
+ "
470
+ `);
471
+ });
472
+ });
473
+ //# sourceMappingURL=AutocompletePrompt.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutocompletePrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/AutocompletePrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,0BAA0B,EAC1B,cAAc,EACd,sBAAsB,GACvB,MAAM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xD,CAAC,CAAA;QAEF,MAAM,yBAAyB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;QAEvD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BxD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {AutocompletePrompt} from './AutocompletePrompt.js'\nimport {Item} from './SelectInput.js'\nimport {\n getLastFrameAfterUnmount,\n sendInputAndWait,\n sendInputAndWaitForChange,\n sendInputAndWaitForContent,\n waitForContent,\n waitForInputsToBeReady,\n} from '../../../../testing/ui.js'\nimport {describe, expect, test, vi} from 'vitest'\nimport React from 'react'\nimport {render} from 'ink-testing-library'\n\nconst ARROW_DOWN = '\\u001B[B'\nconst ENTER = '\\r'\nconst DELETE = '\\u007F'\n\nconst DATABASE = [\n {label: 'first', value: 'first'},\n {label: 'second', value: 'second'},\n {label: 'third', value: 'third'},\n {label: 'fourth', value: 'fourth'},\n {label: 'fifth', value: 'fifth'},\n {label: 'sixth', value: 'sixth'},\n {label: 'seventh', value: 'seventh'},\n {label: 'eighth', value: 'eighth'},\n {label: 'ninth', value: 'ninth'},\n {label: 'tenth', value: 'tenth'},\n {label: 'eleventh', value: 'eleventh'},\n {label: 'twelfth', value: 'twelfth'},\n {label: 'thirteenth', value: 'thirteenth'},\n {label: 'fourteenth', value: 'fourteenth'},\n {label: 'fifteenth', value: 'fifteenth'},\n {label: 'sixteenth', value: 'sixteenth'},\n {label: 'seventeenth', value: 'seventeenth'},\n {label: 'eighteenth', value: 'eighteenth'},\n {label: 'nineteenth', value: 'nineteenth'},\n {label: 'twentieth', value: 'twentieth'},\n {label: 'twenty-first', value: 'twenty-first'},\n {label: 'twenty-second', value: 'twenty-second'},\n {label: 'twenty-third', value: 'twenty-third'},\n {label: 'twenty-fourth', value: 'twenty-fourth'},\n {label: 'twenty-fifth', value: 'twenty-fifth'},\n {label: 'twenty-sixth', value: 'twenty-sixth'},\n {label: 'twenty-seventh', value: 'twenty-seventh'},\n {label: 'twenty-eighth', value: 'twenty-eighth'},\n {label: 'twenty-ninth', value: 'twenty-ninth'},\n {label: 'thirtieth', value: 'thirtieth'},\n {label: 'thirty-first', value: 'thirty-first'},\n {label: 'thirty-second', value: 'thirty-second'},\n {label: 'thirty-third', value: 'thirty-third'},\n {label: 'thirty-fourth', value: 'thirty-fourth'},\n {label: 'thirty-fifth', value: 'thirty-fifth'},\n {label: 'thirty-sixth', value: 'thirty-sixth'},\n {label: 'thirty-seventh', value: 'thirty-seventh'},\n {label: 'thirty-eighth', value: 'thirty-eighth'},\n {label: 'thirty-ninth', value: 'thirty-ninth'},\n {label: 'fortieth', value: 'fortieth'},\n {label: 'forty-first', value: 'forty-first'},\n {label: 'forty-second', value: 'forty-second'},\n {label: 'forty-third', value: 'forty-third'},\n {label: 'forty-fourth', value: 'forty-fourth'},\n {label: 'forty-fifth', value: 'forty-fifth'},\n {label: 'forty-sixth', value: 'forty-sixth'},\n {label: 'forty-seventh', value: 'forty-seventh'},\n {label: 'forty-eighth', value: 'forty-eighth'},\n {label: 'forty-ninth', value: 'forty-ninth'},\n {label: 'fiftieth', value: 'fiftieth'},\n]\n\ndescribe('AutocompletePrompt', async () => {\n test('choose an answer', async () => {\n const onEnter = vi.fn()\n\n const items = [\n {label: 'first', value: 'first'},\n {label: 'second', value: 'second'},\n {label: 'third', value: 'third'},\n ]\n\n const infoTable = {Add: ['new-ext'], Remove: ['integrated-demand-ext', 'order-discount']}\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n infoTable={infoTable}\n onSubmit={onEnter}\n search={() => Promise.resolve([] as Item<string>[])}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ARROW_DOWN)\n await sendInputAndWaitForChange(renderInstance, ENTER)\n\n expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n \u001b[36m✔\u001b[39m \u001b[36msecond\u001b[39m\n \"\n `)\n\n expect(onEnter).toHaveBeenCalledWith(items[1]!.value)\n })\n\n test('renders groups', async () => {\n const items = [\n {label: 'first', value: 'first', group: 'Automations', key: 'f'},\n {label: 'second', value: 'second', group: 'Automations', key: 's'},\n {label: 'third', value: 'third', group: 'Merchant Admin'},\n {label: 'fourth', value: 'fourth', group: 'Merchant Admin'},\n {label: 'fifth', value: 'fifth', key: 'a'},\n {label: 'sixth', value: 'sixth'},\n {label: 'seventh', value: 'seventh'},\n {label: 'eighth', value: 'eighth'},\n {label: 'ninth', value: 'ninth'},\n {label: 'tenth', value: 'tenth'},\n ]\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n search={() => Promise.resolve([] as Item<string>[])}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n \u001b[1mAutomations\u001b[22m\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m\n second\n\n \u001b[1mMerchant Admin\u001b[22m\n third\n fourth\n\n \u001b[1mOther\u001b[22m\n fifth\n sixth\n seventh\n eighth\n ninth\n tenth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n })\n\n test('supports an info table', async () => {\n const items = [\n {label: 'first', value: 'first'},\n {label: 'second', value: 'second'},\n {label: 'third', value: 'third'},\n {label: 'fourth', value: 'fourth'},\n ]\n\n const infoTable = {\n Add: ['new-ext'],\n Remove: ['integrated-demand-ext', 'order-discount'],\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n infoTable={infoTable}\n onSubmit={() => {}}\n search={() => Promise.resolve([] as Item<string>[])}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n Add: • new-ext\n\n Remove: • integrated-demand-ext\n • order-discount\n\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m\n second\n third\n fourth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n })\n\n test(\"doesn't submit if there are no choices\", async () => {\n const onEnter = vi.fn()\n const searchPromise = Promise.resolve([] as Item<string>[])\n const search = () => {\n return searchPromise\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={onEnter}\n search={search}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForContent(renderInstance, 'No results found', 'a')\n // prompt doesn't change when enter is pressed\n await sendInputAndWait(renderInstance, 100, ENTER)\n\n expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36ma\u001b[7m \u001b[27m\u001b[39m\n\n \u001b[2mNo results found.\u001b[22m\n \"\n `)\n\n expect(onEnter).not.toHaveBeenCalled()\n })\n\n test('has a loading state', async () => {\n const onEnter = vi.fn()\n const searchPromise = new Promise<Item<string>[]>((resolve) => {\n setTimeout(() => resolve([{label: 'a', value: 'b'}]), 2000)\n })\n\n const search = () => {\n return searchPromise\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={onEnter}\n search={search}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForContent(renderInstance, 'Loading...', 'a')\n // prompt doesn't change when enter is pressed\n await sendInputAndWait(renderInstance, 100, ENTER)\n\n expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36ma\u001b[7m \u001b[27m\u001b[39m\n\n \u001b[2mLoading...\u001b[22m\n \"\n `)\n\n expect(onEnter).not.toHaveBeenCalled()\n })\n\n test('allows searching with pagination', async () => {\n const onEnter = vi.fn()\n\n const search = async (term: string) => {\n return DATABASE.filter((item) => item.label.includes(term))\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={onEnter}\n search={search}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36m\u001b[7mT\u001b[27m\u001b[2mype to search...\u001b[22m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m\n second\n third\n fourth\n fifth\n sixth\n seventh\n eighth\n ninth\n tenth\n eleventh\n twelfth\n thirteenth\n fourteenth\n fifteenth\n sixteenth\n seventeenth\n eighteenth\n nineteenth\n twentieth\n twenty-first\n twenty-second\n twenty-third\n twenty-fourth\n twenty-fifth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForContent(renderInstance, 'th\u001b[1mi\u001b[22mrty-sixth', 'i')\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36mi\u001b[7m \u001b[27m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mrst\u001b[39m\n th\u001b[1mi\u001b[22mrd\n f\u001b[1mi\u001b[22mfth\n s\u001b[1mi\u001b[22mxth\n e\u001b[1mi\u001b[22mghth\n n\u001b[1mi\u001b[22mnth\n th\u001b[1mi\u001b[22mrteenth\n f\u001b[1mi\u001b[22mfteenth\n s\u001b[1mi\u001b[22mxteenth\n e\u001b[1mi\u001b[22mghteenth\n n\u001b[1mi\u001b[22mneteenth\n twent\u001b[1mi\u001b[22meth\n twenty-f\u001b[1mi\u001b[22mrst\n twenty-th\u001b[1mi\u001b[22mrd\n twenty-f\u001b[1mi\u001b[22mfth\n twenty-s\u001b[1mi\u001b[22mxth\n twenty-e\u001b[1mi\u001b[22mghth\n twenty-n\u001b[1mi\u001b[22mnth\n th\u001b[1mi\u001b[22mrtieth\n th\u001b[1mi\u001b[22mrty-first\n th\u001b[1mi\u001b[22mrty-second\n th\u001b[1mi\u001b[22mrty-third\n th\u001b[1mi\u001b[22mrty-fourth\n th\u001b[1mi\u001b[22mrty-fifth\n th\u001b[1mi\u001b[22mrty-sixth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n\n await sendInputAndWaitForChange(renderInstance, DELETE)\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36m\u001b[7mT\u001b[27m\u001b[2mype to search...\u001b[22m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m\n second\n third\n fourth\n fifth\n sixth\n seventh\n eighth\n ninth\n tenth\n eleventh\n twelfth\n thirteenth\n fourteenth\n fifteenth\n sixteenth\n seventeenth\n eighteenth\n nineteenth\n twentieth\n twenty-first\n twenty-second\n twenty-third\n twenty-fourth\n twenty-fifth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n\n await sendInputAndWaitForContent(renderInstance, 'th\u001b[1mi\u001b[22mrty-sixth', 'i')\n await sendInputAndWaitForChange(renderInstance, ARROW_DOWN)\n await sendInputAndWaitForChange(renderInstance, ARROW_DOWN)\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36mi\u001b[7m \u001b[27m\u001b[39m\n\n f\u001b[1mi\u001b[22mrst\n th\u001b[1mi\u001b[22mrd\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mfth\u001b[39m\n s\u001b[1mi\u001b[22mxth\n e\u001b[1mi\u001b[22mghth\n n\u001b[1mi\u001b[22mnth\n th\u001b[1mi\u001b[22mrteenth\n f\u001b[1mi\u001b[22mfteenth\n s\u001b[1mi\u001b[22mxteenth\n e\u001b[1mi\u001b[22mghteenth\n n\u001b[1mi\u001b[22mneteenth\n twent\u001b[1mi\u001b[22meth\n twenty-f\u001b[1mi\u001b[22mrst\n twenty-th\u001b[1mi\u001b[22mrd\n twenty-f\u001b[1mi\u001b[22mfth\n twenty-s\u001b[1mi\u001b[22mxth\n twenty-e\u001b[1mi\u001b[22mghth\n twenty-n\u001b[1mi\u001b[22mnth\n th\u001b[1mi\u001b[22mrtieth\n th\u001b[1mi\u001b[22mrty-first\n th\u001b[1mi\u001b[22mrty-second\n th\u001b[1mi\u001b[22mrty-third\n th\u001b[1mi\u001b[22mrty-fourth\n th\u001b[1mi\u001b[22mrty-fifth\n th\u001b[1mi\u001b[22mrty-sixth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n\n await sendInputAndWaitForChange(renderInstance, ENTER)\n\n expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n \u001b[36m✔\u001b[39m \u001b[36mfifth\u001b[39m\n \"\n `)\n\n expect(onEnter).toHaveBeenCalledWith('fifth')\n })\n\n test('allows selecting the first item after searching and triggering the loading state', async () => {\n const onEnter = vi.fn()\n\n const search = async (term: string) => {\n await new Promise((resolve) => setTimeout(resolve, 300))\n return DATABASE.filter((item) => item.label.includes(term))\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={onEnter}\n search={search}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForContent(renderInstance, 'Loading...', 'e')\n await waitForContent(renderInstance, 'Press ↑↓ arrows to select, enter to confirm')\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36me\u001b[7m \u001b[27m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36ms\u001b[1me\u001b[22mcond\u001b[39m\n s\u001b[1me\u001b[22mventh\n \u001b[1me\u001b[22mighth\n t\u001b[1me\u001b[22mnth\n \u001b[1me\u001b[22mleventh\n tw\u001b[1me\u001b[22mlfth\n thirt\u001b[1me\u001b[22menth\n fourt\u001b[1me\u001b[22menth\n fift\u001b[1me\u001b[22menth\n sixt\u001b[1me\u001b[22menth\n s\u001b[1me\u001b[22mventeenth\n \u001b[1me\u001b[22mighteenth\n nin\u001b[1me\u001b[22mteenth\n tw\u001b[1me\u001b[22mntieth\n tw\u001b[1me\u001b[22mnty-first\n tw\u001b[1me\u001b[22mnty-second\n tw\u001b[1me\u001b[22mnty-third\n tw\u001b[1me\u001b[22mnty-fourth\n tw\u001b[1me\u001b[22mnty-fifth\n tw\u001b[1me\u001b[22mnty-sixth\n tw\u001b[1me\u001b[22mnty-seventh\n tw\u001b[1me\u001b[22mnty-eighth\n tw\u001b[1me\u001b[22mnty-ninth\n thirti\u001b[1me\u001b[22mth\n thirty-s\u001b[1me\u001b[22mcond\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n\n await sendInputAndWaitForChange(renderInstance, ENTER)\n\n expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n \u001b[36m✔\u001b[39m \u001b[36msecond\u001b[39m\n \"\n `)\n\n expect(onEnter).toHaveBeenCalledWith('second')\n })\n\n test('displays an error message if the search fails', async () => {\n const search = (_term: string) => {\n return Promise.reject(new Error('Something went wrong'))\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={() => {}}\n search={search}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForContent(renderInstance, 'There has been an error', 'i')\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36mi\u001b[7m \u001b[27m\u001b[39m\n\n \u001b[31mThere has been an error while searching. Please try again later.\u001b[39m\n \"\n `)\n })\n\n test('immediately shows the initial items if the search is empty', async () => {\n const search = (term: string) => {\n return Promise.resolve(DATABASE.filter((item) => item.label.includes(term)))\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={() => {}}\n search={search}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForContent(renderInstance, 'th\u001b[1mi\u001b[22mrty-sixth', 'i')\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36mi\u001b[7m \u001b[27m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mrst\u001b[39m\n th\u001b[1mi\u001b[22mrd\n f\u001b[1mi\u001b[22mfth\n s\u001b[1mi\u001b[22mxth\n e\u001b[1mi\u001b[22mghth\n n\u001b[1mi\u001b[22mnth\n th\u001b[1mi\u001b[22mrteenth\n f\u001b[1mi\u001b[22mfteenth\n s\u001b[1mi\u001b[22mxteenth\n e\u001b[1mi\u001b[22mghteenth\n n\u001b[1mi\u001b[22mneteenth\n twent\u001b[1mi\u001b[22meth\n twenty-f\u001b[1mi\u001b[22mrst\n twenty-th\u001b[1mi\u001b[22mrd\n twenty-f\u001b[1mi\u001b[22mfth\n twenty-s\u001b[1mi\u001b[22mxth\n twenty-e\u001b[1mi\u001b[22mghth\n twenty-n\u001b[1mi\u001b[22mnth\n th\u001b[1mi\u001b[22mrtieth\n th\u001b[1mi\u001b[22mrty-first\n th\u001b[1mi\u001b[22mrty-second\n th\u001b[1mi\u001b[22mrty-third\n th\u001b[1mi\u001b[22mrty-fourth\n th\u001b[1mi\u001b[22mrty-fifth\n th\u001b[1mi\u001b[22mrty-sixth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n\n await sendInputAndWaitForChange(renderInstance, DELETE)\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36m\u001b[7mT\u001b[27m\u001b[2mype to search...\u001b[22m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m\n second\n third\n fourth\n fifth\n sixth\n seventh\n eighth\n ninth\n tenth\n eleventh\n twelfth\n thirteenth\n fourteenth\n fifteenth\n sixteenth\n seventeenth\n eighteenth\n nineteenth\n twentieth\n twenty-first\n twenty-second\n twenty-third\n twenty-fourth\n twenty-fifth\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm\u001b[22m\n \"\n `)\n })\n})\n"]}
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  export declare type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error';
3
3
  interface Props {
4
4
  type: BannerType;
5
- marginY?: number;
6
5
  }
7
6
  declare const Banner: React.FC<Props>;
8
7
  export { Banner };
@@ -10,16 +10,16 @@ function typeToColor(type) {
10
10
  external_error: 'red',
11
11
  }[type];
12
12
  }
13
- const BoxWithBorder = ({ type, marginY, children }) => {
13
+ const BoxWithBorder = ({ type, children }) => {
14
14
  const { twoThirds } = useLayout();
15
- return (React.createElement(Box, { width: twoThirds, paddingY: 1, paddingX: 2, marginY: marginY, borderStyle: "round", flexDirection: "column", borderColor: typeToColor(type) },
15
+ return (React.createElement(Box, { width: twoThirds, paddingY: 1, paddingX: 2, marginBottom: 1, borderStyle: "round", flexDirection: "column", borderColor: typeToColor(type) },
16
16
  React.createElement(Box, { marginTop: -2, marginBottom: 1, marginLeft: -1 },
17
17
  React.createElement(Text, null, ` ${type.replace(/_/g, ' ')} `)),
18
18
  children));
19
19
  };
20
- const BoxWithTopBottomLines = ({ type, marginY, children }) => {
20
+ const BoxWithTopBottomLines = ({ type, children }) => {
21
21
  const { twoThirds } = useLayout();
22
- return (React.createElement(Box, { marginY: marginY, flexDirection: "column" },
22
+ return (React.createElement(Box, { flexDirection: "column", marginBottom: 1 },
23
23
  React.createElement(Box, { marginBottom: 1 },
24
24
  React.createElement(Text, null,
25
25
  React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(2)),
@@ -1 +1 @@
1
- {"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,SAAS,WAAW,CAAC,IAAmB;IACtC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,KAAK;QACX,cAAc,EAAE,KAAK;KACtB,CAAC,IAAI,CAAC,CAAA;AACT,CAAC;AAED,MAAM,aAAa,GAAoB,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,EAAE,EAAE;IACnE,MAAM,EAAC,SAAS,EAAC,GAAG,SAAS,EAAE,CAAA;IAE/B,OAAO,CACL,oBAAC,GAAG,IACF,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,EACX,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,OAAO,EAChB,WAAW,EAAC,OAAO,EACnB,aAAa,EAAC,QAAQ,EACtB,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC;QAE9B,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YACjD,oBAAC,IAAI,QAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAQ,CACzC;QACL,QAAQ,CACL,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAoB,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,EAAE,EAAE;IAC3E,MAAM,EAAC,SAAS,EAAC,GAAG,SAAS,EAAE,CAAA;IAE/B,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAC,QAAQ;QAC3C,oBAAC,GAAG,IAAC,YAAY,EAAE,CAAC;YAClB,oBAAC,IAAI;gBACH,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAQ;gBACtD,oBAAC,IAAI,QAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAQ;gBAE7C,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAQ,CAC/E,CACH;QAEL,QAAQ;QAET,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAQ,CAC1D,CACF,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAoB,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAC,EAAE,EAAE;IACvD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACnC,OAAO,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KACnE;SAAM;QACL,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KAC3D;AACH,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import useLayout from '../hooks/use-layout.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error'\n\ninterface Props {\n type: BannerType\n marginY?: number\n}\n\nfunction typeToColor(type: Props['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n external_error: 'red',\n }[type]\n}\n\nconst BoxWithBorder: React.FC<Props> = ({type, marginY, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box\n width={twoThirds}\n paddingY={1}\n paddingX={2}\n marginY={marginY}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-2} marginBottom={1} marginLeft={-1}>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n </Box>\n {children}\n </Box>\n )\n}\n\nconst BoxWithTopBottomLines: React.FC<Props> = ({type, marginY, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box marginY={marginY} flexDirection=\"column\">\n <Box marginBottom={1}>\n <Text>\n <Text color={typeToColor(type)}>{'─'.repeat(2)}</Text>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n {/* 2 initial dashes + 2 spaces surrounding the type */}\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds - 2 - type.length - 2)}</Text>\n </Text>\n </Box>\n\n {children}\n\n <Box marginTop={1}>\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds)}</Text>\n </Box>\n </Box>\n )\n}\n\nconst Banner: React.FC<Props> = ({children, ...props}) => {\n if (props.type === 'external_error') {\n return React.createElement(BoxWithTopBottomLines, props, children)\n } else {\n return React.createElement(BoxWithBorder, props, children)\n }\n}\n\nexport {Banner}\n"]}
1
+ {"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,SAAS,WAAW,CAAC,IAAmB;IACtC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAA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CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAQ,CAC/E,CACH;QAEL,QAAQ;QAET,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAQ,CAC1D,CACF,CACP,CAAA;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAoB,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAC,EAAE,EAAE;IACvD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACnC,OAAO,KAAK,CAAC,aAAa,CAAC,qBAAqB,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KACnE;SAAM;QACL,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;KAC3D;AACH,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import useLayout from '../hooks/use-layout.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error'\n\ninterface Props {\n type: BannerType\n}\n\nfunction typeToColor(type: Props['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n external_error: 'red',\n }[type]\n}\n\nconst BoxWithBorder: React.FC<Props> = ({type, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box\n width={twoThirds}\n paddingY={1}\n paddingX={2}\n marginBottom={1}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-2} marginBottom={1} marginLeft={-1}>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n </Box>\n {children}\n </Box>\n )\n}\n\nconst BoxWithTopBottomLines: React.FC<Props> = ({type, children}) => {\n const {twoThirds} = useLayout()\n\n return (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box marginBottom={1}>\n <Text>\n <Text color={typeToColor(type)}>{'─'.repeat(2)}</Text>\n <Text>{` ${type.replace(/_/g, ' ')} `}</Text>\n {/* 2 initial dashes + 2 spaces surrounding the type */}\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds - 2 - type.length - 2)}</Text>\n </Text>\n </Box>\n\n {children}\n\n <Box marginTop={1}>\n <Text color={typeToColor(type)}>{'─'.repeat(twoThirds)}</Text>\n </Box>\n </Box>\n )\n}\n\nconst Banner: React.FC<Props> = ({children, ...props}) => {\n if (props.type === 'external_error') {\n return React.createElement(BoxWithTopBottomLines, props, children)\n } else {\n return React.createElement(BoxWithBorder, props, children)\n }\n}\n\nexport {Banner}\n"]}
@@ -9,7 +9,8 @@ describe('Banner', async () => {
9
9
  "╭─ success ────────────────────────────────────────────────────────────────────╮
10
10
  │ │
11
11
  │ │
12
- ╰──────────────────────────────────────────────────────────────────────────────╯"
12
+ ╰──────────────────────────────────────────────────────────────────────────────╯
13
+ "
13
14
  `);
14
15
  });
15
16
  test('renders with a border for info', async () => {
@@ -18,7 +19,8 @@ describe('Banner', async () => {
18
19
  "╭─ info ───────────────────────────────────────────────────────────────────────╮
19
20
  │ │
20
21
  │ │
21
- ╰──────────────────────────────────────────────────────────────────────────────╯"
22
+ ╰──────────────────────────────────────────────────────────────────────────────╯
23
+ "
22
24
  `);
23
25
  });
24
26
  test('renders with a border for warning', async () => {
@@ -27,7 +29,8 @@ describe('Banner', async () => {
27
29
  "╭─ warning ────────────────────────────────────────────────────────────────────╮
28
30
  │ │
29
31
  │ │
30
- ╰──────────────────────────────────────────────────────────────────────────────╯"
32
+ ╰──────────────────────────────────────────────────────────────────────────────╯
33
+ "
31
34
  `);
32
35
  });
33
36
  test('renders with a border for error', async () => {
@@ -36,7 +39,8 @@ describe('Banner', async () => {
36
39
  "╭─ error ──────────────────────────────────────────────────────────────────────╮
37
40
  │ │
38
41
  │ │
39
- ╰──────────────────────────────────────────────────────────────────────────────╯"
42
+ ╰──────────────────────────────────────────────────────────────────────────────╯
43
+ "
40
44
  `);
41
45
  });
42
46
  test('renders with a top and bottom lines only for external errors', async () => {
@@ -45,7 +49,8 @@ describe('Banner', async () => {
45
49
  "── external error ──────────────────────────────────────────────────────────────
46
50
 
47
51
 
48
- ────────────────────────────────────────────────────────────────────────────────"
52
+ ────────────────────────────────────────────────────────────────────────────────
53
+ "
49
54
  `);
50
55
  });
51
56
  });