@shopify/cli-kit 3.49.7 → 3.50.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.
- package/assets/cli-ruby/lib/project_types/theme/commands/console.rb +3 -1
- package/assets/cli-ruby/lib/shopify_cli/theme/file.rb +2 -0
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_dev_server.rb +2 -4
- package/assets/cli-ruby/lib/shopify_cli/theme/repl/remote_evaluator.rb +3 -0
- package/assets/cli-ruby/lib/shopify_cli/theme/repl.rb +4 -3
- package/dist/private/node/constants.d.ts +2 -0
- package/dist/private/node/constants.js +2 -0
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/context/utilities.js +2 -3
- package/dist/private/node/context/utilities.js.map +1 -1
- package/dist/private/node/otel-metrics.d.ts +32 -0
- package/dist/private/node/otel-metrics.js +131 -0
- package/dist/private/node/otel-metrics.js.map +1 -0
- package/dist/private/node/session/authorize.js +8 -5
- package/dist/private/node/session/authorize.js.map +1 -1
- package/dist/private/node/testing/ui.d.ts +4 -2
- package/dist/private/node/testing/ui.js +10 -3
- package/dist/private/node/testing/ui.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +6 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +5 -3
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js +12 -6
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/GitDiff.test.js +18 -11
- package/dist/private/node/ui/components/Prompts/GitDiff.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.js +8 -4
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +5 -3
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.js +8 -1
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.js +7 -3
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.d.ts +10 -1
- package/dist/private/node/ui/components/TokenizedText.js +18 -0
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js +10 -1
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui/utilities.d.ts +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.d.ts +2 -0
- package/dist/public/node/analytics.js +48 -10
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/graphql.js +8 -5
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/base-command.js +4 -3
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli.js +5 -2
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/local.d.ts +16 -0
- package/dist/public/node/context/local.js +23 -0
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/error-handler.d.ts +4 -1
- package/dist/public/node/error-handler.js +26 -18
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.d.ts +1 -1
- package/dist/public/node/error.js +1 -1
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/hooks/postrun.js +1 -1
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/http.js +27 -22
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/metadata.d.ts +12 -4
- package/dist/public/node/metadata.js +52 -4
- package/dist/public/node/metadata.js.map +1 -1
- package/dist/public/node/monorail.d.ts +8 -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 +6 -0
- package/dist/public/node/node-package-manager.js +16 -2
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/testing/ui.d.ts +1 -1
- package/dist/public/node/testing/ui.js +1 -1
- package/dist/public/node/testing/ui.js.map +1 -1
- package/dist/public/node/ui.d.ts +1 -1
- package/dist/public/node/ui.js +63 -56
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.d.ts +18 -0
- package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js +36 -0
- package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js.map +1 -0
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.d.ts +46 -0
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js +112 -0
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js.map +1 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultMeterProvider.d.ts +13 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultMeterProvider.js +36 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultMeterProvider.js.map +1 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.d.ts +24 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js +33 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js.map +1 -0
- package/dist/public/node/vendor/otel-js/service/types.d.ts +43 -0
- package/dist/public/node/vendor/otel-js/service/types.js +7 -0
- package/dist/public/node/vendor/otel-js/service/types.js.map +1 -0
- package/dist/public/node/vendor/otel-js/utils/throttle.d.ts +7 -0
- package/dist/public/node/vendor/otel-js/utils/throttle.js +42 -0
- package/dist/public/node/vendor/otel-js/utils/throttle.js.map +1 -0
- package/dist/public/node/vendor/otel-js/utils/validators.d.ts +1 -0
- package/dist/public/node/vendor/otel-js/utils/validators.js +11 -0
- package/dist/public/node/vendor/otel-js/utils/validators.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -16
- package/assets/cli-ruby/RELEASING.md +0 -72
|
@@ -5,6 +5,7 @@ import { AbortController } from '../../../../public/node/abort.js';
|
|
|
5
5
|
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { useStdout } from 'ink';
|
|
8
|
+
import { platformAndArch } from '@shopify/cli-kit/node/os';
|
|
8
9
|
vi.mock('ink', async () => {
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
11
|
const original = await vi.importActual('ink');
|
|
@@ -170,7 +171,8 @@ describe('AutocompletePrompt', async () => {
|
|
|
170
171
|
"
|
|
171
172
|
`);
|
|
172
173
|
});
|
|
173
|
-
|
|
174
|
+
const runningOnWindows = platformAndArch().platform === 'windows';
|
|
175
|
+
test.skipIf(runningOnWindows)('supports a git diff', async () => {
|
|
174
176
|
const items = [
|
|
175
177
|
{ label: 'first', value: 'first' },
|
|
176
178
|
{ label: 'second', value: 'second' },
|
|
@@ -185,8 +187,8 @@ describe('AutocompletePrompt', async () => {
|
|
|
185
187
|
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
186
188
|
"? Associate your project with the org Castile Ventures?
|
|
187
189
|
|
|
188
|
-
┃ [31m- hello[m
|
|
189
|
-
┃ [32m+ [m[32mworld[m
|
|
190
|
+
┃ [31m- hello[m[39m
|
|
191
|
+
┃ [32m+ [m[32mworld[m[0m[39m
|
|
190
192
|
|
|
191
193
|
[36m>[39m [36mfirst[39m
|
|
192
194
|
second
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompletePrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/AutocompletePrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,kB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AutocompletePrompt.js'\nimport {\n getLastFrameAfterUnmount,\n sendInputAndWait,\n sendInputAndWaitForChange,\n sendInputAndWaitForContent,\n waitForInputsToBeReady,\n render,\n} from '../../testing/ui.js'\nimport {Stdout} from '../../ui.js'\nimport {AbortController} from '../../../../public/node/abort.js'\nimport {beforeEach, describe, expect, test, vi} from 'vitest'\nimport React from 'react'\nimport {useStdout} from 'ink'\n\nvi.mock('ink', async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const original: any = await vi.importActual('ink')\n return {\n ...original,\n useStdout: vi.fn(),\n }\n})\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\nbeforeEach(() => {\n vi.mocked(useStdout).mockReturnValue({\n stdout: new Stdout({\n columns: 80,\n rows: 80,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any,\n write: () => {},\n })\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', {userInput: 'Castile Ventures'}, {char: '?'}]}\n choices={items}\n infoTable={infoTable}\n onSubmit={onEnter}\n search={() =>\n Promise.resolve({\n data: [],\n } as SearchResults<string>)\n }\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 \u001b[36mCastile Ventures\u001b[39m?\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'},\n {label: 'second', value: 'second', group: 'Automations'},\n {label: 'third', value: 'third', group: 'Merchant Admin'},\n {label: 'fourth', value: 'fourth', group: 'Merchant Admin'},\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 ]\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n search={() =>\n Promise.resolve({\n data: [],\n } as SearchResults<string>)\n }\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[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({data: []} as SearchResults<string>)}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n ┃ \\u001b[1mAdd\\u001b[22m\n ┃ • new-ext\n ┃\n ┃ \\u001b[1mRemove\\u001b[22m\n ┃ • 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('supports a git diff', 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 gitDiff = {\n baselineContent: 'hello\\n',\n updatedContent: 'world\\n',\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n gitDiff={gitDiff}\n onSubmit={() => {}}\n search={() => Promise.resolve({data: []} as SearchResults<string>)}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n ┃ \u001b[31m- hello\u001b[m\n ┃ \u001b[32m+ \u001b[m\u001b[32mworld\u001b[m\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('supports an info message', 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 infoMessage = {\n title: {\n color: 'red',\n text: 'Info message title',\n },\n body: 'Info message body',\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n infoMessage={infoMessage}\n onSubmit={() => {}}\n search={() => Promise.resolve({data: []} as SearchResults<string>)}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n ┃ \u001b[31mInfo message title\u001b[39m\n ┃\n ┃ Info message body\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({\n data: [],\n } as SearchResults<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(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36ma\u001b[46m█\u001b[49m\u001b[39m\n\n \u001b[2mNo results found.\u001b[22m\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \u001b[2mTry again with a different keyword.\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\n const search = () => {\n return new Promise<SearchResults<string>>((resolve) => {\n setTimeout(() => {\n resolve({data: [{label: 'a', value: 'b'}]})\n }, 2000)\n })\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 new Promise((resolve) => setTimeout(resolve, 100))\n await sendInputAndWait(renderInstance, 100, ENTER)\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36ma\u001b[46m█\u001b[49m\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 {\n data: DATABASE.filter((item) => item.label.includes(term)),\n }\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\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[46m█\u001b[49m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mrst\u001b[39m \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrteenth \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfteenth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxteenth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghteenth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mneteenth \u001b[46m \u001b[49m\n twent\u001b[1mi\u001b[22meth \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n twenty-th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n twenty-s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n twenty-e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n twenty-n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrtieth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-first \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-second \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-third \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fourth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fifth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-sixth \u001b[100m \u001b[49m\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\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[46m█\u001b[49m\u001b[39m\n\n f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mfth\u001b[39m \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrteenth \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfteenth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxteenth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghteenth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mneteenth \u001b[46m \u001b[49m\n twent\u001b[1mi\u001b[22meth \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n twenty-th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n twenty-s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n twenty-e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n twenty-n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrtieth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-first \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-second \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-third \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fourth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fifth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-sixth \u001b[100m \u001b[49m\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('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[46m█\u001b[49m\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({\n data: DATABASE.filter((item) => item.label.includes(term)),\n })\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[46m█\u001b[49m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mrst\u001b[39m \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrteenth \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfteenth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxteenth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghteenth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mneteenth \u001b[46m \u001b[49m\n twent\u001b[1mi\u001b[22meth \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n twenty-th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n twenty-s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n twenty-e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n twenty-n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrtieth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-first \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-second \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-third \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fourth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fifth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-sixth \u001b[100m \u001b[49m\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm.\u001b[22m\n \"\n `)\n })\n\n test('shows a message that indicates there are more results than shown', async () => {\n const search = (_term: string) => {\n return Promise.resolve({\n data: DATABASE,\n meta: {hasNextPage: true},\n })\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={() => {}}\n hasMorePages\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm.\u001b[22m\n \u001b[1m1-50 of many\u001b[22m Find what you're looking for by typing its name.\n \"\n `)\n })\n\n test('adapts to the height of the container', async () => {\n vi.mocked(useStdout).mockReturnValue({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stdout: new Stdout({rows: 10}) as any,\n write: () => {},\n })\n\n const items = [\n {label: 'first', value: 'first', group: 'Automations'},\n {label: 'second', value: 'second', group: 'Automations'},\n {label: 'third', value: 'third', group: 'Merchant Admin'},\n {label: 'fourth', value: 'fourth', group: 'Merchant Admin'},\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 ]\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n hasMorePages\n search={() =>\n Promise.resolve({\n data: items,\n } as SearchResults<string>)\n }\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[1mAutomations\u001b[22m \\u001b[46m \\u001b[49m\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m \\u001b[100m \\u001b[49m\n second \\u001b[100m \\u001b[49m\n \\u001b[100m \\u001b[49m\n \u001b[1mMerchant Admin\u001b[22m \\u001b[100m \\u001b[49m\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm.\u001b[22m\n \u001b[1m1-10 of many\u001b[22m Find what you're looking for by typing its name.\n \"\n `)\n })\n\n test('abortController can be used to exit the prompt from outside', async () => {\n const items = [\n {label: 'a', value: 'a'},\n {label: 'b', value: 'b'},\n ]\n\n const abortController = new AbortController()\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n search={() =>\n Promise.resolve({\n data: [],\n } as SearchResults<string>)\n }\n abortSignal={abortController.signal}\n />,\n )\n const promise = renderInstance.waitUntilExit()\n\n abortController.abort()\n\n // wait for the onAbort promise to resolve\n await new Promise((resolve) => setTimeout(resolve, 0))\n\n expect(getLastFrameAfterUnmount(renderInstance)).toEqual('')\n await expect(promise).resolves.toEqual(undefined)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"AutocompletePrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/AutocompletePrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAgB,MAAM,yBAAyB,CAAA;AACzE,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,MAAM,GACP,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAA;AAChE,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AAExD,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;IACxB,8DAA8D;IAC9D,MAAM,QAAQ,GAAQ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G,IAAI,eAAe,EAAE,CAAA;QAE7C,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,kBAAkB,IACjB,OAAO,EAAC,uDAAuD,EAC/D,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAClB,MAAM,EAAE,GAAG,EAAE,CACX,OAAO,CAAC,OAAO,CAAC;gBACd,IAAI,EAAE,EAAE;aACgB,CAAC,EAE7B,WAAW,EAAE,eAAe,CAAC,MAAM,GACnC,CACH,CAAA;QACD,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,EAAE,CAAA;QAE9C,eAAe,CAAC,KAAK,EAAE,CAAA;QAEvB,0CAA0C;QAC1C,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;QAEtD,MAAM,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC5D,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {AutocompletePrompt, SearchResults} from './AutocompletePrompt.js'\nimport {\n getLastFrameAfterUnmount,\n sendInputAndWait,\n sendInputAndWaitForChange,\n sendInputAndWaitForContent,\n waitForInputsToBeReady,\n render,\n} from '../../testing/ui.js'\nimport {Stdout} from '../../ui.js'\nimport {AbortController} from '../../../../public/node/abort.js'\nimport {beforeEach, describe, expect, test, vi} from 'vitest'\nimport React from 'react'\nimport {useStdout} from 'ink'\nimport {platformAndArch} from '@shopify/cli-kit/node/os'\n\nvi.mock('ink', async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const original: any = await vi.importActual('ink')\n return {\n ...original,\n useStdout: vi.fn(),\n }\n})\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\nbeforeEach(() => {\n vi.mocked(useStdout).mockReturnValue({\n stdout: new Stdout({\n columns: 80,\n rows: 80,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any,\n write: () => {},\n })\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', {userInput: 'Castile Ventures'}, {char: '?'}]}\n choices={items}\n infoTable={infoTable}\n onSubmit={onEnter}\n search={() =>\n Promise.resolve({\n data: [],\n } as SearchResults<string>)\n }\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 \u001b[36mCastile Ventures\u001b[39m?\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'},\n {label: 'second', value: 'second', group: 'Automations'},\n {label: 'third', value: 'third', group: 'Merchant Admin'},\n {label: 'fourth', value: 'fourth', group: 'Merchant Admin'},\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 ]\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n search={() =>\n Promise.resolve({\n data: [],\n } as SearchResults<string>)\n }\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[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({data: []} as SearchResults<string>)}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n ┃ \\u001b[1mAdd\\u001b[22m\n ┃ • new-ext\n ┃\n ┃ \\u001b[1mRemove\\u001b[22m\n ┃ • 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 const runningOnWindows = platformAndArch().platform === 'windows'\n\n test.skipIf(runningOnWindows)('supports a git diff', 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 gitDiff = {\n baselineContent: 'hello\\n',\n updatedContent: 'world\\n',\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n gitDiff={gitDiff}\n onSubmit={() => {}}\n search={() => Promise.resolve({data: []} as SearchResults<string>)}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n ┃ \u001b[31m- hello\u001b[m\u001b[39m\n ┃ \u001b[32m+ \u001b[m\u001b[32mworld\u001b[m\u001b[0m\u001b[39m\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('supports an info message', 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 infoMessage = {\n title: {\n color: 'red',\n text: 'Info message title',\n },\n body: 'Info message body',\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n infoMessage={infoMessage}\n onSubmit={() => {}}\n search={() => Promise.resolve({data: []} as SearchResults<string>)}\n />,\n )\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures?\n\n ┃ \u001b[31mInfo message title\u001b[39m\n ┃\n ┃ Info message body\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({\n data: [],\n } as SearchResults<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(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36ma\u001b[46m█\u001b[49m\u001b[39m\n\n \u001b[2mNo results found.\u001b[22m\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \u001b[2mTry again with a different keyword.\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\n const search = () => {\n return new Promise<SearchResults<string>>((resolve) => {\n setTimeout(() => {\n resolve({data: [{label: 'a', value: 'b'}]})\n }, 2000)\n })\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 new Promise((resolve) => setTimeout(resolve, 100))\n await sendInputAndWait(renderInstance, 100, ENTER)\n\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Associate your project with the org Castile Ventures? \u001b[36ma\u001b[46m█\u001b[49m\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 {\n data: DATABASE.filter((item) => item.label.includes(term)),\n }\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\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[46m█\u001b[49m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mrst\u001b[39m \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrteenth \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfteenth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxteenth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghteenth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mneteenth \u001b[46m \u001b[49m\n twent\u001b[1mi\u001b[22meth \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n twenty-th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n twenty-s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n twenty-e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n twenty-n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrtieth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-first \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-second \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-third \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fourth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fifth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-sixth \u001b[100m \u001b[49m\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\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[46m█\u001b[49m\u001b[39m\n\n f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mfth\u001b[39m \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrteenth \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfteenth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxteenth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghteenth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mneteenth \u001b[46m \u001b[49m\n twent\u001b[1mi\u001b[22meth \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n twenty-th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n twenty-s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n twenty-e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n twenty-n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrtieth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-first \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-second \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-third \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fourth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fifth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-sixth \u001b[100m \u001b[49m\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('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[46m█\u001b[49m\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({\n data: DATABASE.filter((item) => item.label.includes(term)),\n })\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[46m█\u001b[49m\u001b[39m\n\n \u001b[36m>\u001b[39m \u001b[36mf\u001b[1mi\u001b[22mrst\u001b[39m \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrteenth \u001b[46m \u001b[49m\n f\u001b[1mi\u001b[22mfteenth \u001b[46m \u001b[49m\n s\u001b[1mi\u001b[22mxteenth \u001b[46m \u001b[49m\n e\u001b[1mi\u001b[22mghteenth \u001b[46m \u001b[49m\n n\u001b[1mi\u001b[22mneteenth \u001b[46m \u001b[49m\n twent\u001b[1mi\u001b[22meth \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mrst \u001b[46m \u001b[49m\n twenty-th\u001b[1mi\u001b[22mrd \u001b[46m \u001b[49m\n twenty-f\u001b[1mi\u001b[22mfth \u001b[46m \u001b[49m\n twenty-s\u001b[1mi\u001b[22mxth \u001b[46m \u001b[49m\n twenty-e\u001b[1mi\u001b[22mghth \u001b[46m \u001b[49m\n twenty-n\u001b[1mi\u001b[22mnth \u001b[46m \u001b[49m\n th\u001b[1mi\u001b[22mrtieth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-first \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-second \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-third \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fourth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-fifth \u001b[100m \u001b[49m\n th\u001b[1mi\u001b[22mrty-sixth \u001b[100m \u001b[49m\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm.\u001b[22m\n \"\n `)\n })\n\n test('shows a message that indicates there are more results than shown', async () => {\n const search = (_term: string) => {\n return Promise.resolve({\n data: DATABASE,\n meta: {hasNextPage: true},\n })\n }\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={DATABASE}\n onSubmit={() => {}}\n hasMorePages\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 \u001b[46m \u001b[49m\n second \u001b[46m \u001b[49m\n third \u001b[46m \u001b[49m\n fourth \u001b[46m \u001b[49m\n fifth \u001b[46m \u001b[49m\n sixth \u001b[46m \u001b[49m\n seventh \u001b[46m \u001b[49m\n eighth \u001b[46m \u001b[49m\n ninth \u001b[46m \u001b[49m\n tenth \u001b[46m \u001b[49m\n eleventh \u001b[46m \u001b[49m\n twelfth \u001b[46m \u001b[49m\n thirteenth \u001b[46m \u001b[49m\n fourteenth \u001b[100m \u001b[49m\n fifteenth \u001b[100m \u001b[49m\n sixteenth \u001b[100m \u001b[49m\n seventeenth \u001b[100m \u001b[49m\n eighteenth \u001b[100m \u001b[49m\n nineteenth \u001b[100m \u001b[49m\n twentieth \u001b[100m \u001b[49m\n twenty-first \u001b[100m \u001b[49m\n twenty-second \u001b[100m \u001b[49m\n twenty-third \u001b[100m \u001b[49m\n twenty-fourth \u001b[100m \u001b[49m\n twenty-fifth \u001b[100m \u001b[49m\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm.\u001b[22m\n \u001b[1m1-50 of many\u001b[22m Find what you're looking for by typing its name.\n \"\n `)\n })\n\n test('adapts to the height of the container', async () => {\n vi.mocked(useStdout).mockReturnValue({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stdout: new Stdout({rows: 10}) as any,\n write: () => {},\n })\n\n const items = [\n {label: 'first', value: 'first', group: 'Automations'},\n {label: 'second', value: 'second', group: 'Automations'},\n {label: 'third', value: 'third', group: 'Merchant Admin'},\n {label: 'fourth', value: 'fourth', group: 'Merchant Admin'},\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 ]\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n hasMorePages\n search={() =>\n Promise.resolve({\n data: items,\n } as SearchResults<string>)\n }\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[1mAutomations\u001b[22m \\u001b[46m \\u001b[49m\n \u001b[36m>\u001b[39m \u001b[36mfirst\u001b[39m \\u001b[100m \\u001b[49m\n second \\u001b[100m \\u001b[49m\n \\u001b[100m \\u001b[49m\n \u001b[1mMerchant Admin\u001b[22m \\u001b[100m \\u001b[49m\n\n \u001b[2mPress ↑↓ arrows to select, enter to confirm.\u001b[22m\n \u001b[1m1-10 of many\u001b[22m Find what you're looking for by typing its name.\n \"\n `)\n })\n\n test('abortController can be used to exit the prompt from outside', async () => {\n const items = [\n {label: 'a', value: 'a'},\n {label: 'b', value: 'b'},\n ]\n\n const abortController = new AbortController()\n\n const renderInstance = render(\n <AutocompletePrompt\n message=\"Associate your project with the org Castile Ventures?\"\n choices={items}\n onSubmit={() => {}}\n search={() =>\n Promise.resolve({\n data: [],\n } as SearchResults<string>)\n }\n abortSignal={abortController.signal}\n />,\n )\n const promise = renderInstance.waitUntilExit()\n\n abortController.abort()\n\n // wait for the onAbort promise to resolve\n await new Promise((resolve) => setTimeout(resolve, 0))\n\n expect(getLastFrameAfterUnmount(renderInstance)).toEqual('')\n await expect(promise).resolves.toEqual(undefined)\n })\n})\n"]}
|
|
@@ -6,7 +6,7 @@ import useLayout from '../hooks/use-layout.js';
|
|
|
6
6
|
import { messageWithPunctuation } from '../utilities.js';
|
|
7
7
|
import useAbortSignal from '../hooks/use-abort-signal.js';
|
|
8
8
|
import usePrompt, { PromptState } from '../hooks/use-prompt.js';
|
|
9
|
-
import React, { useCallback, useState } from 'react';
|
|
9
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
10
10
|
import { Box, useApp, useInput, Text } from 'ink';
|
|
11
11
|
import figures from 'figures';
|
|
12
12
|
const DangerousConfirmationPrompt = ({ message, confirmation, infoTable, onSubmit, abortSignal, }) => {
|
|
@@ -27,8 +27,6 @@ const DangerousConfirmationPrompt = ({ message, confirmation, infoTable, onSubmi
|
|
|
27
27
|
if (key.escape) {
|
|
28
28
|
setPromptState(PromptState.Cancelled);
|
|
29
29
|
setError(undefined);
|
|
30
|
-
onSubmit(false);
|
|
31
|
-
unmountInk();
|
|
32
30
|
}
|
|
33
31
|
if (key.return) {
|
|
34
32
|
const error = validateAnswer(answer);
|
|
@@ -38,18 +36,26 @@ const DangerousConfirmationPrompt = ({ message, confirmation, infoTable, onSubmi
|
|
|
38
36
|
}
|
|
39
37
|
else {
|
|
40
38
|
setPromptState(PromptState.Submitted);
|
|
41
|
-
onSubmit(true);
|
|
42
|
-
unmountInk();
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
});
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (promptState === PromptState.Submitted) {
|
|
44
|
+
onSubmit(true);
|
|
45
|
+
unmountInk();
|
|
46
|
+
}
|
|
47
|
+
else if (promptState === PromptState.Cancelled) {
|
|
48
|
+
onSubmit(false);
|
|
49
|
+
unmountInk();
|
|
50
|
+
}
|
|
51
|
+
}, [onSubmit, promptState, unmountInk]);
|
|
46
52
|
const completed = promptState === PromptState.Submitted || promptState === PromptState.Cancelled;
|
|
47
53
|
return isAborted ? null : (React.createElement(Box, { flexDirection: "column", marginBottom: 1, width: twoThirds },
|
|
48
54
|
React.createElement(Box, null,
|
|
49
55
|
React.createElement(Box, { marginRight: 2 },
|
|
50
56
|
React.createElement(Text, null, "?")),
|
|
51
57
|
React.createElement(TokenizedText, { item: messageWithPunctuation(message) })),
|
|
52
|
-
completed ? (React.createElement(CompletedPrompt, {
|
|
58
|
+
completed ? (React.createElement(CompletedPrompt, { cancelled: promptState === PromptState.Cancelled })) : (React.createElement(React.Fragment, null,
|
|
53
59
|
React.createElement(Box, { flexDirection: "column", gap: 1, marginTop: 1, marginLeft: 3 },
|
|
54
60
|
infoTable ? (React.createElement(Box, { paddingLeft: 2, borderStyle: "bold", borderLeft: true, borderRight: false, borderTop: false, borderBottom: false, flexDirection: "column", gap: 1 },
|
|
55
61
|
React.createElement(InfoTable, { table: infoTable }))) : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DangerousConfirmationPrompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/DangerousConfirmationPrompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAyB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAC,SAAS,EAAiB,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AAEtD,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,SAAS,EAAE,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"DangerousConfirmationPrompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/DangerousConfirmationPrompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAyB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAC,SAAS,EAAiB,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AAEtD,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,SAAS,EAAE,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAChF,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC/C,OAAO,OAAO,MAAM,SAAS,CAAA;AAU7B,MAAM,2BAA2B,GAAwD,CAAC,EACxF,OAAO,EACP,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,WAAW,GACZ,EAAE,EAAE;IACH,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,KAAa,EAAsC,EAAE;QACpD,OAAO,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,uBAAuB,EAAE,EAAC,SAAS,EAAE,YAAY,EAAC,CAAC,CAAA;IAClG,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAA;IAED,MAAM,EAAC,QAAQ,EAAE,SAAS,EAAC,GAAG,SAAS,EAAE,CAAA;IACzC,MAAM,EAAC,WAAW,EAAE,cAAc,EAAE,MAAM,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CAC5F;IAEN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,IAAG,SAAS,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,gBAAiB,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,gBAAiB,CAAO,CAC1G,CACP,CAAA;AAED,OAAO,EAAC,2BAA2B,EAAC,CAAA","sourcesContent":["import {TextInput} from './TextInput.js'\nimport {InlineToken, TokenItem, TokenizedText} from './TokenizedText.js'\nimport {InfoTable, InfoTableProps} from './Prompts/InfoTable.js'\nimport {handleCtrlC} from '../../ui.js'\nimport useLayout from '../hooks/use-layout.js'\nimport {messageWithPunctuation} from '../utilities.js'\nimport {AbortSignal} from '../../../../public/node/abort.js'\nimport useAbortSignal from '../hooks/use-abort-signal.js'\nimport usePrompt, {PromptState} from '../hooks/use-prompt.js'\nimport React, {FunctionComponent, useCallback, useEffect, useState} from 'react'\nimport {Box, useApp, useInput, Text} from 'ink'\nimport figures from 'figures'\n\nexport interface DangerousConfirmationPromptProps {\n message: string\n confirmation: string\n infoTable?: InfoTableProps['table']\n onSubmit: (value: boolean) => void\n abortSignal?: AbortSignal\n}\n\nconst DangerousConfirmationPrompt: FunctionComponent<DangerousConfirmationPromptProps> = ({\n message,\n confirmation,\n infoTable,\n onSubmit,\n abortSignal,\n}) => {\n const validateAnswer = useCallback(\n (value: string): TokenItem<InlineToken> | undefined => {\n return value === confirmation ? undefined : ['Value must be exactly', {userInput: confirmation}]\n },\n [confirmation],\n )\n\n const {oneThird, twoThirds} = useLayout()\n const {promptState, setPromptState, answer, setAnswer} = usePrompt<string>({\n initialAnswer: '',\n })\n const {exit: unmountInk} = useApp()\n const [error, setError] = useState<TokenItem<InlineToken> | undefined>(undefined)\n const color = promptState === PromptState.Error ? 'red' : 'cyan'\n const underline = new Array(oneThird - 3).fill('▔')\n const {isAborted} = useAbortSignal(abortSignal)\n\n useInput((input, key) => {\n handleCtrlC(input, key)\n\n if (key.escape) {\n setPromptState(PromptState.Cancelled)\n setError(undefined)\n }\n\n if (key.return) {\n const error = validateAnswer(answer)\n\n if (error) {\n setPromptState(PromptState.Error)\n setError(error)\n } else {\n setPromptState(PromptState.Submitted)\n }\n }\n })\n\n useEffect(() => {\n if (promptState === PromptState.Submitted) {\n onSubmit(true)\n unmountInk()\n } else if (promptState === PromptState.Cancelled) {\n onSubmit(false)\n unmountInk()\n }\n }, [onSubmit, promptState, unmountInk])\n\n const completed = promptState === PromptState.Submitted || promptState === PromptState.Cancelled\n\n return isAborted ? null : (\n <Box flexDirection=\"column\" marginBottom={1} width={twoThirds}>\n <Box>\n <Box marginRight={2}>\n <Text>?</Text>\n </Box>\n <TokenizedText item={messageWithPunctuation(message)} />\n </Box>\n {completed ? (\n <CompletedPrompt {...{cancelled: promptState === PromptState.Cancelled}} />\n ) : (\n <>\n <Box flexDirection=\"column\" gap={1} marginTop={1} marginLeft={3}>\n {infoTable ? (\n <Box\n paddingLeft={2}\n borderStyle=\"bold\"\n borderLeft\n borderRight={false}\n borderTop={false}\n borderBottom={false}\n flexDirection=\"column\"\n gap={1}\n >\n <InfoTable table={infoTable} />\n </Box>\n ) : null}\n <Box>\n <TokenizedText item={['Type', {userInput: confirmation}, 'to confirm, or press Escape to cancel.']} />\n </Box>\n </Box>\n <Box flexDirection=\"column\" width={oneThird}>\n <Box>\n <Box marginRight={2}>\n <Text color={color}>{`>`}</Text>\n </Box>\n <Box flexGrow={1}>\n <TextInput\n value={answer}\n onChange={(answer) => {\n setAnswer(answer)\n setPromptState(PromptState.Idle)\n }}\n defaultValue=\"\"\n color={color}\n />\n </Box>\n </Box>\n <Box marginLeft={3}>\n <Text color={color}>{underline}</Text>\n </Box>\n {promptState === PromptState.Error && error ? (\n <Box marginLeft={3}>\n <Text color={color}>\n <TokenizedText item={error} />\n </Text>\n </Box>\n ) : null}\n </Box>\n </>\n )}\n </Box>\n )\n}\n\ninterface CompletedPromptProps {\n cancelled: boolean\n}\n\nconst CompletedPrompt: FunctionComponent<CompletedPromptProps> = ({cancelled}) => (\n <Box>\n <Box marginRight={2}>\n {cancelled ? <Text color=\"red\">{figures.cross}</Text> : <Text color=\"cyan\">{figures.tick}</Text>}\n </Box>\n\n <Box flexGrow={1}>{cancelled ? <Text color=\"red\">Cancelled</Text> : <Text color=\"cyan\">Confirmed</Text>}</Box>\n </Box>\n)\n\nexport {DangerousConfirmationPrompt}\n"]}
|
|
@@ -28,7 +28,7 @@ describe('DangerousConfirmationPrompt', () => {
|
|
|
28
28
|
Type [36myes[39m to confirm, or press Escape to cancel.
|
|
29
29
|
[31m>[39m [31m[41m█[49m[39m
|
|
30
30
|
[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
31
|
-
[31mValue must be exactly [36myes[39m
|
|
31
|
+
[31mValue must be exactly [36myes[39m
|
|
32
32
|
"
|
|
33
33
|
`);
|
|
34
34
|
await sendInputAndWaitForChange(renderInstance, 'A');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DangerousConfirmationPrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/DangerousConfirmationPrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EAAC,wBAAwB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAA;AACvH,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAEjD,MAAM,KAAK,GAAG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AQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;KAOpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,CAAA;QACxB,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,2BAA2B,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAC,eAAe,EAAC,YAAY,EAAC,KAAK,GAAG,CAC/F,CAAA;QACD,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,EAAE,CAAA;QAC9C,MAAM,yBAAyB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QAEpD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAIjF,CAAC,CAAA;QACF,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACjD,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {DangerousConfirmationPrompt} from './DangerousConfirmationPrompt.js'\nimport {getLastFrameAfterUnmount, sendInputAndWaitForChange, waitForInputsToBeReady, render} from '../../testing/ui.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test, vi} from 'vitest'\n\nconst ENTER = '\\r'\nconst ESC = '\\x1b'\n\ndescribe('DangerousConfirmationPrompt', () => {\n test('default state', () => {\n const {lastFrame} = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type yes to confirm, or press Escape to cancel.\n > █\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('default validation error', async () => {\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n // testing with styles because the color changes to red\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[31m>\u001b[39m \u001b[31m\u001b[41m█\u001b[49m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mValue must be exactly \u001b[36myes\u001b[39m\
|
|
1
|
+
{"version":3,"file":"DangerousConfirmationPrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/DangerousConfirmationPrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EAAC,wBAAwB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAA;AACvH,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAEjD,M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,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;KAOpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,QAAQ,GAAG,EAAE,CAAC,EAAE,EAAE,CAAA;QACxB,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,2BAA2B,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAC,eAAe,EAAC,YAAY,EAAC,KAAK,GAAG,CAC/F,CAAA;QACD,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,EAAE,CAAA;QAC9C,MAAM,yBAAyB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QAEpD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAIjF,CAAC,CAAA;QACF,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACjD,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {DangerousConfirmationPrompt} from './DangerousConfirmationPrompt.js'\nimport {getLastFrameAfterUnmount, sendInputAndWaitForChange, waitForInputsToBeReady, render} from '../../testing/ui.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test, vi} from 'vitest'\n\nconst ENTER = '\\r'\nconst ESC = '\\x1b'\n\ndescribe('DangerousConfirmationPrompt', () => {\n test('default state', () => {\n const {lastFrame} = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type yes to confirm, or press Escape to cancel.\n > █\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('default validation error', async () => {\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n // testing with styles because the color changes to red\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[31m>\u001b[39m \u001b[31m\u001b[41m█\u001b[49m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mValue must be exactly \u001b[36myes\u001b[39m\n \"\n `)\n await sendInputAndWaitForChange(renderInstance, 'A')\n // color changes back to valid color\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[36m>\u001b[39m \u001b[36mA\u001b[46m█\u001b[49m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test('submitting the value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={onSubmit} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'yes')\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith(true)\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ Confirmed\n \"\n `)\n })\n\n test('text wrapping', async () => {\n // component width is 80 characters wide in tests but because of the question mark and\n // spaces before the question, we only have 77 characters to work with\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'A'.repeat(77))\n await sendInputAndWaitForChange(renderInstance, 'B'.repeat(6))\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[36m>\u001b[39m \u001b[36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\u001b[39m\n \u001b[36mBBBBBB\u001b[46m█\u001b[49m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test(\"doesn't append a colon to the message if it ends with a question mark\", async () => {\n const {lastFrame} = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question?\" confirmation=\"yes\" />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question?\n\n Type yes to confirm, or press Escape to cancel.\n > █\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('can use Escape key to exit the prompt gracefully', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={onSubmit} message=\"Test question\" confirmation=\"yes\" />,\n )\n await waitForInputsToBeReady()\n const promise = renderInstance.waitUntilExit()\n await sendInputAndWaitForChange(renderInstance, ESC)\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✘ Cancelled\n \"\n `)\n await expect(promise).resolves.toEqual(undefined)\n expect(onSubmit).toHaveBeenCalledWith(false)\n })\n})\n"]}
|
|
@@ -3,9 +3,11 @@ import { render } from '../../../testing/ui.js';
|
|
|
3
3
|
import { unstyled } from '../../../../../public/node/output.js';
|
|
4
4
|
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { platformAndArch } from '@shopify/cli-kit/node/os';
|
|
6
7
|
afterEach(async () => {
|
|
7
8
|
await vi.unstubAllGlobals();
|
|
8
9
|
});
|
|
10
|
+
const runningOnWindows = platformAndArch().platform === 'windows';
|
|
9
11
|
describe('GitDiff', async () => {
|
|
10
12
|
test('renders correctly when no changes exist', async () => {
|
|
11
13
|
const gitDiff = {
|
|
@@ -28,29 +30,30 @@ describe('GitDiff', async () => {
|
|
|
28
30
|
});
|
|
29
31
|
test('renders correctly when changes exist and are several lines long', async () => {
|
|
30
32
|
const gitDiff = {
|
|
31
|
-
baselineContent: 'hello\nworld\n',
|
|
32
|
-
updatedContent: 'world\nhello\n',
|
|
33
|
+
baselineContent: 'hello\nworld\nfoobar\n',
|
|
34
|
+
updatedContent: 'world\nfoobar\nhello\n',
|
|
33
35
|
};
|
|
34
36
|
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
35
37
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
36
38
|
"- hello
|
|
37
39
|
world
|
|
40
|
+
foobar
|
|
38
41
|
+ hello"
|
|
39
42
|
`);
|
|
40
43
|
});
|
|
41
|
-
test('displays color correctly', async () => {
|
|
44
|
+
test.skipIf(runningOnWindows)('displays color correctly', async () => {
|
|
42
45
|
const gitDiff = {
|
|
43
46
|
baselineContent: 'hello\nworld\n',
|
|
44
47
|
updatedContent: 'world\nhello\n',
|
|
45
48
|
};
|
|
46
49
|
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
47
50
|
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
48
|
-
"[31m- hello[m
|
|
51
|
+
"[31m- hello[m[39m
|
|
49
52
|
world[m
|
|
50
|
-
[32m+ [m[32mhello[m"
|
|
53
|
+
[32m+ [m[32mhello[m[0m[39m"
|
|
51
54
|
`);
|
|
52
55
|
});
|
|
53
|
-
test('respects no-color mode', async () => {
|
|
56
|
+
test.skipIf(runningOnWindows)('respects no-color mode', async () => {
|
|
54
57
|
vi.stubGlobal('process', { ...process, env: { ...process.env, FORCE_COLOR: '0' } });
|
|
55
58
|
const gitDiff = {
|
|
56
59
|
baselineContent: 'hello\nworld\n',
|
|
@@ -63,24 +66,26 @@ describe('GitDiff', async () => {
|
|
|
63
66
|
+ hello"
|
|
64
67
|
`);
|
|
65
68
|
});
|
|
66
|
-
test('ignores newline changes', async () => {
|
|
69
|
+
test.skipIf(runningOnWindows)('ignores newline changes', async () => {
|
|
67
70
|
const expectedDiff = `
|
|
68
71
|
"- hello
|
|
69
72
|
world
|
|
73
|
+
foobar
|
|
70
74
|
+ hello"
|
|
71
75
|
`;
|
|
72
76
|
const gitDiff = {
|
|
73
|
-
baselineContent: 'hello\nworld\n',
|
|
74
|
-
updatedContent: 'world\nhello',
|
|
77
|
+
baselineContent: 'hello\nworld\nfoobar\n',
|
|
78
|
+
updatedContent: 'world\nfoobar\nhello',
|
|
75
79
|
};
|
|
76
80
|
// Removing a newline
|
|
77
81
|
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
78
82
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(expectedDiff);
|
|
79
83
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(expectedDiff);
|
|
80
84
|
});
|
|
81
|
-
test('renders correctly when changes exist in multiple areas of a file', async () => {
|
|
85
|
+
test.skipIf(runningOnWindows)('renders correctly when changes exist in multiple areas of a file', async () => {
|
|
82
86
|
const baselineContent = `hello
|
|
83
87
|
world
|
|
88
|
+
foobar
|
|
84
89
|
lorem
|
|
85
90
|
ipsum
|
|
86
91
|
dolor
|
|
@@ -90,6 +95,7 @@ foo
|
|
|
90
95
|
bar
|
|
91
96
|
`;
|
|
92
97
|
const updatedContent = `world
|
|
98
|
+
foobar
|
|
93
99
|
hello
|
|
94
100
|
lorem
|
|
95
101
|
ipsum
|
|
@@ -106,10 +112,11 @@ qux`;
|
|
|
106
112
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
107
113
|
"- hello
|
|
108
114
|
world
|
|
115
|
+
foobar
|
|
109
116
|
+ hello
|
|
110
117
|
lorem
|
|
111
118
|
|
|
112
|
-
@@ -
|
|
119
|
+
@@ -9,2 +9,2 @@ amet
|
|
113
120
|
foo
|
|
114
121
|
- bar
|
|
115
122
|
+ qux"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitDiff.test.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/GitDiff.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CA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C,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;KAWpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {GitDiff} from './GitDiff.js'\nimport {render} from '../../../testing/ui.js'\nimport {unstyled} from '../../../../../public/node/output.js'\nimport {afterEach, describe, expect, test, vi} from 'vitest'\nimport React from 'react'\nimport {platformAndArch} from '@shopify/cli-kit/node/os'\n\nafterEach(async () => {\n await vi.unstubAllGlobals()\n})\n\nconst runningOnWindows = platformAndArch().platform === 'windows'\n\ndescribe('GitDiff', async () => {\n test('renders correctly when no changes exist', async () => {\n const gitDiff = {\n baselineContent: 'hello',\n updatedContent: 'hello',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()).toEqual('No changes.')\n })\n\n test('renders correctly when changes exist', async () => {\n const gitDiff = {\n baselineContent: 'hello\\n',\n updatedContent: 'world\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n + world\"\n `)\n })\n\n test('renders correctly when changes exist and are several lines long', async () => {\n const gitDiff = {\n baselineContent: 'hello\\nworld\\nfoobar\\n',\n updatedContent: 'world\\nfoobar\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n world\n foobar\n + hello\"\n `)\n })\n\n test.skipIf(runningOnWindows)('displays color correctly', async () => {\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m- hello\u001b[m\u001b[39m\n world\u001b[m\n \u001b[32m+ \u001b[m\u001b[32mhello\u001b[m\u001b[0m\u001b[39m\"\n `)\n })\n\n test.skipIf(runningOnWindows)('respects no-color mode', async () => {\n vi.stubGlobal('process', {...process, env: {...process.env, FORCE_COLOR: '0'}})\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()!).toMatchInlineSnapshot(`\n \"- hello\n world\n + hello\"\n `)\n })\n\n test.skipIf(runningOnWindows)('ignores newline changes', async () => {\n const expectedDiff = `\n \"- hello\n world\n foobar\n + hello\"\n `\n\n const gitDiff = {\n baselineContent: 'hello\\nworld\\nfoobar\\n',\n updatedContent: 'world\\nfoobar\\nhello',\n }\n\n // Removing a newline\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(expectedDiff)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(expectedDiff)\n })\n\n test.skipIf(runningOnWindows)('renders correctly when changes exist in multiple areas of a file', async () => {\n const baselineContent = `hello\nworld\nfoobar\nlorem\nipsum\ndolor\nsit\namet\nfoo\nbar\n`\n const updatedContent = `world\nfoobar\nhello\nlorem\nipsum\ndolor\nsit\namet\nfoo\nqux`\n\n const gitDiff = {\n baselineContent,\n updatedContent,\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n world\n foobar\n + hello\n lorem\n\n @@ -9,2 +9,2 @@ amet\n foo\n - bar\n + qux\"\n `)\n })\n})\n"]}
|