Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix back to search results link (#588)
Krystle Salazar3161c64f9ea8
diff --git a/src/components/ImageDetails/VPhotoDetails.vue b/src/components/ImageDetails/VPhotoDetails.vueindex d0b78e5eb..3a59a977a 100644--- a/src/components/ImageDetails/VPhotoDetails.vue+++ b/src/components/ImageDetails/VPhotoDetails.vue@@ -3,7 +3,7 @@<div class="column is-three-fifths photo_image-ctr mt-4"><av-if="shouldShowBreadcrumb"- class="block photo_breadcrumb text-left ms-4 mb-4 lg:ms-0 text-dark-gray font-semibold caption"+ class="flex photo_breadcrumb text-left mb-4 lg:ms-0 text-dark-gray font-semibold caption":href="breadCrumbURL"@click.prevent="goBackToSearchResults">@@ -157,7 +157,7 @@</template><script>-import { computed, ref, useContext } from '@nuxtjs/composition-api'+import { computed, ref, useContext, useRouter } from '@nuxtjs/composition-api'import { USAGE_DATA } from '~/constants/store-modules'import {@@ -200,7 +200,8 @@ export default {'thumbnail',],setup(props, { emit }) {- const { router, store } = useContext()+ const { store } = useContext()+ const router = useRouter()const sketchFabfailure = ref(false)const activeTab = ref(0)const isReportFormVisible = ref(false)diff --git a/test/e2e/search.spec.js b/test/e2e/search.spec.jsindex 1b2428f48..25820ab8a 100644--- a/test/e2e/search.spec.js+++ b/test/e2e/search.spec.js@@ -68,3 +68,13 @@ test('navigates to the image detail page correctly', async ({ page }) => {// Renders the breadcrumb linkawait expect(page.locator('text="Back to search results"')).toBeVisible()})++test('the Back to search results link returns to the search page', async ({+ page,+}) => {+ const url = '/search/image?q=honey'+ await page.goto(url)+ await page.locator('figure a').first().click()+ await page.locator('text="Back to search results"').click()+ await expect(page).toHaveURL(url)+})diff --git a/test/unit/specs/components/ImageDetails/photo-details.spec.js b/test/unit/specs/components/ImageDetails/v-photo-details.spec.jssimilarity index 91%rename from test/unit/specs/components/ImageDetails/photo-details.spec.jsrename to test/unit/specs/components/ImageDetails/v-photo-details.spec.jsindex 3128235dd..d247b058a 100644--- a/test/unit/specs/components/ImageDetails/photo-details.spec.js+++ b/test/unit/specs/components/ImageDetails/v-photo-details.spec.js@@ -9,15 +9,17 @@ import { createLocalVue } from '@vue/test-utils'import Vuex from 'vuex'import VueI18n from 'vue-i18n'import messages from '~/locales/en.json'+const i18n = new VueI18n({locale: 'en',fallbackLocale: 'en',messages: { en: messages },})+describe('PhotoDetails', () => {let options = nulllet props = null- let dispatchMock, routeMock, routerMock+ let dispatchMockconst localVue = createLocalVue()localVue.use(Vuex)localVue.use(VueI18n)@@ -43,11 +45,7 @@ describe('PhotoDetails', () => {}dispatchMock = jest.fn()- routerMock = {- push: jest.fn(),- back: jest.fn(),- }- routeMock = {+ const routeMock = {params: {location: window.scrollY,},@@ -73,7 +71,6 @@ describe('PhotoDetails', () => {$nuxt: {context: {route: routeMock,- router: routerMock,store: storeMock,},},@@ -131,14 +128,6 @@ describe('PhotoDetails', () => {expect(screen.queryAllByText(props.image.title).length).toEqual(1)})- it('redirects back when clicking on the back to results link', async () => {- render(VPhotoDetails, options)- const linkBack = screen.queryByText(/back/i)- await fireEvent.click(linkBack)-- expect(routerMock.back).toHaveBeenCalled()- })-it('should toggle visibility of report form on report button click', async () => {render(VPhotoDetails, options)await fireEvent.click(screen.queryByRole('button', { name: /report/i }))