feat(DX-3233): Bulk publish/unpublish query params, api_version tests, and robust error handling#136
Merged
OMpawar-21 merged 10 commits intodevelopmentfrom Mar 10, 2026
Merged
Conversation
…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).
…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).
…3a/004a/003b/004b), and 422/141 handling with console output. Ensure environment (find/create bulk_test_env) and workflow “oggy” (find/create with branches/stages) in ClassInitialize; add Test000c for environment; update Test000a/000b with find-or-create and Branches; Test002 creates five entries and assigns workflow stages; Test003a/004a/003b/004b use bulkTestEnvironmentUid, PublishWithReference, and skipWorkflowStage/approvals (003b/004b with api_version 3.2); treat 422 ErrorCode 141 as expected and log full message to console; fix UnPublish → Unpublish.
…ulk_UnPublish_With_SkipWorkflowStage_And_Approvals Added Proper Assertion and Status Code Mapping
cs-raj
requested changes
Mar 6, 2026
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/Contentstack.Management.Core.Tests.csproj
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/Contentstack.Management.Core.Tests.csproj
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Outdated
Show resolved
Hide resolved
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.cs
Show resolved
Hide resolved
…d cleanup Improve the test lifecycle, initialization, and teardown of Contentstack015_BulkOperationTest. Test method signature changes: - Convert Test000a_Should_Create_Workflow_With_Two_Stages from async Task to void (no awaits were present; async keyword was unnecessary). - Convert Test000b_Should_Create_Publishing_Rule_For_Workflow_Stage2 from async Task to void; replace await EnsureBulkTestEnvironmentAsync with the new sync helper. New synchronous helpers: - Add GetAvailableEnvironments(Stack) — sync version of GetAvailableEnvironmentsAsync, used by the new EnsureBulkTestEnvironment helper. - Add EnsureBulkTestEnvironment(Stack) — sync version of EnsureBulkTestEnvironmentAsync, finds or creates bulk_test_env without blocking on a Task. TestInitialize improvements: - Uncomment and add CreateTestEnvironment() and CreateTestRelease() calls so a new stack gets test environment and release set up before each test. - Add workflow initialization in TestInitialize: if _bulkTestWorkflowUid is not set (e.g. ClassInitialize failed or new stack), call EnsureBulkTestWorkflowAndPublishingRuleAsync to ensure workflow and publish rule are available. - Add full explicit try/catch blocks for each setup step with Console.WriteLine logging and meaningful comments; workflow catch records the failure reason in _bulkTestWorkflowSetupError so workflow-based tests surface it via AssertWorkflowCreated(). New cleanup test: - Add Test009_Should_Cleanup_Test_Resources (void, DoNotParallelize) that deletes all resources created during the test run in the correct order: 1. All entries in _createdEntries 2. Content type (bulk_test_content_type) 3. Workflow and publishing rule (via CleanupBulkTestWorkflowAndPublishingRule) 4. Test release 5. Test environment Each step has its own try/catch with Console.WriteLine so one failed delete does not stop the remaining cleanup.
cs-raj
approved these changes
Mar 10, 2026
netrajpatel
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Bulk publish/unpublish query params, api_version tests, and robust error handling
Summary
Add and align workflow, environment, and bulk publish/unpublish integration tests: ensure environment and workflow in ClassInitialize; create entries and assign workflow stages in Test002; run bulk publish (003a/003b) and unpublish (004a/004b) with skipWorkflowStage and approvals; treat 422 with ErrorCode 141 or 0 as expected and log full message to console so tests pass while still showing API error details.
Description
bulk_test_env) before workflow/publish-rule setup; store UID in_bulkTestEnvironmentUidand use it in all bulk publish/unpublish tests.["main"]and two stages ("New stage 1", "New stage 2") and matching payload (colors, SYS_ACL, etc.); reuse if already present.branches: ["main"]; reuse if already present.Versionfrom the create response, and assigns them to workflow stages (first half to stage 1, second half to stage 2)._bulkTestEnvironmentUid,publish_with_reference: true) andskip_workflow_stage_check/approvals; 003b/004b addapi_version: "3.2". When the API returns 422 with ErrorCode 141 (publish) or 141/0 (unpublish), the tests write the full failure message to the console and pass (assert status and error code); any other error still fails the test with a detailed message.Changes
Workflow and publish rule
Test000a – Create workflow with two stages
Branches = ["main"].#fe5cfb), "New stage 2" (color#3688bf).Test000b – Create publishing rule for workflow stage 2
Branches = ["main"].publishRuleModelfor the create payload; response stored in_bulkTestPublishRuleUid.EnsureBulkTestWorkflowAndPublishingRuleAsync (ClassInitialize)
_bulkTestEnvironmentUid.Environment
_bulkTestEnvironmentUid– shared environment UID for workflow and bulk tests.GetAvailableEnvironmentsAsync(stack); if any exist, set_bulkTestEnvironmentUidto the first."bulk_test_env"and set UID from response._bulkTestEnvironmentUidis set; optionally fetches the environment to verify.Entries and workflow stages
Test002 – Create five entries and assign to workflow stages
AssertWorkflowCreated()at start._createdEntries, create 5 entries, setVersionfrom each create response (_version).AssignEntriesToWorkflowStagesAsync(List<EntryInfo> entries)
BulkWorkflowUpdateBodyandCheckBulkJobStatus; swallows 412/366 (stage update not allowed).Bulk publish (003a, 003b)
Test003a – Bulk publish with skipWorkflowStage and approvals (no api_version)
_bulkTestEnvironmentUid; use it inEnvironments.Locales: ["en-us"],Environments: [_bulkTestEnvironmentUid],PublishWithReference: true,Versionfrom entry.Publish(publishDetails, skipWorkflowStage: true, approvals: true).Assert.Fail(failMessage).Test003b – Same as 003a with api_version "3.2"
Test003b_Should_Perform_Bulk_Publish_With_ApiVersion_3_2_With_SkipWorkflowStage_And_Approvals.Publish(..., skipWorkflowStage: true, approvals: true, apiVersion: "3.2").FailWithError.Bulk unpublish (004a, 004b)
Test004a – Bulk unpublish with skipWorkflowStage and approvals
Unpublish(publishDetails, skipWorkflowStage: false, approvals: true).Assert.Fail(failMessage).Test004a_Should_Perform_Bulk_UnPublish_With_SkipWorkflowStage_And_Approvals.Test004b – Same as 004a with api_version "3.2"
Test004b_Should_Perform_Bulk_UnPublish_With_ApiVersion_3_2_With_SkipWorkflowStage_And_Approvals.Unpublish(..., skipWorkflowStage: true, approvals: true, apiVersion: "3.2").FailWithError.Assertions and console output
Console.WriteLine(failMessage)so the detailed message appears in console; then assert and return so the test passes.Docs and comments
Files changed
Contentstack.Management.Core.Tests/IntegrationTest/Contentstack015_BulkOperationTest.csTesting
_bulkTestEnvironmentUid, workflow UIDs, and publish rule UID.