From 47de4c50d16e52de1940588f4b0816673e179997 Mon Sep 17 00:00:00 2001 From: Casey Dyer Date: Mon, 16 May 2022 15:05:01 -0700 Subject: [PATCH 1/5] fix: resolved vue errors on load: missing title and wrong boolean prop --- src/components/Lend/LoanSearch/LoanSearchInterface.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Lend/LoanSearch/LoanSearchInterface.vue b/src/components/Lend/LoanSearch/LoanSearchInterface.vue index 4a266b890c..608c29891d 100644 --- a/src/components/Lend/LoanSearch/LoanSearchInterface.vue +++ b/src/components/Lend/LoanSearch/LoanSearchInterface.vue @@ -6,7 +6,12 @@ Filter & Sort - + @@ -29,7 +34,7 @@ :key="loan.id" :loan="loan" loan-card-type="ListLoanCard" - rounded-corners="true" + :rounded-corners="true" /> From a40276e694e7510559d818a6ccc3170534e6823a Mon Sep 17 00:00:00 2001 From: Casey Dyer Date: Mon, 16 May 2022 15:05:30 -0700 Subject: [PATCH 2/5] fix: added missing mocked function for auth0 that was causing error on load locally --- src/util/KvAuth0.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/KvAuth0.js b/src/util/KvAuth0.js index 4fc40311b0..54d85ddb35 100644 --- a/src/util/KvAuth0.js +++ b/src/util/KvAuth0.js @@ -357,6 +357,7 @@ export const MockKvAuth0 = { getKivaId: () => undefined, getLastLogin: () => 0, getMfaEnrollToken: () => Promise.resolve({}), + fakeAuthAllowed: () => undefined, getFakeAuthCookieValue: () => undefined, getFakeIdTokenPayload: () => undefined, getSyncCookieValue: () => null, From c972bc4962d30ef737ecbba30ce48e36efb14a25 Mon Sep 17 00:00:00 2001 From: Casey Dyer Date: Mon, 16 May 2022 15:35:50 -0700 Subject: [PATCH 3/5] feat: created new loan search utils file --- .../Lend/LoanSearch/LoanSearchFilter.vue | 23 ++++--------------- src/util/loanSearchUtils.js | 21 +++++++++++++++++ test/unit/specs/util/loanSearchUtils.spec.js | 21 +++++++++++++++++ 3 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 src/util/loanSearchUtils.js create mode 100644 test/unit/specs/util/loanSearchUtils.spec.js diff --git a/src/components/Lend/LoanSearch/LoanSearchFilter.vue b/src/components/Lend/LoanSearch/LoanSearchFilter.vue index 9d91b9b70c..ea80c4c055 100644 --- a/src/components/Lend/LoanSearch/LoanSearchFilter.vue +++ b/src/components/Lend/LoanSearch/LoanSearchFilter.vue @@ -87,7 +87,7 @@ import { import KvAccordionItem from '@/components/Kv/KvAccordionItem'; import { mdiClose, mdiArrowRight } from '@mdi/js'; import LoanSearchGenderFilter from '@/components/Lend/LoanSearch/LoanSearchGenderFilter'; -import updateLoanSearchMutation from '@/graphql/mutation/updateLoanSearchState.graphql'; +import { updateSearchState } from '@/util/loanSearchUtils'; import KvCheckbox from '~/@kiva/kv-components/vue/KvCheckbox'; import KvMaterialIcon from '~/@kiva/kv-components/vue/KvMaterialIcon'; @@ -124,7 +124,7 @@ export default { }, async getAllCountries() { // data pull only from production endpoint, - // not implmented with a component until design path + // not implemented with a component until design path // with product is completed. const countryFacets = await fetchCountryFacets(this.apollo); this.allCountries = countryFacets.map(cf => cf.country.name); @@ -144,19 +144,8 @@ export default { // console.log('from updateQuery', updatedQueryFilters); // console.log('new query ran, yes!'); // }, - // TODO: Extract to plugin/util for use in each filter component - updateSearchState() { - return this.apollo.mutate({ - mutation: updateLoanSearchMutation, - variables: { - searchParams: { - ...this.loanQueryFilters - } - } - }); - } }, - mounted() { + async mounted() { this.getSectors(); this.getAllCountries(); @@ -164,10 +153,8 @@ export default { // Each Filter type will use the updateSearchState method to set this when filters are selected this.loanQueryFilters = { countryIsoCode: ['US'], sectorId: [9] }; console.log('mounted query ran:', this.loanQueryFilters); - // this.updateSearchState(); - this.updateSearchState().then(updateResponse => { - console.log(updateResponse); - }); + const response = await updateSearchState(this.apollo, this.loanQueryFilters); + console.log('mounted query response:', response); }, computed: { // queryFilters() { diff --git a/src/util/loanSearchUtils.js b/src/util/loanSearchUtils.js new file mode 100644 index 0000000000..ee3b69a99d --- /dev/null +++ b/src/util/loanSearchUtils.js @@ -0,0 +1,21 @@ +// TODO: remove this disabled eslint rule once there's another function +/* eslint-disable import/prefer-default-export */ +import updateLoanSearchMutation from '@/graphql/mutation/updateLoanSearchState.graphql'; + +/** + * Updates the search state using the provided apollo client and filters + * + * @param {Object} apollo The apollo client instance + * @param {Object} loanQueryFilters The filters for the loan query + * @returns Returns Promise for the results of the mutation + */ +export async function updateSearchState(apollo, loanQueryFilters) { + return apollo.mutate({ + mutation: updateLoanSearchMutation, + variables: { + searchParams: { + ...loanQueryFilters + } + } + }); +} diff --git a/test/unit/specs/util/loanSearchUtils.spec.js b/test/unit/specs/util/loanSearchUtils.spec.js new file mode 100644 index 0000000000..1d75622735 --- /dev/null +++ b/test/unit/specs/util/loanSearchUtils.spec.js @@ -0,0 +1,21 @@ +import { updateSearchState } from '@/util/loanSearchUtils'; +import updateLoanSearchMutation from '@/graphql/mutation/updateLoanSearchState.graphql'; + +describe('loanSearchUtils.js', () => { + describe('updateSearchState', () => { + it('should call apollo with the provided filters and return results', async () => { + const mockResult = 1; + const apollo = { mutate: jest.fn(() => Promise.resolve(mockResult)) }; + const filters = { countryIsoCode: ['US'], sectorId: [9] }; + const params = { + mutation: updateLoanSearchMutation, + variables: { searchParams: filters } + }; + + const result = await updateSearchState(apollo, filters); + + expect(apollo.mutate).toHaveBeenCalledWith(params); + expect(result).toBe(mockResult); + }); + }); +}); From 1b8a4742d42c6505d0de4427024abc1f7d19901a Mon Sep 17 00:00:00 2001 From: Casey Dyer Date: Mon, 16 May 2022 16:23:37 -0700 Subject: [PATCH 4/5] fix: include aria-label for lightbox but not visible title --- src/components/Lend/LoanSearch/LoanSearchInterface.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/Lend/LoanSearch/LoanSearchInterface.vue b/src/components/Lend/LoanSearch/LoanSearchInterface.vue index 608c29891d..1465df5b0d 100644 --- a/src/components/Lend/LoanSearch/LoanSearchInterface.vue +++ b/src/components/Lend/LoanSearch/LoanSearchInterface.vue @@ -9,9 +9,12 @@ + From 7f083f19211df0c2ca8361f7eb40856f25c55a3a Mon Sep 17 00:00:00 2001 From: Casey Dyer Date: Mon, 16 May 2022 16:24:44 -0700 Subject: [PATCH 5/5] fix: changed undefined fakeAuthAllowed mock to false --- src/util/KvAuth0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/KvAuth0.js b/src/util/KvAuth0.js index 54d85ddb35..685cc9bfe0 100644 --- a/src/util/KvAuth0.js +++ b/src/util/KvAuth0.js @@ -357,7 +357,7 @@ export const MockKvAuth0 = { getKivaId: () => undefined, getLastLogin: () => 0, getMfaEnrollToken: () => Promise.resolve({}), - fakeAuthAllowed: () => undefined, + fakeAuthAllowed: () => false, getFakeAuthCookieValue: () => undefined, getFakeIdTokenPayload: () => undefined, getSyncCookieValue: () => null,