From f05541195dfda9d8ddbaef00b944053a8c057f2c Mon Sep 17 00:00:00 2001 From: gonzaloriestra <14979109+gonzaloriestra@users.noreply.github.com> Date: Wed, 8 Jul 2026 00:48:57 +0000 Subject: [PATCH 1/2] [Tests] Add unit tests for app bulk cancel command Implemented command-level unit tests for the BulkCancel command in packages/app/src/cli/commands/app/bulk/cancel.test.ts. These tests verify that the command correctly parses flags, prepares the app and store context, and calls the cancelBulkOperation service with the expected arguments, including ID normalization. --- .../src/cli/commands/app/bulk/cancel.test.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 packages/app/src/cli/commands/app/bulk/cancel.test.ts diff --git a/packages/app/src/cli/commands/app/bulk/cancel.test.ts b/packages/app/src/cli/commands/app/bulk/cancel.test.ts new file mode 100644 index 00000000000..b26ac8c8c19 --- /dev/null +++ b/packages/app/src/cli/commands/app/bulk/cancel.test.ts @@ -0,0 +1,69 @@ +import BulkCancel from './cancel.js' +import {cancelBulkOperation} from '../../../services/bulk-operations/cancel-bulk-operation.js' +import {prepareAppStoreContext} from '../../../utilities/execute-command-helpers.js' +import { + testAppLinked, + testOrganization, + testOrganizationApp, + testOrganizationStore, + testProject, +} from '../../../models/app/app.test-data.js' +import {describe, expect, test, vi, beforeEach} from 'vitest' + +vi.mock('../../../services/bulk-operations/cancel-bulk-operation.js') +vi.mock('../../../utilities/execute-command-helpers.js') + +describe('app bulk cancel command', () => { + const app = testAppLinked() + const remoteApp = testOrganizationApp() + const store = testOrganizationStore({shopDomain: 'shop.myshopify.com'}) + + beforeEach(() => { + vi.clearAllMocks() + vi.mocked(prepareAppStoreContext).mockResolvedValue({ + appContextResult: { + app, + remoteApp, + developerPlatformClient: remoteApp.developerPlatformClient, + organization: testOrganization(), + specifications: [], + project: testProject(), + activeConfig: {} as never, + }, + store, + }) + vi.mocked(cancelBulkOperation).mockResolvedValue() + }) + + test('prepares app/store context and cancels bulk operation', async () => { + // When + await BulkCancel.run(['--path', '/tmp/app', '--id', '12345', '--store', 'shop']) + + // Then + expect(prepareAppStoreContext).toHaveBeenCalledWith( + expect.objectContaining({ + path: '/tmp/app', + id: '12345', + store: 'shop.myshopify.com', + }), + ) + expect(cancelBulkOperation).toHaveBeenCalledWith({ + organization: expect.any(Object), + storeFqdn: 'shop.myshopify.com', + operationId: 'gid://shopify/BulkOperation/12345', + remoteApp, + }) + }) + + test('passes full GID operation ID correctly', async () => { + // When + await BulkCancel.run(['--id', 'gid://shopify/BulkOperation/67890', '--store', 'shop']) + + // Then + expect(cancelBulkOperation).toHaveBeenCalledWith( + expect.objectContaining({ + operationId: 'gid://shopify/BulkOperation/67890', + }), + ) + }) +}) From 532998408a16e2429be9867cb928970d5465addf Mon Sep 17 00:00:00 2001 From: gonzaloriestra <14979109+gonzaloriestra@users.noreply.github.com> Date: Wed, 8 Jul 2026 01:18:48 +0000 Subject: [PATCH 2/2] [Tests] Add unit tests for app bulk cancel command Implemented command-level unit tests for the BulkCancel command in packages/app/src/cli/commands/app/bulk/cancel.test.ts. These tests verify that the command correctly parses flags, prepares the app and store context, and calls the cancelBulkOperation service with the expected arguments, including ID normalization. --- packages/app/src/cli/commands/app/bulk/cancel.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/app/src/cli/commands/app/bulk/cancel.test.ts b/packages/app/src/cli/commands/app/bulk/cancel.test.ts index b26ac8c8c19..cecdfc3ca40 100644 --- a/packages/app/src/cli/commands/app/bulk/cancel.test.ts +++ b/packages/app/src/cli/commands/app/bulk/cancel.test.ts @@ -19,7 +19,6 @@ describe('app bulk cancel command', () => { const store = testOrganizationStore({shopDomain: 'shop.myshopify.com'}) beforeEach(() => { - vi.clearAllMocks() vi.mocked(prepareAppStoreContext).mockResolvedValue({ appContextResult: { app,