Skip to content

Commit

Permalink
Fix issue in deployed apps where StateSubmissions are shown as Draft …
Browse files Browse the repository at this point in the history
…after submission (#176)

* A little logging to start a fix branch

* Fix bug that only appeared in prod where after submission, the card showed "DRAFT" still
  • Loading branch information
macrael authored Jun 28, 2021
1 parent 64cb3f4 commit f2f4c3d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 0 additions & 2 deletions services/app-web/src/api/fakeAmplifyFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export async function fakeAmplifyFetch(
uri: string,
options: RequestInit
): Promise<Response> {
console.log('try to amplify', uri, options)

if (options.method !== 'POST') {
throw new Error('unexpected GQL request')
}
Expand Down
7 changes: 5 additions & 2 deletions services/app-web/src/pages/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, {useEffect} from 'react'
import { BrowserRouter } from 'react-router-dom'
import { ErrorBoundary } from 'react-error-boundary'
import {
Expand Down Expand Up @@ -35,7 +35,10 @@ function App({
apolloClient: ApolloClient<NormalizedCacheObject>
s3Client: S3ClientT
}): React.ReactElement {
logEvent('on_load', { success: true })

useEffect(() => {
logEvent('on_load', { success: true })
}, []);

return (
<ErrorBoundary FallbackComponent={ErrorFallback}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,21 @@ export const ReviewSubmit = ({
>(undefined)
const history = useHistory()
const [submitDraftSubmission] = useSubmitDraftSubmissionMutation({
// An alternative to messing with the cache, just force refetch this query along with this one
refetchQueries: ['indexSubmissions'],
// An alternative to messing with the cache like we do with create, just zero it out.
update(cache, { data }) {
if (data) {
cache.modify({
id: 'ROOT_QUERY',
fields: {
indexSubmissions(
_index, {DELETE}
) {
return DELETE
},
},
})
}
},
})

useEffect(() => {
Expand Down Expand Up @@ -119,6 +132,8 @@ export const ReviewSubmit = ({
},
})

console.log("Got data: ", data)

if (data.errors) {
console.log(data.errors)
showError('Error attempting to submit. Please try again.')
Expand Down
11 changes: 7 additions & 4 deletions tests/cypress/integration/stateSubmission.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,18 @@ describe('State Submission', () => {
cy.findByTestId('submission-name')
.invoke('text')
.then((nameText) => {
console.log('GOT TEXT', nameText)

// Navigate to the dashboard again
// Submit the form and navigate to the dashboard again
cy.navigateForm('Submit')
cy.findByRole('heading', { name: 'Submissions' }).should(
'exist'
)

cy.findByText(nameText).should('exist')
cy.findByText(nameText).should('exist').then( (submittedText) => {
// find "SUBMITTED" in the card
const submissionCard = submittedText.parent().parent()
const cardStatus = submissionCard.find('span[data-testid="tag"]').html()
assert(cardStatus.indexOf('Submitted') === 0, 'Submission isnt displayed as Submitted')
})
})
})

Expand Down

0 comments on commit f2f4c3d

Please sign in to comment.