fix: Handle non-error empty objects from release notes service (#9134)

This commit is contained in:
Chris Breiding
2020-11-09 11:11:19 -05:00
committed by GitHub
parent 5198a866bd
commit 82d2968e17
2 changed files with 18 additions and 2 deletions

View File

@@ -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()

View File

@@ -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)
})