|
3 | 3 | createAsNewAppPrompt, |
4 | 4 | reloadStoreListPrompt, |
5 | 5 | selectAppPrompt, |
6 | | - selectOrganizationPrompt, |
7 | 6 | selectStorePrompt, |
8 | 7 | updateURLsPrompt, |
9 | 8 | } from './dev.js' |
@@ -68,85 +67,6 @@ beforeEach(() => { |
68 | 67 | vi.mocked(getTomls).mockResolvedValue({}) |
69 | 68 | }) |
70 | 69 |
|
71 | | -describe('selectOrganization', () => { |
72 | | - test('request org selection if passing more than 1 org', async () => { |
73 | | - // Given |
74 | | - vi.mocked(renderAutocompletePrompt).mockResolvedValue('1') |
75 | | - |
76 | | - // When |
77 | | - const got = await selectOrganizationPrompt([ORG1, ORG2]) |
78 | | - |
79 | | - // Then |
80 | | - expect(got).toEqual(ORG1) |
81 | | - expect(renderAutocompletePrompt).toHaveBeenCalledWith({ |
82 | | - message: 'Which organization is this work for?', |
83 | | - choices: [ |
84 | | - {label: 'org1', value: '1'}, |
85 | | - {label: 'org2', value: '2'}, |
86 | | - ], |
87 | | - }) |
88 | | - }) |
89 | | - |
90 | | - test('returns directly if passing only 1 org', async () => { |
91 | | - // Given |
92 | | - const orgs = [ORG2] |
93 | | - |
94 | | - // When |
95 | | - const got = await selectOrganizationPrompt(orgs) |
96 | | - |
97 | | - // Then |
98 | | - expect(got).toEqual(ORG2) |
99 | | - expect(renderAutocompletePrompt).not.toBeCalled() |
100 | | - }) |
101 | | - |
102 | | - // Intentional: when ANY duplicates exist, ALL orgs get ID suffix for consistent formatting |
103 | | - test('appends ID to label when duplicate names exist', async () => { |
104 | | - // Given |
105 | | - const orgsWithDuplicates = [ |
106 | | - {id: '1', businessName: 'My Org', source: OrganizationSource.BusinessPlatform}, |
107 | | - {id: '2', businessName: 'My Org', source: OrganizationSource.BusinessPlatform}, |
108 | | - {id: '3', businessName: 'Other Org', source: OrganizationSource.BusinessPlatform}, |
109 | | - ] |
110 | | - vi.mocked(renderAutocompletePrompt).mockResolvedValue('1') |
111 | | - |
112 | | - // When |
113 | | - await selectOrganizationPrompt(orgsWithDuplicates) |
114 | | - |
115 | | - // Then - note: Other Org also gets ID suffix for consistency |
116 | | - expect(renderAutocompletePrompt).toHaveBeenCalledWith({ |
117 | | - message: 'Which organization is this work for?', |
118 | | - choices: [ |
119 | | - {label: 'My Org (1)', value: '1'}, |
120 | | - {label: 'My Org (2)', value: '2'}, |
121 | | - {label: 'Other Org (3)', value: '3'}, |
122 | | - ], |
123 | | - }) |
124 | | - }) |
125 | | - |
126 | | - test('appends ID to all labels when all names are identical', async () => { |
127 | | - // Given |
128 | | - const orgsAllSameName = [ |
129 | | - {id: '1', businessName: 'Same Org', source: OrganizationSource.BusinessPlatform}, |
130 | | - {id: '2', businessName: 'Same Org', source: OrganizationSource.BusinessPlatform}, |
131 | | - {id: '3', businessName: 'Same Org', source: OrganizationSource.BusinessPlatform}, |
132 | | - ] |
133 | | - vi.mocked(renderAutocompletePrompt).mockResolvedValue('2') |
134 | | - |
135 | | - // When |
136 | | - await selectOrganizationPrompt(orgsAllSameName) |
137 | | - |
138 | | - // Then |
139 | | - expect(renderAutocompletePrompt).toHaveBeenCalledWith({ |
140 | | - message: 'Which organization is this work for?', |
141 | | - choices: [ |
142 | | - {label: 'Same Org (1)', value: '1'}, |
143 | | - {label: 'Same Org (2)', value: '2'}, |
144 | | - {label: 'Same Org (3)', value: '3'}, |
145 | | - ], |
146 | | - }) |
147 | | - }) |
148 | | -}) |
149 | | - |
150 | 70 | describe('selectApp', () => { |
151 | 71 | test('returns app if user selects one', async () => { |
152 | 72 | // Given |
|
0 commit comments