Skip to content

Commit

Permalink
Merge pull request #11517 from artsy/janaehijaz/1106
Browse files Browse the repository at this point in the history
feat(DIA-1106): updating 'back' and 'exit' icons for infinite discovery
  • Loading branch information
JanaeHijaz authored Feb 7, 2025
2 parents dd9b616 + e9e4d6c commit f1f8336
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/app/Scenes/InfiniteDiscovery/InfiniteDiscovery.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex, Screen, Spinner, Text, Touchable } from "@artsy/palette-mobile"
import { ArrowBackIcon, CloseIcon, Flex, Screen, Spinner, Touchable } from "@artsy/palette-mobile"
import { FancySwiper } from "app/Components/FancySwiper/FancySwiper"
import { useToast } from "app/Components/Toast/toastHook"
import { InfiniteDiscoveryArtworkCard } from "app/Scenes/InfiniteDiscovery/Components/InfiniteDiscoveryArtworkCard"
Expand Down Expand Up @@ -103,14 +103,14 @@ export const InfiniteDiscovery: React.FC<InfiniteDiscoveryProps> = ({
<Screen.Header
title="Discovery"
leftElements={
<Touchable onPress={handleBackPressed}>
<Text variant="xs">Back</Text>
<Touchable onPress={handleBackPressed} testID="back-icon">
<ArrowBackIcon />
</Touchable>
}
hideLeftElements={index === 0}
rightElements={
<Touchable onPress={handleExitPressed}>
<Text variant="xs">Exit</Text>
<Touchable onPress={handleExitPressed} testID="close-icon">
<CloseIcon fill="black100" />
</Touchable>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,36 @@ xdescribe("InfiniteDiscovery", () => {
jest.clearAllMocks()
})

it("hides the back button if the current artwork is on the first artwork", async () => {
it("hides the back icon if the current artwork is on the first artwork", async () => {
await renderAndFetchFirstBatch(mockFetchQuery)

expect(screen.queryByText("Back")).not.toBeOnTheScreen()
expect(screen.queryByTestId("back-icon")).not.toBeOnTheScreen()
})

it("shows the back button if the current artwork is not the first artwork", async () => {
it("shows the back icon if the current artwork is not the first artwork", async () => {
await renderAndFetchFirstBatch(mockFetchQuery)

swipeLeft()

await screen.findByText("Back")
await screen.findByTestId("back-icon")
})

it("returns to the previous artwork when the back button is pressed", async () => {
it("returns to the previous artwork when the back icon is pressed", async () => {
await renderAndFetchFirstBatch(mockFetchQuery)

expect(screen.queryByText("Back")).not.toBeOnTheScreen()
expect(screen.queryByTestId("back-icon")).not.toBeOnTheScreen()
swipeLeft()

await screen.findByText("Back")
await screen.findByTestId("back-icon")

fireEvent.press(screen.getByText("Back"))
expect(screen.queryByText("Back")).not.toBeOnTheScreen()
fireEvent.press(screen.getByTestId("back-icon"))
expect(screen.queryByTestId("back-icon")).not.toBeOnTheScreen()
})

it("navigates to home view when the exit button is pressed", async () => {
it("navigates to home view when the close icon is pressed", async () => {
await renderAndFetchFirstBatch(mockFetchQuery)

fireEvent.press(screen.getByText("Exit"))
fireEvent.press(screen.getByTestId("close-icon"))
expect(goBack).toHaveBeenCalledTimes(1)
})
})
Expand Down

0 comments on commit f1f8336

Please sign in to comment.