-
Notifications
You must be signed in to change notification settings - Fork 99
feat: [TOL-2513][SPA-2443] Bulk actions v2 support #2528
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
Open
colomolo
wants to merge
17
commits into
master
Choose a base branch
from
locale-based-bulk-actions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d2fe023
feat: add bulk actions v2 support
colomolo 01b28d0
chore: update payload types
colomolo 1f73956
fix: add separate methods for v2 bulk actions
colomolo 7368df8
Merge branch 'master' into locale-based-bulk-actions
colomolo f710030
fix: linting issues
colomolo 79237e0
Merge branch 'locale-based-bulk-actions' of github.com:contentful/con…
colomolo 2ea259f
test: add new methods tests
colomolo c35460a
test: adjust tests
colomolo 60b4409
chore: add v2 wait method
colomolo 5e667d1
chore: fix lint errors
colomolo 59bf69f
chore: export types
colomolo 0e3639b
chore: fix linter errors
colomolo 560c415
test: tweak unpublish test
colomolo f6b9fa7
chore: fix prettier error
colomolo 0defd8b
Merge branch 'master' into locale-based-bulk-actions
colomolo d37aacf
Merge branch 'master' into locale-based-bulk-actions
SofiaMargariti f32729a
fix: linting
SofiaMargariti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,14 +5,22 @@ import type { | |
| BulkActionPublishPayload, | ||
| BulkActionUnpublishPayload, | ||
| BulkActionValidatePayload, | ||
| UnpublishBulkActionV2Payload, | ||
| } from '../../lib/contentful-management' | ||
| import type { Environment, Space } from '../../lib/contentful-management' | ||
| import { waitForBulkActionProcessing } from '../../lib/methods/bulk-action' | ||
| import { | ||
| waitForBulkActionProcessing, | ||
| waitForBulkActionV2Processing, | ||
| } from '../../lib/methods/bulk-action' | ||
| import { TestDefaults } from '../defaults' | ||
| import { getDefaultSpace, initPlainClient, timeoutToCalmRateLimiting } from '../helpers' | ||
| import { makeLink, makeVersionedLink } from '../utils' | ||
| import { | ||
| PublishBulkActionV2Payload, | ||
| ValidateBulkActionV2Payload, | ||
| } from '../../lib/entities/bulk-action' | ||
|
|
||
| describe('BulkActions Api', () => { | ||
| describe('BulkActions Api v1', () => { | ||
| let testSpace: Space | ||
| let testEnvironment: Environment | ||
|
|
||
|
|
@@ -257,3 +265,83 @@ describe('BulkActions Api', () => { | |
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('BulkActions Api v2 (Plain Client only)', () => { | ||
|
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. Is there a reason to only support bulk actions V2 in the plain client and not the legacy? I can see that V1 is supported in both. |
||
| afterAll(timeoutToCalmRateLimiting) | ||
|
|
||
| const defaultParams = { | ||
| environmentId: TestDefaults.environmentId, | ||
| spaceId: TestDefaults.spaceId, | ||
| } | ||
| const plainClient = initPlainClient(defaultParams) | ||
|
|
||
| it('bulkAction.publishV2', async () => { | ||
| const entry = await plainClient.entry.get({ entryId: TestDefaults.entry.testEntryBulkActionId }) | ||
|
|
||
| const bulkActionInProgress = await plainClient.bulkAction.publishV2(defaultParams, { | ||
| action: 'publish', | ||
| entities: [ | ||
| { | ||
| entity: makeVersionedLink('Entry', entry.sys.id, entry.sys.version), | ||
| add: { fields: { '*': ['en-US'] } }, | ||
| }, | ||
| ], | ||
| }) | ||
|
|
||
| const bulkActionCompleted = await waitForBulkActionV2Processing< | ||
| PublishBulkActionV2Payload<'add'> | ||
| >({ | ||
| ...defaultParams, | ||
| plainClient, | ||
| bulkActionId: bulkActionInProgress.sys.id, | ||
| }) | ||
|
|
||
| expect(bulkActionCompleted.sys.status).toBe('succeeded') | ||
| expect(bulkActionCompleted.action).toBe('publish') | ||
| }) | ||
|
|
||
| it('bulkAction.unpublishV2', async () => { | ||
| const entry = await plainClient.entry.get({ entryId: TestDefaults.entry.testEntryBulkActionId }) | ||
|
|
||
| const bulkActionInProgress = await plainClient.bulkAction.unpublishV2(defaultParams, { | ||
| action: 'unpublish', | ||
| entities: [ | ||
| { | ||
| entity: makeLink('Entry', entry.sys.id), | ||
| }, | ||
| ], | ||
| }) | ||
|
|
||
| const bulkActionCompleted = await waitForBulkActionV2Processing<UnpublishBulkActionV2Payload>({ | ||
| ...defaultParams, | ||
| plainClient, | ||
| bulkActionId: bulkActionInProgress.sys.id, | ||
| }) | ||
|
|
||
| expect(bulkActionCompleted.sys.status).toBe('succeeded') | ||
| expect(bulkActionCompleted.action).toBe('unpublish') | ||
| }) | ||
|
|
||
| it('bulkAction.validateV2', async () => { | ||
| const entry = await plainClient.entry.get({ entryId: TestDefaults.entry.testEntryBulkActionId }) | ||
|
|
||
| const bulkActionInProgress = await plainClient.bulkAction.validateV2(defaultParams, { | ||
| action: 'validate', | ||
| entities: [ | ||
| { | ||
| entity: makeLink('Entry', entry.sys.id), | ||
| add: { fields: { '*': ['en-US'] } }, | ||
| }, | ||
| ], | ||
| }) | ||
|
|
||
| const bulkActionCompleted = await waitForBulkActionV2Processing<ValidateBulkActionV2Payload>({ | ||
| ...defaultParams, | ||
| plainClient, | ||
| bulkActionId: bulkActionInProgress.sys.id, | ||
| }) | ||
|
|
||
| expect(bulkActionCompleted.sys.status).toBe('succeeded') | ||
| expect(bulkActionCompleted.action).toBe('validate') | ||
| }) | ||
| }) | ||
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.
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.
Is this actually used by the plain client? Or is it just a test helper? If it's just a test helper, I think this belongs in the test/helpers.ts file.
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.
I will take a look on the next week. I need to recall this stuff 🙂