Skip to content

feat(DX-3233): Bulk publish/unpublish query params, api_version tests, and robust error handling#136

Open
OMpawar-21 wants to merge 5 commits intodevelopmentfrom
enhc/DX-3233
Open

feat(DX-3233): Bulk publish/unpublish query params, api_version tests, and robust error handling#136
OMpawar-21 wants to merge 5 commits intodevelopmentfrom
enhc/DX-3233

Conversation

@OMpawar-21
Copy link

@OMpawar-21 OMpawar-21 commented Mar 2, 2026

Title

feat(DX-3233): Bulk publish/unpublish query params, api_version tests, and robust error handling


Summary

  • DX-3233: Send skip_workflow_stage_check and approvals as query parameters (not headers) for bulk publish/unpublish.
  • Integration tests: Add bulk tests with flags (3a/4a), with api_version 3.2 (3b/4b), a helper for test data, and stronger assertions and error handling (3a, 4a, 3b, 4b, 4c).
  • Release: Version bump and CHANGELOG entry.

1. Bulk publish/unpublish: headers → query params (DX-3233)

BulkPublishService.cs

  • skip_workflow_stage_check and approvals are no longer set as headers.
  • They are set as query parameters via AddQueryResource("skip_workflow_stage_check", "true") and AddQueryResource("approvals", "true").
  • BulkUnpublishService already used query params; no change.

Unit tests

  • BulkPublishServiceTest.cs: Assertions for these two flags use QueryResources instead of Headers; test names updated to "Query Parameter".
  • BulkUnpublishServiceTest.cs: Same (Headers → QueryResources).
  • BulkOperationServicesTest.cs: All checks for these flags (Test004, Test006, Test007, Test008) use QueryResources instead of Headers.

2. Integration tests – bulk operations (Contentstack015_BulkOperationTest.cs)

New/updated tests

  • Test003a: Bulk publish with skipWorkflowStage: true and approvals: true.
  • Test004a: Bulk unpublish with skipWorkflowStage: true and approvals: true.
  • Test003b: Bulk publish with same flags and api_version 3.2 (header).
  • Test004b: Bulk unpublish with same flags and api_version 3.2 (header).
  • Test004c: Negative test – bulk unpublish with invalid data (empty entries, non-existent env); expects ContentstackErrorException and asserts non-success status and error message.

Helper

  • EnsureBulkTestContentTypeAndEntriesAsync(): Ensures bulk_test_content_type and at least one entry exist so bulk tests can run in any order.

Assertions and error handling

  • FailWithError(operation, ex): Centralized failure reporting; for ContentstackErrorException includes HTTP status, ErrorCode, and API message.
  • Test003a, Test004a, Test003b, Test004b: Explicit Assert.AreEqual(HttpStatusCode.OK, response.StatusCode) and descriptive IsSuccessStatusCode messages; catch blocks use FailWithError.
  • Usings: System.Net, Contentstack.Management.Core.Exceptions.

3. Release

  • Directory.Build.props: Version bumped (e.g. 0.6.1 → 0.7.0).
  • CHANGELOG.md: New version entry for bulk query params, integration tests, and error-handling improvements.

Testing

  • Unit tests: BulkPublishServiceTest, BulkUnpublishServiceTest, BulkOperationServicesTest (bulk-related) pass.
  • Integration tests: Test003a, Test004a, Test003b, Test004b, Test004c pass against a stack with required setup.

Checklist

  • Code follows project conventions.
  • Unit tests updated for query-param behavior.
  • Integration tests cover bulk with flags, api_version 3.2, and invalid data.
  • CHANGELOG and version updated.

…BulkUnpublishService.cs.

Description
In BulkUnpublishService.cs, two comment-only lines were added to document an alternative way of sending the bulk unpublish options:
skip_workflow_stage_check – A commented call AddQueryResource("skip_workflow_stage_check", "true") was added next to the existing Headers["skip_workflow_stage_check"] = "true" assignment.
approvals – A commented call AddQueryResource("approvals", "true") was added next to the existing Headers["approvals"] = "true" assignment.
…add integration tests

- Bulk publish/unpublish: send skip_workflow_stage_check and approvals as query
  params via AddQueryResource instead of headers (BulkPublishService; BulkUnpublishService
  already used query params).
- Unit tests: in BulkPublishServiceTest, BulkUnpublishServiceTest, and
  BulkOperationServicesTest, assert on QueryResources instead of Headers for
  these two flags.
- Integration tests: add EnsureBulkTestContentTypeAndEntriesAsync() so
  bulk_test_content_type and at least one entry exist; add Test003a (bulk
  publish with skipWorkflowStage and approvals) and Test004a (bulk unpublish
  with same flags).
@OMpawar-21 OMpawar-21 requested a review from a team as a code owner March 2, 2026 06:15
…ndling

Integration tests (Contentstack015_BulkOperationTest):

- API version 3.2:
  - Test003b: bulk publish with skipWorkflowStage, approvals, and apiVersion "3.2" (api_version header).
  - Test004b: bulk unpublish with skipWorkflowStage, approvals, and apiVersion "3.2" (api_version header).

- Error handling and assertions:

  - Add FailWithError(operation, ex) to report HTTP status, ErrorCode, and API message on ContentstackErrorException.

  - In Test003a, Test004a, Test003b, Test004b: assert response.StatusCode == HttpStatusCode.OK and use FailWithError in catch.

  - Add Test004c: negative test for bulk unpublish with invalid data (empty entries, non-existent env); expect ContentstackErrorException and assert non-success status and presence of error message.

- Usings: System.Net (HttpStatusCode), Contentstack.Management.Core.Exceptions (ContentstackErrorException).
@OMpawar-21 OMpawar-21 changed the title Enhc/dx 3233 : Bulk publish/unpublish – send skip_workflow_stage_check and approvals as query params feat(DX-3233): Bulk publish/unpublish query params, api_version tests, and robust error handling Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant