mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-24 16:59:22 -06:00
fix: Handle non-error empty objects from release notes service (#9134)
This commit is contained in:
@@ -43,6 +43,15 @@ describe('Release Notes', () => {
|
||||
cy.contains('Update to Version 1.2.3').should('be.visible')
|
||||
})
|
||||
|
||||
it('shows update instructions if release notes does not include title or content', () => {
|
||||
// if this hasn't been released on on.cypress.io yet, it will use the default redirect
|
||||
// and not a 404 error, which returns an empty object
|
||||
// also protects against the data not being correct in any case
|
||||
getReleaseNotes.resolve({})
|
||||
cy.get('.update-notice').contains('Learn more').click()
|
||||
cy.contains('Update to Version 1.2.3').should('be.visible')
|
||||
})
|
||||
|
||||
it('shows update instructions if getting release notes errors', () => {
|
||||
getReleaseNotes.reject(new Error('something went wrong'))
|
||||
cy.get('.update-notice').contains('Learn more').click()
|
||||
|
||||
@@ -42,10 +42,17 @@ export const getReleaseNotes = (version) => {
|
||||
|
||||
ipc.getReleaseNotes(version)
|
||||
.then((releaseNotes) => {
|
||||
if (!releaseNotes || !releaseNotes.title || !releaseNotes.content) {
|
||||
updateStore.setReleaseNotes(undefined)
|
||||
updateStore.setState(updateStore.SHOW_INSTRUCTIONS)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
updateStore.setReleaseNotes(releaseNotes)
|
||||
updateStore.setState(releaseNotes ? updateStore.SHOW_RELEASE_NOTES : updateStore.SHOW_INSTRUCTIONS)
|
||||
updateStore.setState(updateStore.SHOW_RELEASE_NOTES)
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(() => {
|
||||
updateStore.setReleaseNotes(undefined)
|
||||
updateStore.setState(updateStore.SHOW_INSTRUCTIONS)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user