Skip to content

Commit

Permalink
fix: show edit artwork button (#10635)
Browse files Browse the repository at this point in the history
* fix: show edit artwork button

* chore: address review comments
  • Loading branch information
MounirDhahri authored and MrSltun committed Aug 21, 2024
1 parent 01614ae commit 3392154
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,14 @@
"filename": "src/app/Scenes/MyCollection/Screens/ArtworkForm/MyCollectionArtworkForm.tests.tsx",
"hashed_secret": "67d1be5993e49fbaba0bbd38492c33a2bc007ef7",
"is_verified": false,
"line_number": 624
"line_number": 625
},
{
"type": "Base64 High Entropy String",
"filename": "src/app/Scenes/MyCollection/Screens/ArtworkForm/MyCollectionArtworkForm.tests.tsx",
"hashed_secret": "6414700358f2ae5762917a164e2e30df8783fc4e",
"is_verified": false,
"line_number": 710
"line_number": 711
}
],
"src/app/Scenes/MyCollection/Screens/Insights/SelectArtist.tests.tsx": [
Expand Down Expand Up @@ -1134,5 +1134,5 @@
}
]
},
"generated_at": "2024-08-07T08:22:24Z"
"generated_at": "2024-08-21T08:03:56Z"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { screen } from "@testing-library/react-native"
import { getMockRelayEnvironment } from "app/system/relay/defaultEnvironment"
import { renderWithHookWrappersTL } from "app/utils/tests/renderWithWrappers"
import { resolveMostRecentRelayOperation } from "app/utils/tests/resolveMostRecentRelayOperation"
Expand All @@ -7,7 +8,7 @@ const mockEnvironment = getMockRelayEnvironment()

describe("My Collection Artwork", () => {
it("show new artwork screen ", () => {
const { getByTestId } = renderWithHookWrappersTL(
renderWithHookWrappersTL(
<MyCollectionArtworkScreen
artworkId="random-id"
artistInternalID="internal-id"
Expand All @@ -18,6 +19,48 @@ describe("My Collection Artwork", () => {
)

resolveMostRecentRelayOperation(mockEnvironment)
expect(() => getByTestId("my-collection-artwork")).toBeTruthy()
expect(() => screen.getByTestId("my-collection-artwork")).toBeTruthy()
})

describe("Edit button", () => {
it("should be visible when consignmentSubmission is available", () => {
renderWithHookWrappersTL(
<MyCollectionArtworkScreen
artworkId="random-id"
artistInternalID="internal-id"
medium="medium"
category="medium"
/>,
mockEnvironment
)

resolveMostRecentRelayOperation(mockEnvironment, {
Artwork: () => ({
consignmentSubmission: {
internalID: "submission-id",
},
}),
})
expect(screen.getByText("Edit")).toBeOnTheScreen()
})

it("should be visible when consignmentSubmission is not available", () => {
renderWithHookWrappersTL(
<MyCollectionArtworkScreen
artworkId="random-id"
artistInternalID="internal-id"
medium="medium"
category="medium"
/>,
mockEnvironment
)

resolveMostRecentRelayOperation(mockEnvironment, {
Artwork: () => ({
consignmentSubmission: null,
}),
})
expect(() => screen.getByText("Edit")).toThrow()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ const MyCollectionArtwork: React.FC<MyCollectionArtworkScreenProps> = ({

const articles = extractNodes(artwork.artist?.articles)

const isEditable = !!artwork.consignmentSubmission?.internalID

return (
<Screen>
<Screen.Header
onBack={goBack}
rightElements={() =>
!artwork.consignmentSubmission && (
rightElements={
!!isEditable && (
<TouchableOpacity onPress={handleEdit} hitSlop={DEFAULT_HIT_SLOP}>
<Text>Edit</Text>
</TouchableOpacity>
Expand Down Expand Up @@ -271,6 +273,7 @@ export const ArtworkMetaProps = graphql`
# needed to show the banner inside the edit artwork view
# TODO: move logic to the edit artwork view https://artsyproduct.atlassian.net/browse/CX-2846
consignmentSubmission @optionalField {
internalID
displayText
}
pricePaid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ describe("MyCollectionArtworkForm", () => {
confidentialNotes: "some-notes",
consignmentSubmission: {
displayText: "In progress",
internalID: "submission-id",
},
dimensions: {
in: "23",
Expand Down

0 comments on commit 3392154

Please sign in to comment.