Skip to content

Commit

Permalink
fix: Missing artwork ID in SWA My Collection flow (#11045)
Browse files Browse the repository at this point in the history
* fix: Missing artwork ID in SWA My Collection flow

* test
  • Loading branch information
olerichter00 authored and gkartalis committed Oct 31, 2024
1 parent 1a587b7 commit da313a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SubmitArtworkStackNavigation } from "app/Scenes/SellWithArtsy/ArtworkFo
import { fetchArtworkInformation } from "app/Scenes/SellWithArtsy/ArtworkForm/Utils/fetchArtworkInformation"
import { getInitialSubmissionFormValuesFromArtwork } from "app/Scenes/SellWithArtsy/ArtworkForm/Utils/getInitialSubmissionValuesFromArtwork"
import { SubmissionModel } from "app/Scenes/SellWithArtsy/ArtworkForm/Utils/validation"
import { createOrUpdateSubmission } from "app/Scenes/SellWithArtsy/SubmitArtwork/ArtworkDetails/utils/createOrUpdateSubmission"
import { dismissModal, switchTab } from "app/system/navigation/navigate"
import { extractNodes } from "app/utils/extractNodes"
import { useRefreshControl } from "app/utils/refreshHelpers"
Expand Down Expand Up @@ -48,17 +49,27 @@ export const SubmitArtworkFromMyCollectionArtworks: React.FC<{}> = () => {
try {
setIsLoading(true)
// Fetch Artwork Details

const artwork = await fetchArtworkInformation(artworkID)

if (artwork) {
const formValues = {
const artworkValues = {
...getInitialSubmissionFormValuesFromArtwork(artwork),
submissionId: values.submissionId,
externalId: values.externalId,
userName: values.userName,
userEmail: values.userEmail,
userPhone: values.userPhone,
}
setValues(formValues)

const submission = await createOrUpdateSubmission(artworkValues, values.submissionId)

setValues({
...artworkValues,
submissionId: submission?.internalID || values.submissionId,
externalId: submission?.externalID || values.externalId,
})

setIsLoading(false)

navigation.navigate("AddTitle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ jest.mock("app/Scenes/SellWithArtsy/ArtworkForm/Utils/useSubmissionContext", ()
}
},
}))

jest.mock("app/Scenes/SellWithArtsy/ArtworkForm/Utils/fetchArtworkInformation", () => ({
fetchArtworkInformation: jest.fn().mockResolvedValue({ artwork: mockedFetchedArtwork }),
}))
jest.mock(
"app/Scenes/SellWithArtsy/SubmitArtwork/ArtworkDetails/utils/createOrUpdateSubmission",
() => ({
createOrUpdateSubmission: jest
.fn()
.mockResolvedValue({ internalID: "internal-id", externalID: "external-id" }),
})
)

describe("SubmitArtworkFromMyCollection", () => {
beforeEach(() => {
Expand Down

0 comments on commit da313a7

Please sign in to comment.