-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add collapsible element to updater notification to show changelog, open if there breaking changes #4051
Merged
pierremtb
merged 9 commits into
main
from
franknoirot/3984/show-changelog-in-update-toast
Oct 15, 2024
Merged
Add collapsible element to updater notification to show changelog, open if there breaking changes #4051
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
61183fe
Add collapsible element to updater toast notification showing release…
franknoirot 91b4f35
Temp create release artifacts to test updater
franknoirot 3054cf7
Merge branch 'main' into franknoirot/3984/show-changelog-in-update-toast
pierremtb 453a5bd
Merge branch 'main' into franknoirot/3984/show-changelog-in-update-toast
pierremtb 3a5cdb7
Fix tsc error
franknoirot 3fc00c5
Fix some styling, make release notes not appear if no notes are present
franknoirot 0bc76de
Add component tests
franknoirot 8d261ff
Merge branch 'main' into franknoirot/3984/show-changelog-in-update-toast
pierremtb 6818f86
Remove test release builds
pierremtb 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react' | ||
import { vi } from 'vitest' | ||
import { ToastUpdate } from './ToastUpdate' | ||
|
||
describe('ToastUpdate tests', () => { | ||
const testData = { | ||
version: '0.255.255', | ||
files: [ | ||
{ | ||
url: 'Zoo Modeling App-0.255.255-x64-mac.zip', | ||
sha512: | ||
'VJb0qlrqNr+rVx3QLATz+B28dtHw3osQb5/+UUmQUIMuF9t0i8dTKOVL/2lyJSmLJVw2/SGDB4Ud6VlTPJ6oFw==', | ||
size: 141277345, | ||
}, | ||
{ | ||
url: 'Zoo Modeling App-0.255.255-arm64-mac.zip', | ||
sha512: | ||
'b+ugdg7A4LhYYJaFkPRxh1RvmGGMlPJJj7inkLg9PwRtCnR9ePMlktj2VRciXF1iLh59XW4bLc4dK1dFQHMULA==', | ||
size: 135278259, | ||
}, | ||
{ | ||
url: 'Zoo Modeling App-0.255.255-x64-mac.dmg', | ||
sha512: | ||
'gCUqww05yj8OYwPiTq6bo5GbkpngSbXGtenmDD7+kUm0UyVK8WD3dMAfQJtGNG5HY23aHCHe9myE2W4mbZGmiQ==', | ||
size: 146004232, | ||
}, | ||
{ | ||
url: 'Zoo Modeling App-0.255.255-arm64-mac.dmg', | ||
sha512: | ||
'ND871ayf81F1ZT+iWVLYTc2jdf/Py6KThuxX2QFWz14ebmIbJPL07lNtxQOexOFiuk0MwRhlCy1RzOSG1b9bmw==', | ||
size: 140021522, | ||
}, | ||
], | ||
path: 'Zoo Modeling App-0.255.255-x64-mac.zip', | ||
sha512: | ||
'VJb0qlrqNr+rVx3QLATz+B28dtHw3osQb5/+UUmQUIMuF9t0i8dTKOVL/2lyJSmLJVw2/SGDB4Ud6VlTPJ6oFw==', | ||
releaseNotes: | ||
'## Some markdown release notes\n\n- This is a list item\n- This is another list item\n\n```javascript\nconsole.log("Hello, world!")\n```\n', | ||
releaseDate: '2024-10-09T11:57:59.133Z', | ||
} as const | ||
|
||
test('Happy path: renders the toast with good data', () => { | ||
const onRestart = vi.fn() | ||
const onDismiss = vi.fn() | ||
|
||
render( | ||
<ToastUpdate | ||
onRestart={onRestart} | ||
onDismiss={onDismiss} | ||
version={testData.version} | ||
releaseNotes={testData.releaseNotes} | ||
/> | ||
) | ||
|
||
// Locators and other constants | ||
const versionText = screen.getByTestId('update-version') | ||
const restartButton = screen.getByRole('button', { name: /restart/i }) | ||
const dismissButton = screen.getByRole('button', { name: /got it/i }) | ||
const releaseNotes = screen.getByTestId('release-notes') | ||
|
||
expect(versionText).toBeVisible() | ||
expect(versionText).toHaveTextContent(testData.version) | ||
|
||
expect(restartButton).toBeEnabled() | ||
fireEvent.click(restartButton) | ||
expect(onRestart.mock.calls).toHaveLength(1) | ||
|
||
expect(dismissButton).toBeEnabled() | ||
fireEvent.click(dismissButton) | ||
expect(onDismiss.mock.calls).toHaveLength(1) | ||
|
||
// I cannot for the life of me seem to get @testing-library/react | ||
// to properly handle click events or visibility checks on the details element. | ||
// So I'm only checking that the content is in the document. | ||
expect(releaseNotes).toBeInTheDocument() | ||
expect(releaseNotes).toHaveTextContent('Release notes') | ||
const releaseNotesListItems = screen.getAllByRole('listitem') | ||
expect(releaseNotesListItems.map((el) => el.textContent)).toEqual([ | ||
'This is a list item', | ||
'This is another list item', | ||
]) | ||
}) | ||
|
||
test('Happy path: renders the breaking changes notice', () => { | ||
const releaseNotesWithBreakingChanges = ` | ||
## Some markdown release notes | ||
- This is a list item | ||
- This is another list item with a breaking change | ||
- This is a list item | ||
` | ||
const onRestart = vi.fn() | ||
const onDismiss = vi.fn() | ||
|
||
render( | ||
<ToastUpdate | ||
onRestart={onRestart} | ||
onDismiss={onDismiss} | ||
version={testData.version} | ||
releaseNotes={releaseNotesWithBreakingChanges} | ||
/> | ||
) | ||
|
||
// Locators and other constants | ||
const releaseNotes = screen.getByText('Release notes', { | ||
selector: 'summary', | ||
}) | ||
const listItemContents = screen | ||
.getAllByRole('listitem') | ||
.map((el) => el.textContent) | ||
|
||
// I cannot for the life of me seem to get @testing-library/react | ||
// to properly handle click events or visibility checks on the details element. | ||
// So I'm only checking that the content is in the document. | ||
expect(releaseNotes).toBeInTheDocument() | ||
expect(listItemContents).toEqual([ | ||
'This is a list item', | ||
'This is another list item with a breaking change', | ||
'This is a list item', | ||
]) | ||
}) | ||
|
||
test('Missing release notes: renders the toast without release notes', () => { | ||
const onRestart = vi.fn() | ||
const onDismiss = vi.fn() | ||
|
||
render( | ||
<ToastUpdate | ||
onRestart={onRestart} | ||
onDismiss={onDismiss} | ||
version={testData.version} | ||
releaseNotes={''} | ||
/> | ||
) | ||
|
||
// Locators and other constants | ||
const versionText = screen.getByTestId('update-version') | ||
const restartButton = screen.getByRole('button', { name: /restart/i }) | ||
const dismissButton = screen.getByRole('button', { name: /got it/i }) | ||
const releaseNotes = screen.queryByText(/release notes/i, { | ||
selector: 'details > summary', | ||
}) | ||
const releaseNotesListItem = screen.queryByRole('listitem', { | ||
name: /this is a list item/i, | ||
}) | ||
|
||
expect(versionText).toBeVisible() | ||
expect(versionText).toHaveTextContent(testData.version) | ||
expect(releaseNotes).not.toBeInTheDocument() | ||
expect(releaseNotesListItem).not.toBeInTheDocument() | ||
expect(restartButton).toBeEnabled() | ||
expect(dismissButton).toBeEnabled() | ||
}) | ||
}) |
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.
Don't let me merge this without reverting this part