-
Notifications
You must be signed in to change notification settings - Fork 255
[Refactor] Fix incorrect Promise.all usage in app preDeployValidation #7540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -851,3 +851,21 @@ function createPackageJson(tmpDir: string, type: string, version: string) { | |||||
| const dirPath = joinPath(tmpDir, 'node_modules', '@shopify', type) | ||||||
| return mkdir(dirPath).then(() => writeFile(packagePath, JSON.stringify(packageJson))) | ||||||
| } | ||||||
|
|
||||||
| describe('preDeployValidation awaiting', () => { | ||||||
| test('awaits extension validation and catches rejections', async () => { | ||||||
| // Given | ||||||
| const extension = await testUIExtension() | ||||||
| vi.spyOn(extension, 'preDeployValidation').mockImplementation(async () => { | ||||||
| await new Promise((resolve) => setTimeout(resolve, 10)) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Suggestion: The test uses Suggestion: The mock can be simplified to remove the artificial delay:
Suggested change
|
||||||
| throw new Error('Validation failed') | ||||||
| }) | ||||||
|
|
||||||
| const app = testApp({ | ||||||
| allExtensions: [extension], | ||||||
| }) | ||||||
|
|
||||||
| // When / Then | ||||||
| await expect(app.preDeployValidation()).rejects.toThrow('Validation failed') | ||||||
| }) | ||||||
| }) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 Suggestion: The regression test proves a rejection is caught for one extension, but the original bug specifically affected
Promise.allwith multiple promises. With a single extension, the behavioral difference betweenPromise.all([promise])andPromise.all([[promise]])is less discriminating. A test with two or more extensions — where one succeeds and one rejects — would more directly demonstrate the fix works for the N > 1 case and guard against future regressions.Suggestion: Consider adding a second test case with multiple extensions (e.g., one that resolves and one that rejects) to verify
Promise.allcorrectly awaits all of them. This more directly exercises the array-wrapping bug that was fixed.