Skip to content

Commit

Permalink
Fix issue with navigation getting stuck in a circular loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lfarrell committed Dec 8, 2023
1 parent 44b2d5a commit ad3c998
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
13 changes: 0 additions & 13 deletions static/js/vue-cdr-access/src/components/displayWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Top level component for full record pages with searching/browsing, including Adm
import notAvailable from "@/components/error_pages/notAvailable.vue";
import notFound from '@/components/error_pages/notFound.vue';
import get from 'axios';
import isEmpty from 'lodash.isempty';
import analyticsUtils from '../mixins/analyticsUtils';
import errorUtils from '../mixins/errorUtils';
import imageUtils from '../mixins/imageUtils';
Expand Down Expand Up @@ -189,9 +188,6 @@ Top level component for full record pages with searching/browsing, including Adm
this.min_created_year = response.data.minSearchYear;
this.filter_parameters = response.data.filterParameters;
this.is_page_loading = false;
if (!isEmpty(this.$route.query)) {
this.updateUrl();
}
}).catch(error => {
this.setErrorResponse(error);
this.is_page_loading = false;
Expand Down Expand Up @@ -237,15 +233,6 @@ Top level component for full record pages with searching/browsing, including Adm
}
},

updateUrl() {
let params = this.setTypes();
this.$router.push({ name: 'displayRecords', query: params }).catch((e) => {
if (this.nonDuplicateNavigationError(e)) {
throw e;
}
});
},

hasSearchQuery() {
let query_params = this.$route.query;
return Object.keys(query_params).some(key => query_params[key]
Expand Down
52 changes: 1 addition & 51 deletions static/js/vue-cdr-access/tests/unit/displayWrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ describe('displayWrapper.vue', () => {
await router.push(`/record/${response.container.id}`);
mountApp();
wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();

Expand All @@ -85,23 +84,19 @@ describe('displayWrapper.vue', () => {
mountApp();

wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();
expect(wrapper.vm.search_method).toEqual('searchJson');
expect(wrapper.vm.$router.currentRoute.value.query.types).toEqual('Work,File');
});

it("uses the correct search parameters for non admin works only browse", async () => {
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/?works_only=false');
mountApp();

wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();
expect(wrapper.vm.search_method).toEqual('listJson');
expect(wrapper.vm.$router.currentRoute.value.query.types).toEqual('Work,Folder,Collection,File');
});

it("uses the correct search parameters if search text is specified", async () => {
Expand All @@ -111,11 +106,9 @@ describe('displayWrapper.vue', () => {
});

wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();
expect(wrapper.vm.search_method).toEqual('searchJson');
expect(wrapper.vm.$router.currentRoute.value.query.types).toEqual('Work,Folder,Collection,File');
});

it("uses the correct search parameters if facet parameter is specified", async () => {
Expand All @@ -125,11 +118,9 @@ describe('displayWrapper.vue', () => {
});

wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();
expect(wrapper.vm.search_method).toEqual('searchJson');
expect(wrapper.vm.$router.currentRoute.value.query.types).toEqual('Work,Folder,Collection,File');
});

it("uses the correct parameters for admin unit browse", async () => {
Expand Down Expand Up @@ -159,55 +150,19 @@ describe('displayWrapper.vue', () => {
});

wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();
expect(wrapper.vm.search_method).toEqual('listJson');
expect(wrapper.vm.$router.currentRoute.value.query.types).toEqual('Work,Folder,Collection,File');
expect(wrapper.find(".container-note").exists()).toBe(true);
expect(wrapper.find('#browse-display-type').exists()).toBe(true);
});

it("updates the url when work type changes", async () => {
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a?browse_type=gallery-display');
mountApp({
container_info: {
briefObject: {
type: 'Collection',
objectPath: [
{
pid: 'collections',
name: 'Content Collections Root',
container: true
},
{
pid: '353ee09f-a4ed-461e-a436-18a1bee77b01',
name: 'testAdminUnit',
container: true
},
{
pid: 'fc77a9be-b49d-4f4e-b656-1644c9e964fc',
name: 'testCollection',
container: true
}
]
},
resourceType: 'Collection'
}
});

wrapper.vm.updateUrl();
await flushPromises();
expect(wrapper.vm.$router.currentRoute.value.query.types).toEqual('Work,Folder,Collection,File');
});

it("displays a 'works only' option if the 'works only' box is checked and no records are works", async () => {
stubQueryResponse(`searchJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+`, response);
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a?works_only=true');
mountApp();

wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();
let works_only = wrapper.find('.container-note');
Expand All @@ -218,10 +173,7 @@ describe('displayWrapper.vue', () => {
it("does not display a 'works only' option if the 'works only' box is not checked and no records are works", async () => {
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a?works_only=false');
mountApp();
// wrapper.vm.getBriefObject();
// wrapper.vm.updateUrl();
// wrapper.vm.retrieveSearchResults();
// await flushPromises();

let works_only = wrapper.find('.container-note');
expect(works_only.exists()).toBe(false)
});
Expand Down Expand Up @@ -253,7 +205,6 @@ describe('displayWrapper.vue', () => {
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a');
mountApp();
wrapper.vm.getBriefObject();
wrapper.vm.updateUrl();
wrapper.vm.retrieveSearchResults();
await flushPromises();

Expand Down Expand Up @@ -357,7 +308,6 @@ describe('displayWrapper.vue', () => {
let num_facets = wrapper.vm.$store.state.possibleFacetFields.length;
expect(num_facets).toBeGreaterThan(0);
expect(wrapper.vm.$store.state.possibleFacetFields.indexOf('unit')).toEqual(-1);
expect(wrapper.vm.$route.query.facetSelect.indexOf('unit')).toEqual(-1);

// Trigger works only filter and make sure that the set of facets does not change
await wrapper.find('#works-only').trigger('click');
Expand Down

0 comments on commit ad3c998

Please sign in to comment.