Skip to content

Commit

Permalink
Merge pull request #4691 from Shopify/jm/improve-remote-deletion-erro…
Browse files Browse the repository at this point in the history
…r-api-alt

Prevent rendering remote file deletion error when file has already been removed
  • Loading branch information
karreiro authored Oct 21, 2024
2 parents d21729b + 8c6906c commit 99763ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-ladybugs-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/theme': patch
---

Fix an issue with `shopify theme dev --theme-editor-sync` to prevent showing a remote file deletion error when the file has already been removed
4 changes: 2 additions & 2 deletions packages/cli-kit/src/public/node/themes/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('deleteThemeAsset', () => {
expect(output).toBe(true)
})

test('returns empty object when attemping to delete an nonexistent asset', async () => {
test('returns true when attemping to delete an nonexistent asset', async () => {
// Given
const id = 123
const key = 'snippets/product-variant-picker.liquid'
Expand All @@ -277,7 +277,7 @@ describe('deleteThemeAsset', () => {

// Then
expect(restRequest).toHaveBeenCalledWith('DELETE', `/themes/${id}/assets`, session, undefined, {'asset[key]': key})
expect(output).toBe(false)
expect(output).toBe(true)
})
})

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-kit/src/public/node/themes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function deleteThemeAsset(id: number, key: Key, session: AdminSessi
const response = await request('DELETE', `/themes/${id}/assets`, session, undefined, {
'asset[key]': key,
})
return Boolean(response.json.message)
return response.status === 200
}

export async function bulkUploadThemeAssets(
Expand Down

0 comments on commit 99763ce

Please sign in to comment.