Skip to content

Commit

Permalink
chore: fix broken typechecks (#10694)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSltun committed Aug 30, 2024
1 parent 7e9bdfe commit eb0b267
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Full Artist Series List", () => {
)

const getWrapper = () => {
const tree = renderWithWrappersLEGACY(<TestRenderer />)
const { root } = renderWithWrappersLEGACY(<TestRenderer />)
act(() => {
env.mock.resolveMostRecentOperation({
errors: [],
Expand All @@ -47,22 +47,24 @@ describe("Full Artist Series List", () => {
},
})
})
return tree
return root
}

it("renders the Full Artist Series Page Header", () => {
const wrapper = getWrapper()
expect(extractText(wrapper.root)).toContain("Artist Series")
const root = getWrapper()
expect(extractText(root)).toContain("Artist Series")
})

it("renders the all of an artist's associated Artist Series", () => {
const wrapper = getWrapper()
expect(wrapper.root.findAllByType(ArtistSeriesListItem)).toHaveLength(6)
it("renders the all of an artist's associated Artist Series", async () => {
const root = getWrapper()

expect(await root.findAllByType(ArtistSeriesListItem)).toHaveLength(6)
})

it("tracks clicks on an artist series", () => {
const wrapper = getWrapper()
const seriesButton = wrapper.root.findAllByType(ArtistSeriesListItem)[0].findByType(Touchable)
it("tracks clicks on an artist series", async () => {
const root = getWrapper()
const artistSeriesListItems = await root.findAllByType(ArtistSeriesListItem)
const seriesButton = await artistSeriesListItems[0].findByType(Touchable)
seriesButton.props.onPress()
expect(mockTrackEvent.mock.calls[0]).toMatchInlineSnapshot(`
[
Expand Down Expand Up @@ -92,6 +94,7 @@ const ArtistSeriesFullArtistSeriesListFixture: ArtistSeriesFullArtistSeriesListT
edges: [
{
node: {
id: "yayoi-kusama-plums",
featured: true,
slug: "yayoi-kusama-plums",
internalID: "da821a13-92fc-49c2-bbd5-bebb790f7020",
Expand All @@ -104,6 +107,7 @@ const ArtistSeriesFullArtistSeriesListFixture: ArtistSeriesFullArtistSeriesListT
},
{
node: {
id: "yayoi-kusama-apricots",
featured: false,
slug: "yayoi-kusama-apricots",
internalID: "ecfa5731-9d64-4bc2-9f9f-c427a9126064",
Expand All @@ -116,6 +120,7 @@ const ArtistSeriesFullArtistSeriesListFixture: ArtistSeriesFullArtistSeriesListT
},
{
node: {
id: "yayoi-kusama-pumpkins",
featured: false,
slug: "yayoi-kusama-pumpkins",
internalID: "58597ef5-3390-406b-b6d2-d4e308125d0d",
Expand All @@ -128,6 +133,7 @@ const ArtistSeriesFullArtistSeriesListFixture: ArtistSeriesFullArtistSeriesListT
},
{
node: {
id: "yayoi-kusama-apples",
featured: false,
slug: "yayoi-kusama-apples",
internalID: "5856ee51-35eb-4b75-bb12-15a1cd7e012e",
Expand All @@ -140,6 +146,7 @@ const ArtistSeriesFullArtistSeriesListFixture: ArtistSeriesFullArtistSeriesListT
},
{
node: {
id: "yayoi-kusama-grapefruit",
featured: false,
slug: "yayoi-kusama-grapefruit",
internalID: "5856ee51-35eb-4b75-bb12-15a1816a9",
Expand All @@ -152,6 +159,7 @@ const ArtistSeriesFullArtistSeriesListFixture: ArtistSeriesFullArtistSeriesListT
},
{
node: {
id: "yayoi-kusama-dragonfruit",
featured: false,
slug: "yayoi-kusama-dragonfruit",
internalID: "5856ee51-35eb-4b75-bb12-15a1cd18161",
Expand Down
10 changes: 6 additions & 4 deletions src/app/Scenes/ArtistSeries/ArtistSeriesHeader.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ describe("Artist Series Header", () => {
/>
)

it("renders the Artist Series header", () => {
it("renders the Artist Series header", async () => {
const wrapper = () => {
const tree = renderWithWrappersLEGACY(<TestRenderer />)
const { root } = renderWithWrappersLEGACY(<TestRenderer />)
act(() => {
env.mock.resolveMostRecentOperation({
errors: [],
Expand All @@ -45,17 +45,19 @@ describe("Artist Series Header", () => {
},
})
})
return tree
return root
}
const imageView = await wrapper().findByType(OpaqueImageView)

expect(wrapper().root.findByType(OpaqueImageView).props.imageURL).toBe(
expect(imageView.props.imageURL).toBe(
"https://www.imagesofpumpkins.cloudfront.net/primary/square.jpg"
)
})
})

const ArtistSeriesHeaderFixture: ArtistSeriesHeaderTestsQuery["rawResponse"] = {
artistSeries: {
id: "pumpkins",
image: {
url: "https://www.imagesofpumpkins.cloudfront.net/primary/square.jpg",
},
Expand Down
56 changes: 28 additions & 28 deletions src/app/Scenes/ArtistSeries/ArtistSeriesMeta.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("Artist Series Meta", () => {
)

const getWrapper = () => {
const tree = renderWithWrappersLEGACY(<TestRenderer />)
const { root } = renderWithWrappersLEGACY(<TestRenderer />)
act(() => {
env.mock.resolveMostRecentOperation({
errors: [],
Expand All @@ -54,46 +54,45 @@ describe("Artist Series Meta", () => {
},
})
})
return tree
return root
}

it("renders without throwing an error", () => {
const wrapper = getWrapper()
expect(wrapper.root.findAllByType(ArtistSeriesMeta)).toHaveLength(1)
it("renders without throwing an error", async () => {
const root = getWrapper()
expect(await root.findAllByType(ArtistSeriesMeta)).toHaveLength(1)
})

it("renders the Artist Series title", () => {
const wrapper = getWrapper()
expect(wrapper.root.findByProps({ testID: "title" }).props.children).toBe(
"These are the Pumpkins"
)
it("renders the Artist Series title", async () => {
const root = getWrapper()
const title = await root.findByProps({ testID: "title" })
expect(title.props.children).toBe("These are the Pumpkins")
})

it("renders the Artist Series description", () => {
const wrapper = getWrapper()
expect(wrapper.root.findByProps({ testID: "description" }).props.content).toBe(
"A deliciously artistic variety of painted pumpkins."
)
it("renders the Artist Series description", async () => {
const root = getWrapper()
const description = await root.findByProps({ testID: "description" })
expect(description.props.content).toBe("A deliciously artistic variety of painted pumpkins.")
})

it("renders an entity header component with artist's meta data", () => {
const wrapper = getWrapper()
expect(wrapper.root.findAllByType(EntityHeader)).toHaveLength(1)
expect(wrapper.root.findAllByType(EntityHeader)[0].props.name).toBe("Yayoi Kusama")
it("renders an entity header component with artist's meta data", async () => {
const root = getWrapper()
const entityHeaders = await root.findAllByType(EntityHeader)
expect(entityHeaders).toHaveLength(1)
expect(entityHeaders[0].props.name).toBe("Yayoi Kusama")
})

it("navigates user to artist page when entity header artist tapped ", () => {
const wrapper = getWrapper().root.findByType(TouchableOpacity)
wrapper.props.onPress()
it("navigates user to artist page when entity header artist tapped ", async () => {
const button = await getWrapper().findByType(TouchableOpacity)
button.props.onPress()
expect(navigate).toHaveBeenCalledWith("/artist/yayoi-kusama")
})

it("tracks unfollows", () => {
const wrapper = getWrapper()
const followButton = wrapper.root
.findAllByType(EntityHeader)[0]
.findAllByType(TouchableWithoutFeedback)[0]
followButton.props.onPress()
it("tracks unfollows", async () => {
const root = getWrapper()
const entityHeaders = await root.findAllByType(EntityHeader)
const followButtons = await entityHeaders[0].findAllByType(TouchableWithoutFeedback)

followButtons[0].props.onPress()
expect(mockTrackEvent).toHaveBeenCalledWith({
action: "unfollowedArtist",
context_module: "featuredArtists",
Expand All @@ -109,6 +108,7 @@ describe("Artist Series Meta", () => {

const ArtistSeriesFixture: ArtistSeriesMetaTestsQuery["rawResponse"] = {
artistSeries: {
id: "bs5678",
internalID: "as1234",
slug: "cool-artist-series",
title: "These are the Pumpkins",
Expand Down
62 changes: 37 additions & 25 deletions src/app/Scenes/ArtistSeries/ArtistSeriesMoreSeries.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("ArtistSeriesMoreSeries", () => {
)

const getWrapper = (testFixture: any) => {
const tree = renderWithWrappersLEGACY(<TestRenderer />)
const { root } = renderWithWrappersLEGACY(<TestRenderer />)
act(() => {
env.mock.resolveMostRecentOperation({
errors: [],
Expand All @@ -63,30 +63,30 @@ describe("ArtistSeriesMoreSeries", () => {
},
})
})
return tree
return root
}

it("renders without throwing an error", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesFixture)
expect(wrapper.root.findAllByType(ArtistSeriesMoreSeries)).toHaveLength(1)
it("renders without throwing an error", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesFixture)
expect(await root.findAllByType(ArtistSeriesMoreSeries)).toHaveLength(1)
})

it("renders the correct header text", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesFixture)
expect(wrapper.root.findByProps({ testID: "header" }).props.children).toBe("This is a header")
it("renders the correct header text", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesFixture)
const header = await root.findByProps({ testID: "header" })
expect(header.props.children).toBe("This is a header")
})

describe("with at least one other series related to the artist to show", () => {
it("renders the related artist series", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesFixture)
expect(wrapper.root.findAllByType(ArtistSeriesListItem).length).toBe(5)
it("renders the related artist series", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesFixture)
expect(await root.findAllByType(ArtistSeriesListItem)).toHaveLength(5)
})

it("tracks an event on click", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesFixture)
const artistSeriesButton = wrapper.root
.findAllByType(ArtistSeriesListItem)[0]
.findByType(Touchable)
it("tracks an event on click", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesFixture)
const artistSerieListItems = await root.findAllByType(ArtistSeriesListItem)
const artistSeriesButton = artistSerieListItems[0].findByType(Touchable)

act(() => artistSeriesButton.props.onPress())

Expand All @@ -107,29 +107,31 @@ describe("ArtistSeriesMoreSeries", () => {
})

describe("with no other series related to the artist to show", () => {
it("does not render", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesNoSeriesFixture)
expect(wrapper.root.findAllByType(ArtistSeriesListItem).length).toBe(0)
it("does not render", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesNoSeriesFixture)
expect(await root.findAllByType(ArtistSeriesListItem)).toHaveLength(0)
})
})

describe("with greater than four series associated with an artist", () => {
it("renders a view all button with a total count for all the series associated with the artist", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesFixture)
expect(wrapper.root.findByProps({ testID: "viewAll" }).props.children).toBe("View All (6)")
it("renders a view all button with a total count for all the series associated with the artist", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesFixture)
const viewAllButton = await root.findByProps({ testID: "viewAll" })
expect(viewAllButton.props.children).toBe("View All (6)")
})
})

describe("with fewer than four series associated with an artist", () => {
it("does not render a view all button", () => {
const wrapper = getWrapper(ArtistSeriesMoreSeriesBelowViewAllThresholdFixture)
expect(wrapper.root.findAllByProps({ testID: "viewAll" })).toHaveLength(0)
it("does not render a view all button", async () => {
const root = getWrapper(ArtistSeriesMoreSeriesBelowViewAllThresholdFixture)
expect(await root.findAllByProps({ testID: "viewAll" })).toHaveLength(0)
})
})
})

const ArtistSeriesMoreSeriesNoSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawResponse"] = {
artistSeries: {
id: "abc123",
artist: [
{
id: "abc123",
Expand All @@ -146,6 +148,7 @@ const ArtistSeriesMoreSeriesNoSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["r

const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawResponse"] = {
artistSeries: {
id: "abc123",
artist: [
{
id: "abc123",
Expand All @@ -156,6 +159,7 @@ const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawRespon
edges: [
{
node: {
id: "yayoi-kusama-plums",
featured: true,
slug: "yayoi-kusama-plums",
internalID: "da821a13-92fc-49c2-bbd5-bebb790f7020",
Expand All @@ -168,6 +172,7 @@ const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawRespon
},
{
node: {
id: "yayoi-kusama-apricots",
featured: true,
slug: "yayoi-kusama-apricots",
internalID: "ecfa5731-9d64-4bc2-9f9f-c427a9126064",
Expand All @@ -180,6 +185,7 @@ const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawRespon
},
{
node: {
id: "yayoi-kusama-pumpkins",
featured: true,
slug: "yayoi-kusama-pumpkins",
internalID: "58597ef5-3390-406b-b6d2-d4e308125d0d",
Expand All @@ -192,6 +198,7 @@ const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawRespon
},
{
node: {
id: "yayoi-kusama-apples",
featured: true,
slug: "yayoi-kusama-apples",
internalID: "5856ee51-35eb-4b75-bb12-15a1cd7e012e",
Expand All @@ -204,6 +211,7 @@ const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawRespon
},
{
node: {
id: "yayoi-kusama-dragonfruit",
featured: true,
slug: "yayoi-kusama-dragonfruit",
internalID: "5856ee51-35eb-4b75-bb12-15a1cd18161",
Expand All @@ -224,6 +232,7 @@ const ArtistSeriesMoreSeriesFixture: ArtistSeriesMoreSeriesTestsQuery["rawRespon
const ArtistSeriesMoreSeriesBelowViewAllThresholdFixture: ArtistSeriesMoreSeriesTestsQuery["rawResponse"] =
{
artistSeries: {
id: "abc123",
artist: [
{
id: "abc123",
Expand All @@ -234,6 +243,7 @@ const ArtistSeriesMoreSeriesBelowViewAllThresholdFixture: ArtistSeriesMoreSeries
edges: [
{
node: {
id: "yayoi-kusama-pumpkins",
featured: true,
slug: "yayoi-kusama-pumpkins",
internalID: "58597ef5-3390-406b-b6d2-d4e308125d0d",
Expand All @@ -246,6 +256,7 @@ const ArtistSeriesMoreSeriesBelowViewAllThresholdFixture: ArtistSeriesMoreSeries
},
{
node: {
id: "yayoi-kusama-apples",
featured: true,
slug: "yayoi-kusama-apples",
internalID: "5856ee51-35eb-4b75-bb12-15a1cd7e012e",
Expand All @@ -258,6 +269,7 @@ const ArtistSeriesMoreSeriesBelowViewAllThresholdFixture: ArtistSeriesMoreSeries
},
{
node: {
id: "yayoi-kusama-dragonfruit",
featured: true,
slug: "yayoi-kusama-dragonfruit",
internalID: "5856ee51-35eb-4b75-bb12-15a1cd18161",
Expand Down

0 comments on commit eb0b267

Please sign in to comment.