|
1 | 1 | import { |
2 | 2 | AppSchema, |
3 | 3 | CurrentAppConfiguration, |
4 | | - LegacyAppConfiguration, |
5 | 4 | getAppScopes, |
6 | 5 | getAppScopesArray, |
7 | 6 | getUIExtensionRendererVersion, |
8 | | - isCurrentAppSchema, |
9 | | - isLegacyAppSchema, |
10 | 7 | validateExtensionsHandlesInCollection, |
11 | 8 | validateFunctionExtensionsWithUiHandle, |
12 | 9 | } from './app.js' |
@@ -61,43 +58,8 @@ const CORRECT_CURRENT_APP_SCHEMA: CurrentAppConfiguration = { |
61 | 58 | }, |
62 | 59 | } |
63 | 60 |
|
64 | | -const CORRECT_LEGACY_APP_SCHEMA: LegacyAppConfiguration = { |
65 | | - path: '', |
66 | | - extension_directories: [], |
67 | | - web_directories: [], |
68 | | - scopes: 'write_products', |
69 | | -} |
70 | | - |
71 | 61 | describe('app schema validation', () => { |
72 | | - describe('legacy schema validator', () => { |
73 | | - test('checks whether legacy app schema is valid -- pass', () => { |
74 | | - expect(isLegacyAppSchema(CORRECT_LEGACY_APP_SCHEMA)).toBe(true) |
75 | | - }) |
76 | | - test('checks whether legacy app schema is valid -- fail', () => { |
77 | | - const config = { |
78 | | - ...CORRECT_LEGACY_APP_SCHEMA, |
79 | | - some_other_key: 'i am not valid, i will fail', |
80 | | - } |
81 | | - expect(isLegacyAppSchema(config)).toBe(false) |
82 | | - }) |
83 | | - }) |
84 | | - |
85 | 62 | describe('current schema validator', () => { |
86 | | - test('checks whether current app schema is valid -- pass', () => { |
87 | | - expect(isCurrentAppSchema(CORRECT_CURRENT_APP_SCHEMA)).toBe(true) |
88 | | - }) |
89 | | - test('checks whether current app schema is valid -- fail', () => { |
90 | | - const config = { |
91 | | - ...CORRECT_CURRENT_APP_SCHEMA, |
92 | | - } |
93 | | - |
94 | | - // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
95 | | - // @ts-ignore |
96 | | - delete config.client_id |
97 | | - |
98 | | - expect(isCurrentAppSchema(config)).toBe(false) |
99 | | - }) |
100 | | - |
101 | 63 | test('extension_directories should be transformed to double asterisks', () => { |
102 | 64 | const config = { |
103 | 65 | ...CORRECT_CURRENT_APP_SCHEMA, |
@@ -210,24 +172,14 @@ describe('getUIExtensionRendererVersion', () => { |
210 | 172 | }) |
211 | 173 |
|
212 | 174 | describe('getAppScopes', () => { |
213 | | - test('returns the scopes key when schema is legacy', () => { |
214 | | - const config = {path: '', scopes: 'read_themes,read_products'} |
215 | | - expect(getAppScopes(config)).toEqual('read_themes,read_products') |
216 | | - }) |
217 | | - |
218 | | - test('returns the access_scopes.scopes key when schema is current', () => { |
| 175 | + test('returns the access_scopes.scopes key', () => { |
219 | 176 | const config = {...DEFAULT_CONFIG, access_scopes: {scopes: 'read_themes,read_themes'}} |
220 | 177 | expect(getAppScopes(config)).toEqual('read_themes,read_themes') |
221 | 178 | }) |
222 | 179 | }) |
223 | 180 |
|
224 | 181 | describe('getAppScopesArray', () => { |
225 | | - test('returns the scopes key when schema is legacy', () => { |
226 | | - const config = {path: '', scopes: 'read_themes, read_order ,write_products'} |
227 | | - expect(getAppScopesArray(config)).toEqual(['read_themes', 'read_order', 'write_products']) |
228 | | - }) |
229 | | - |
230 | | - test('returns the access_scopes.scopes key when schema is current', () => { |
| 182 | + test('returns the access_scopes.scopes key', () => { |
231 | 183 | const config = {...DEFAULT_CONFIG, access_scopes: {scopes: 'read_themes, read_order ,write_products'}} |
232 | 184 | expect(getAppScopesArray(config)).toEqual(['read_themes', 'read_order', 'write_products']) |
233 | 185 | }) |
@@ -328,18 +280,6 @@ Learn more: https://shopify.dev/docs/apps/build/authentication-authorization/app |
328 | 280 | await expect(app.preDeployValidation()).resolves.not.toThrow() |
329 | 281 | }) |
330 | 282 |
|
331 | | - test('does not throw an error for legacy schema apps', async () => { |
332 | | - // Given |
333 | | - const configuration: LegacyAppConfiguration = { |
334 | | - ...CORRECT_LEGACY_APP_SCHEMA, |
335 | | - scopes: 'read_orders', |
336 | | - } |
337 | | - const app = testApp(configuration, 'legacy') |
338 | | - |
339 | | - // When/Then |
340 | | - await expect(app.preDeployValidation()).resolves.not.toThrow() |
341 | | - }) |
342 | | - |
343 | 283 | test('handles null/undefined subscriptions safely', async () => { |
344 | 284 | // Given |
345 | 285 | const configuration: CurrentAppConfiguration = { |
|
0 commit comments