-
Notifications
You must be signed in to change notification settings - Fork 451
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
feat(releases): archive and unarchive releases #7072
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
808647c
refactor(sanity): update types to bundle
RitaDias 4e3b76a
feat(sanity): add ability to create releases from dialog + update types
RitaDias 932dea8
feat(sanity): update list on global and document to use store
RitaDias c0f8cf4
feat(sanity): update types, add icon and hue picker to bundles, updat…
RitaDias dfd5d40
feat(sanity): add date picker to bundleform
RitaDias 8aa727a
refactor(sanity): update publishAt fields in menus
RitaDias 263b2ca
refactor(sanity): update type in dummyGetter
RitaDias 269f279
chore(sanity): remove BUNDLES const
RitaDias 4d9cb73
chore(sanity): update LATEST type to Partial
RitaDias c233a70
chore(sanity): update validation for bundle date creation
RitaDias f8794fc
chore(sanity): clean up code
RitaDias e3c762d
refactor(sanity): add archived filter
RitaDias 8feccd4
refactor(sanity): make single bundle menu + clean up
RitaDias 42feacd
chore(sanity): add missing properties
RitaDias 810f692
feat(sanity): add loading & remove unused code
RitaDias d7515f5
feat(sanity): add loading to document version, update filter
RitaDias 788cf21
chore(sanity): rename VersionBadge to BundleBadge
RitaDias 0181e4d
chore(sanity): clean up methods and style
RitaDias b5b7a6f
Merge branch 'corel' into corel-35
RitaDias f58b961
Merge branch 'corel' into corel-35
RitaDias af68e88
chore(sanity): remove unused import
RitaDias 9ab6d65
refactor(sanity): use Bundle provider instead of store
RitaDias 62ffd3e
chore(sanity): update bundleRow to use the new name for badge
RitaDias acdb5ce
chore(sanity): clean up code
RitaDias e904eed
refactor(sanity): re-add oncancel and oncreate props in dialog
RitaDias dc9ca47
refactor(sanity): add scroll to bundle menu
RitaDias 12abc2b
refactor(sanity): move from archived to archivedAt
RitaDias aba518d
refactor(sanity): move version provider to its own file + organise + …
RitaDias 7de4af9
refactor(sanity): remove provider + context, move logic to hook
RitaDias fd8b9d9
chore(sanity): remove comments + change name from setCurrentVersion t…
RitaDias 421d68a
chore(sanity): rename useVersion to useBundle
RitaDias 5c78e5d
chore(sanity): update comments
RitaDias 7360256
chore(sanity): Rename currentVersion
RitaDias 194c03f
refactor(sanity): rename currentBudnle and setGlobalBundle
RitaDias 137996f
chore(sanity): rename versions to bundles in core directory
RitaDias 0a98e28
chore(sanity): rename to GlobalPerspectiveMenu and move to navbar dir…
RitaDias ccd4cf6
chore(sanity): rename to DocumentPerspectiveMenu and move to navbar d…
RitaDias 70b18d7
feat(releases): support for (un)archive
jordanl17 484b480
chore(releases): updating testing for BundlesOverview
jordanl17 cbc845a
chore(releases): new tests for BundleMenuButton and (un)archive
jordanl17 602143a
fix(releases): disabling bundle menu btn when action is performed
jordanl17 f8716ce
Merge branch 'corel' into corel-23-archive-unarchive
jordanl17 1ff7fb0
Merge branch 'corel' into corel-23-archive-unarchive
jordanl17 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 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
108 changes: 108 additions & 0 deletions
108
.../sanity/src/core/releases/components/BundleMenuButton/__tests__/BundleMenuButton.test.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import {describe, expect, jest, test} from '@jest/globals' | ||
import {fireEvent, render, screen} from '@testing-library/react' | ||
import {act} from 'react' | ||
import {useRouter} from 'sanity/router' | ||
|
||
import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' | ||
import {type BundleDocument} from '../../../../store/bundles/types' | ||
import {useBundleOperations} from '../../../../store/bundles/useBundleOperations' | ||
import {releasesUsEnglishLocaleBundle} from '../../../i18n' | ||
import {BundleMenuButton} from '../BundleMenuButton' | ||
|
||
jest.mock('../../../../store/bundles/useBundleOperations', () => ({ | ||
useBundleOperations: jest.fn().mockReturnValue({ | ||
deleteBundle: jest.fn(), | ||
updateBundle: jest.fn(), | ||
}), | ||
})) | ||
|
||
jest.mock('sanity/router', () => ({ | ||
...(jest.requireActual('sanity/router') || {}), | ||
useRouter: jest.fn().mockReturnValue({state: {}, navigate: jest.fn()}), | ||
})) | ||
|
||
const renderTest = async (bundle: BundleDocument) => { | ||
const wrapper = await createTestProvider({ | ||
resources: [releasesUsEnglishLocaleBundle], | ||
}) | ||
return render(<BundleMenuButton bundle={bundle} />, {wrapper}) | ||
} | ||
|
||
describe('BundleMenuButton', () => { | ||
test('will archive an unarchived bundle', async () => { | ||
const activeBundle: BundleDocument = { | ||
_id: 'activeBundle', | ||
_type: 'bundle', | ||
archivedAt: undefined, | ||
title: 'activeBundle', | ||
name: 'activeBundle', | ||
authorId: 'author', | ||
_createdAt: new Date().toISOString(), | ||
_updatedAt: new Date().toISOString(), | ||
_rev: '', | ||
} | ||
|
||
await renderTest(activeBundle) | ||
|
||
fireEvent.click(screen.getByLabelText('Release menu')) | ||
|
||
await act(() => { | ||
fireEvent.click(screen.getByText('Archive')) | ||
}) | ||
|
||
expect(useBundleOperations().updateBundle).toHaveBeenCalledWith({ | ||
...activeBundle, | ||
archivedAt: expect.any(String), | ||
}) | ||
}) | ||
|
||
test('will unarchive an archived bundle', async () => { | ||
const archivedBundle: BundleDocument = { | ||
_id: 'activeBundle', | ||
_type: 'bundle', | ||
archivedAt: new Date().toISOString(), | ||
title: 'activeBundle', | ||
name: 'activeBundle', | ||
authorId: 'author', | ||
_createdAt: new Date().toISOString(), | ||
_updatedAt: new Date().toISOString(), | ||
_rev: '', | ||
} | ||
await renderTest(archivedBundle) | ||
|
||
fireEvent.click(screen.getByLabelText('Release menu')) | ||
|
||
await act(() => { | ||
fireEvent.click(screen.getByText('Unarchive')) | ||
}) | ||
|
||
expect(useBundleOperations().updateBundle).toHaveBeenCalledWith({ | ||
...archivedBundle, | ||
archivedAt: undefined, | ||
}) | ||
}) | ||
|
||
test('will delete a bundle', async () => { | ||
const activeBundle: BundleDocument = { | ||
_id: 'activeBundle', | ||
_type: 'bundle', | ||
archivedAt: new Date().toISOString(), | ||
title: 'activeBundle', | ||
name: 'activeBundle', | ||
authorId: 'author', | ||
_createdAt: new Date().toISOString(), | ||
_updatedAt: new Date().toISOString(), | ||
_rev: '', | ||
} | ||
await renderTest(activeBundle) | ||
|
||
fireEvent.click(screen.getByLabelText('Release menu')) | ||
|
||
await act(() => { | ||
fireEvent.click(screen.getByText('Delete')) | ||
}) | ||
|
||
expect(useBundleOperations().deleteBundle).toHaveBeenCalledWith(activeBundle._id) | ||
expect(useRouter().navigate).not.toHaveBeenCalled() | ||
}) | ||
}) |
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.
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.
I can do this as a fast-follow once sanity-icons has been updated with this icon