-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analytics: Add SELECT_SEARCH_RESULT event #2373
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const image = { | ||
id: "f166c4a0-7207-4ea2-8728-15350a60d37f", | ||
title: "Cat cafe in Seoul", | ||
indexed_on: "2020-04-22T18:09:32.186574Z", | ||
foreign_landing_url: "https://www.flickr.com/photos/36703170@N02/5060030894", | ||
url: "https://live.staticflickr.com/4111/5060030894_96d2b21794_b.jpg", | ||
creator: "toel-uru", | ||
creator_url: "https://www.flickr.com/photos/36703170@N02", | ||
license: "by-nc-sa", | ||
license_version: "2.0", | ||
license_url: "https://creativecommons.org/licenses/by-nc-sa/2.0/", | ||
provider: "flickr", | ||
source: "flickr", | ||
category: null, | ||
filesize: null, | ||
filetype: null, | ||
tags: [ | ||
{ | ||
name: "cat", | ||
accuracy: null, | ||
}, | ||
], | ||
attribution: | ||
'"Cat cafe in Seoul" by toel-uru is licensed under CC BY-NC-SA 2.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/2.0/.', | ||
fields_matched: ["description", "tags.name", "title"], | ||
mature: false, | ||
height: 681, | ||
width: 1024, | ||
thumbnail: | ||
"https://api.openverse.engineering/v1/images/f166c4a0-7207-4ea2-8728-15350a60d37f/thumb/", | ||
detail_url: | ||
"https://api.openverse.engineering/v1/images/f166c4a0-7207-4ea2-8728-15350a60d37f/", | ||
related_url: | ||
"https://api.openverse.engineering/v1/images/f166c4a0-7207-4ea2-8728-15350a60d37f/related/", | ||
unstable__sensitivity: ["sensitive_text"], | ||
} |
49 changes: 49 additions & 0 deletions
49
frontend/test/unit/specs/components/VSearchResultsGrid/v-audio-cell.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { fireEvent } from "@testing-library/vue" | ||
|
||
import { render } from "~~/test/unit/test-utils/render" | ||
|
||
import { getAudioObj } from "~~/test/unit/fixtures/audio" | ||
|
||
import { useAnalytics } from "~/composables/use-analytics" | ||
import { AUDIO } from "~/constants/media" | ||
|
||
import VAudioCell from "~/components/VSearchResultsGrid/VAudioCell.vue" | ||
|
||
jest.mock("~/composables/use-analytics", () => ({ | ||
useAnalytics: jest.fn(), | ||
})) | ||
|
||
describe("VAudioCell", () => { | ||
let options = {} | ||
let sendCustomEventMock = null | ||
const audio = getAudioObj() | ||
|
||
beforeEach(() => { | ||
sendCustomEventMock = jest.fn() | ||
useAnalytics.mockImplementation(() => ({ | ||
sendCustomEvent: sendCustomEventMock, | ||
})) | ||
options = { | ||
props: { | ||
audio, | ||
searchTerm: "cat", | ||
relatedTo: null, | ||
}, | ||
} | ||
}) | ||
|
||
it("sends SELECT_SEARCH_RESULT event when clicked", async () => { | ||
const { getByRole } = render(VAudioCell, options) | ||
const link = getByRole("application") | ||
|
||
await fireEvent.click(link) | ||
|
||
expect(sendCustomEventMock).toHaveBeenCalledWith("SELECT_SEARCH_RESULT", { | ||
id: audio.id, | ||
mediaType: AUDIO, | ||
query: "cat", | ||
provider: audio.provider, | ||
relatedTo: null, | ||
}) | ||
}) | ||
}) |
49 changes: 49 additions & 0 deletions
49
frontend/test/unit/specs/components/VSearchResultsGrid/v-image-cell.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { fireEvent } from "@testing-library/vue" | ||
|
||
import { render } from "~~/test/unit/test-utils/render" | ||
import { image } from "~~/test/unit/fixtures/image" | ||
|
||
import { useAnalytics } from "~/composables/use-analytics" | ||
|
||
import { IMAGE } from "~/constants/media" | ||
|
||
import VImageCell from "~/components/VSearchResultsGrid/VImageCell.vue" | ||
|
||
jest.mock("~/composables/use-analytics", () => ({ | ||
useAnalytics: jest.fn(), | ||
})) | ||
|
||
describe("VImageCell", () => { | ||
let options = {} | ||
let sendCustomEventMock = null | ||
|
||
beforeEach(() => { | ||
sendCustomEventMock = jest.fn() | ||
useAnalytics.mockImplementation(() => ({ | ||
sendCustomEvent: sendCustomEventMock, | ||
})) | ||
options = { | ||
props: { | ||
image, | ||
searchTerm: "cat", | ||
aspectRatio: "square", | ||
obulat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
relatedTo: null, | ||
}, | ||
} | ||
}) | ||
|
||
it("sends SELECT_SEARCH_RESULT event when clicked", async () => { | ||
const { getByRole } = render(VImageCell, options) | ||
const link = getByRole("link") | ||
|
||
await fireEvent.click(link) | ||
|
||
expect(sendCustomEventMock).toHaveBeenCalledWith("SELECT_SEARCH_RESULT", { | ||
id: image.id, | ||
mediaType: IMAGE, | ||
query: "cat", | ||
provider: image.provider, | ||
relatedTo: null, | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this prop necessary for this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
square
is the default foraspectRatio
, so you're right, we can remove it.