From a6e0bbde46df8542fdca87f2fec9c041dd99d564 Mon Sep 17 00:00:00 2001 From: FrankRua Date: Thu, 20 Oct 2022 10:35:08 -0400 Subject: [PATCH 1/4] Deploy to both buckets --- azure-pipelines.yml | 283 ++++++++++++++++++++++---------------------- 1 file changed, 144 insertions(+), 139 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4767a7739..6af6424c1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,6 +1,6 @@ trigger: branches: - include: [ develop, release/* ] + include: [develop, release/*] paths: exclude: - deployment/* @@ -8,7 +8,7 @@ trigger: - "*" pr: branches: - include: [ '*' ] + include: ["*"] paths: exclude: - deployment/* @@ -35,144 +35,149 @@ variables: stages: # PR's - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: - - stage: TestPr - displayName: Run Unit Tests For PullRequest - jobs: - - template: templates/digital/vue-jest-run-unit-tests.yml@AzureDevOps - parameters: - nodeContainer: node - npmLocation: $(Build.SourcesDirectory) - testResultsFile: junit.xml - summaryFileLocation: $(Build.SourcesDirectory)/coverage/cobertura-coverage.xml + - stage: TestPr + displayName: Run Unit Tests For PullRequest + jobs: + - template: templates/digital/vue-jest-run-unit-tests.yml@AzureDevOps + parameters: + nodeContainer: node + npmLocation: $(Build.SourcesDirectory) + testResultsFile: junit.xml + summaryFileLocation: $(Build.SourcesDirectory)/coverage/cobertura-coverage.xml + - # Dev Build/Deploy - ${{ else }}: - - stage: Dev - condition: eq(variables['Build.SourceBranch'], variables['dev-branch'] ) - variables: - - group: FixMyGlassDev - jobs: - - deployment: devBuildDeployment - displayName: Build and Deploy FMG - Dev - environment: digitalCloud-dev - container: node - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - checkout: self - clean: true - - template: templates/digital/step-build-vue.yml@AzureDevOps - parameters: - buildOutputDir: dist - environment: Dev - - template: templates/digital/step-deploy-vue.yml@AzureDevOps - parameters: - artifactName: vueDistDev - awsProfile: $(devDeploymentProfile) - outputPath: /fmg/ - deployBuckets: - safelite-dev-fmg-us-east-1: - clearFolder: true - deployFolder: '' - region: us-east-1 - appDeployVariables: - __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) - __VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__) - __VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__) - __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) - indexDeployVariables: - __VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__) - __VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__) - cfDistributionId: $(cfDistributionId) + # Dev Build/Deploy + - stage: Dev + condition: eq(variables['Build.SourceBranch'], variables['dev-branch'] ) + variables: + - group: FixMyGlassDev + jobs: + - deployment: devBuildDeployment + displayName: Build and Deploy FMG - Dev + environment: digitalCloud-dev + container: node + workspace: + clean: all + strategy: + runOnce: + deploy: + steps: + - checkout: self + clean: true + - template: templates/digital/step-build-vue.yml@AzureDevOps + parameters: + buildOutputDir: dist + environment: Dev + - template: templates/digital/step-deploy-vue.yml@AzureDevOps + parameters: + artifactName: vueDistDev + awsProfile: $(devDeploymentProfile) + outputPath: /fmg/ + deployBuckets: + safelite-dev-fmg-us-east-1: + clearFolder: true + deployFolder: "" + region: us-east-1 + safelite-dev-fmg-us-east-2: + clearFolder: true + deployFolder: "" + region: us-east-2 + appDeployVariables: + __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) + __VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__) + __VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__) + __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) + indexDeployVariables: + __VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__) + __VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__) + cfDistributionId: $(cfDistributionId) - # QA Build/Deploy - - stage: Qa - condition: eq(variables['Build.SourceBranch'], variables['qa-branch'] ) - variables: - - group: FixMyGlassQa - jobs: - - deployment: qaBuildDeployment - displayName: Build and Deploy FMG - QA - environment: NoApproval-All - container: node - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - checkout: self - clean: true - - template: templates/digital/step-build-vue.yml@AzureDevOps - parameters: - buildOutputDir: dist - environment: Qa - - template: templates/digital/step-deploy-vue.yml@AzureDevOps - parameters: - artifactName: vueDistQa - awsProfile: $(qaDeploymentProfile) - outputPath: /fmg/ - deployBuckets: - safelite-qa-fmg-us-east-1: - clearFolder: true - deployFolder: '' - region: us-east-1 - appDeployVariables: - __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) - __VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__) - __VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__) - __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) - indexDeployVariables: - __VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__) - __VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__) - cfDistributionId: $(cfDistributionId) + # QA Build/Deploy + - stage: Qa + condition: eq(variables['Build.SourceBranch'], variables['qa-branch'] ) + variables: + - group: FixMyGlassQa + jobs: + - deployment: qaBuildDeployment + displayName: Build and Deploy FMG - QA + environment: NoApproval-All + container: node + workspace: + clean: all + strategy: + runOnce: + deploy: + steps: + - checkout: self + clean: true + - template: templates/digital/step-build-vue.yml@AzureDevOps + parameters: + buildOutputDir: dist + environment: Qa + - template: templates/digital/step-deploy-vue.yml@AzureDevOps + parameters: + artifactName: vueDistQa + awsProfile: $(qaDeploymentProfile) + outputPath: /fmg/ + deployBuckets: + safelite-qa-fmg-us-east-1: + clearFolder: true + deployFolder: "" + region: us-east-1 + appDeployVariables: + __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) + __VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__) + __VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__) + __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) + indexDeployVariables: + __VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__) + __VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__) + cfDistributionId: $(cfDistributionId) - # Prod Build/Deploy - - stage: Prod - condition: succeeded('Qa') - variables: - - group: FixMyGlassProd - jobs: - - deployment: prodBuildDeployment - displayName: Build and Deploy FMG - Prod - environment: digitalCloud-prod - container: node - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - checkout: self - clean: true - - template: templates/digital/step-build-vue.yml@AzureDevOps - parameters: - buildOutputDir: dist - environment: Prod - - template: templates/digital/step-deploy-vue.yml@AzureDevOps - parameters: - artifactName: vueDistProd - awsProfile: $(prodDeploymentProfile) - outputPath: /fmg/ - deployBuckets: - safelite-prod-fmg-us-east-1: - clearFolder: true - deployFolder: '' - region: us-east-1 - appDeployVariables: - __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) - __VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__) - __VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__) - __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) - indexDeployVariables: - __VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__) - __VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__) - cfDistributionId: $(cfDistributionId) - - template: templates/digital/auto-tag.yml@AzureDevOps - parameters: - dependsOn: prodBuildDeployment - userName: SafeliteAzureDevops - userEmail: githubazuredevops@safelite.com \ No newline at end of file + # Prod Build/Deploy + - stage: Prod + condition: succeeded('Qa') + variables: + - group: FixMyGlassProd + jobs: + - deployment: prodBuildDeployment + displayName: Build and Deploy FMG - Prod + environment: digitalCloud-prod + container: node + workspace: + clean: all + strategy: + runOnce: + deploy: + steps: + - checkout: self + clean: true + - template: templates/digital/step-build-vue.yml@AzureDevOps + parameters: + buildOutputDir: dist + environment: Prod + - template: templates/digital/step-deploy-vue.yml@AzureDevOps + parameters: + artifactName: vueDistProd + awsProfile: $(prodDeploymentProfile) + outputPath: /fmg/ + deployBuckets: + safelite-prod-fmg-us-east-1: + clearFolder: true + deployFolder: "" + region: us-east-1 + appDeployVariables: + __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) + __VUE_APP_GOOGLE_PLACES_API_KEY__: $(__VUE_APP_GOOGLE_PLACES_API_KEY__) + __VUE_APP_HERITAGE_FUNNEL__: $(__VUE_APP_HERITAGE_FUNNEL__) + __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) + indexDeployVariables: + __VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__: $(__VUE_APP_GOOGLE_TAG_MANAGER_SCRIPT_BODY__) + __VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__: $(__VUE_APP_GOOGLE_TAG_MANAGER_NOSCRIPT_FRAME_SRC__) + cfDistributionId: $(cfDistributionId) + - template: templates/digital/auto-tag.yml@AzureDevOps + parameters: + dependsOn: prodBuildDeployment + userName: SafeliteAzureDevops + userEmail: githubazuredevops@safelite.com From 7e437cfa64fc2a390bce8027292a74139f79f6ed Mon Sep 17 00:00:00 2001 From: FrankRua Date: Thu, 20 Oct 2022 10:35:52 -0400 Subject: [PATCH 2/4] Test branch --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6af6424c1..09627faa7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,7 +49,7 @@ stages: - ${{ else }}: # Dev Build/Deploy - stage: Dev - condition: eq(variables['Build.SourceBranch'], variables['dev-branch'] ) + condition: eq(variables['Build.SourceBranch'], variables['test-branch'] ) variables: - group: FixMyGlassDev jobs: From 9a6d3202427df9f5ee06fa72e09baed64fa5e2e7 Mon Sep 17 00:00:00 2001 From: FrankRua Date: Thu, 20 Oct 2022 10:43:31 -0400 Subject: [PATCH 3/4] switch back to dev branch --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 09627faa7..6af6424c1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,7 +49,7 @@ stages: - ${{ else }}: # Dev Build/Deploy - stage: Dev - condition: eq(variables['Build.SourceBranch'], variables['test-branch'] ) + condition: eq(variables['Build.SourceBranch'], variables['dev-branch'] ) variables: - group: FixMyGlassDev jobs: From b6bfc178ed4d020ff124df30a429217a02435473 Mon Sep 17 00:00:00 2001 From: Adam Caouette Date: Fri, 21 Oct 2022 15:46:13 -0400 Subject: [PATCH 4/4] CSR-867: new simplified updates to match updates in Parts Service API --- jest.config.js | 2 +- src/helpers/damage-helper.js | 6 +- src/helpers/damage-helper.spec.js | 12 +- .../capability-questions.vue | 18 +- .../molding-questions/molding-questions.vue | 12 +- src/layouts/part-questions/part-questions.vue | 14 +- .../vehicle-damage/vehicle-damage.spec.js | 28 +-- src/layouts/vehicle-damage/vehicle-damage.vue | 44 ++--- .../glass-part-question.spec.js | 34 ++-- .../glass-part-question.vue | 29 +-- .../vehicle-parts/vehicle-parts.spec.js | 16 +- src/layouts/vehicle-parts/vehicle-parts.vue | 36 ++-- src/mixins/vehicle-questions-mixin.js | 12 +- src/mixins/vehicle-questions-mixin.spec.js | 184 +++++++++--------- src/store/index.js | 38 +++- 15 files changed, 253 insertions(+), 232 deletions(-) diff --git a/jest.config.js b/jest.config.js index ded486df9..80b382c5a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -28,7 +28,7 @@ module.exports = { testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { global: { - statements: 85, + statements: 83, // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 }, }, diff --git a/src/helpers/damage-helper.js b/src/helpers/damage-helper.js index ed353e51b..55d10738d 100644 --- a/src/helpers/damage-helper.js +++ b/src/helpers/damage-helper.js @@ -19,7 +19,7 @@ export function getDamageString() { if (damageLocations.length > 1) { returnString = "match" } else { - switch(damageLocations[0]?.glassLocation) { + switch(damageLocations[0]?.location) { case "Windshield": returnString = "windshield" break; @@ -36,7 +36,7 @@ export function getDamageString() { export function getIsWindshieldOnly () { const damageLocations = store.getters.damage.glassToReplace; - const returnString = damageLocations.length === 1 && damageLocations[0]?.glassLocation === "Windshield" ? "windshield" : "glass"; + const returnString = damageLocations.length === 1 && damageLocations[0]?.location === "Windshield" ? "windshield" : "glass"; return returnString; } @@ -56,7 +56,7 @@ export async function isGlassAvailableForCarId(carId){ } for(const option of currentGlassOptions){ - if(!newGlassOptions.data[optionsMap[option.glassLocation]].availableReplacementOptions.includes(option.glassName)){ + if(!newGlassOptions.data[optionsMap[option.location]].availableReplacementOptions.includes(option.name)){ return false; } } diff --git a/src/helpers/damage-helper.spec.js b/src/helpers/damage-helper.spec.js index 210bf96cc..2a46978dc 100644 --- a/src/helpers/damage-helper.spec.js +++ b/src/helpers/damage-helper.spec.js @@ -16,7 +16,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ it("Should return match when multiple selected damage options are in the store", () => { // Arrange / Act - store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "windshield"}, {glassLocation: "Passenger", glassName: "sideWindow"}]; + store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}, {location: "Passenger", name: "sideWindow"}]; const damage = getDamageString(); @@ -29,7 +29,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ it("Should return windshield when Windshield is the only selected damage option in the store", () => { // Arrange / Act - store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "windshield"}]; + store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}]; const damage = getDamageString(); @@ -42,7 +42,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ it("Should return side window when Driver or Passenger is the only selected damage option in the store", () => { // Arrange / Act - store.getters.damage.glassToReplace = [{glassLocation: "Passenger", glassName: "sideWindow"}]; + store.getters.damage.glassToReplace = [{location: "Passenger", name: "sideWindow"}]; const damage = getDamageString(); @@ -55,7 +55,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ it("Should return rear window when Rear is the only selected damage option in the store", () => { // Arrange / Act - store.getters.damage.glassToReplace = [{glassLocation: "Rear", glassName: "rear"}]; + store.getters.damage.glassToReplace = [{location: "Rear", name: "rear"}]; const damage = getDamageString(); @@ -67,7 +67,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ describe("damage-helper.js", () => { it("Should return true if no mismatches between each array exist", async () => { // Arrange - store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "windshield"}]; + store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}]; // Act const isGlassAvailable = await isGlassAvailableForCarId(); @@ -80,7 +80,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ describe("damage-helper.js", () => { it("Should return false if any mismatches between each array exist", async () => { // Arrange - store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "sideWindow"}]; + store.getters.damage.glassToReplace = [{location: "Windshield", name: "sideWindow"}]; const isGlassAvailable = await isGlassAvailableForCarId(); diff --git a/src/layouts/capability-questions/capability-questions.vue b/src/layouts/capability-questions/capability-questions.vue index 39b96c361..6491a76df 100644 --- a/src/layouts/capability-questions/capability-questions.vue +++ b/src/layouts/capability-questions/capability-questions.vue @@ -11,7 +11,7 @@ v-bind:isDismissible="false" />
@@ -86,7 +86,7 @@ export default { return this.getCmsContent("AdditionalPartsQuestionsAlert", "BodyText"); }, windshieldPart() { - return this.pageData.partsOrQuestions.find(x => x.glassLocation === damageLocationsSelected.WINDSHIELD); + return this.pageData.partsOrQuestions.find(x => x.location === damageLocationsSelected.WINDSHIELD); }, windshieldPartInfo() { return this.windshieldPart.parts[0]; @@ -122,8 +122,8 @@ export default { const selectedAnswerResult2 = this.getCorrespondingAnswerResult2(glass.answerData.answerResult); return { - glassLocation: glass.glassLocation, - glassName: glass.glassName, + location: glass.location, + name: glass.name, result: glass.answerData.answerResult, result1: glass.answerData.answerResult, result2: selectedAnswerResult2, @@ -143,10 +143,10 @@ export default { // get parts from the capabilityQuestionAnswers let partsOrQuestions = this.pageData.partsOrQuestions; for (let answer of capabilityQuestionsAnswersArray) { - const correspondingPart = partsOrQuestions.find(partOrQuestion => partOrQuestion.glassLocation === answer.glassLocation); - const partFromCapabilityQuestionAnswer = (await this.dispatchStoreAction(storeActions.GET_PART_FROM_CAPABILITY_QUESTION_ANSWER, answer.glassLocation, false)).data; + const correspondingPart = partsOrQuestions.find(partOrQuestion => partOrQuestion.location === answer.location); + const partFromCapabilityQuestionAnswer = (await this.dispatchStoreAction(storeActions.GET_PART_FROM_CAPABILITY_QUESTION_ANSWER, answer.location, false)).data; - partsOrQuestions.find(partOrQuestion => partOrQuestion.glassLocation === answer.glassLocation).parts = partFromCapabilityQuestionAnswer; + partsOrQuestions.find(partOrQuestion => partOrQuestion.location === answer.location).parts = partFromCapabilityQuestionAnswer; } this.navigateForward(partsOrQuestions); @@ -239,7 +239,7 @@ export default { }); // Update the key to re-render this part's question-chain component - this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].glassLocation + this.capabilityQuestionsData[gpIndex].glassName + Date.now().toString(); + this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].location + this.capabilityQuestionsData[gpIndex].name + Date.now().toString(); // handle suppressing downstream in this question chain @@ -325,7 +325,7 @@ export default { }); // Update the key to re-render this part's question-chain component - this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].glassLocation + this.capabilityQuestionsData[gpIndex].glassName + Date.now().toString(); + this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].location + this.capabilityQuestionsData[gpIndex].name + Date.now().toString(); } }); diff --git a/src/layouts/molding-questions/molding-questions.vue b/src/layouts/molding-questions/molding-questions.vue index 50cfe42c2..c73c6e5e1 100644 --- a/src/layouts/molding-questions/molding-questions.vue +++ b/src/layouts/molding-questions/molding-questions.vue @@ -23,7 +23,7 @@
{ return { - glassLocation: glass.glassLocation, - glassName: glass.glassName, + location: glass.location, + name: glass.name, partNum: glass.answerData.answerResult, answeredQuestions: glass.answerData.answeredQuestions, isSuppressedPart: glass.isSuppressedPart, @@ -152,7 +152,7 @@ export default { let partsOrQuestions = this.pageData.partsOrQuestions; for (let answer of questionAnswersArray) { partsOrQuestions.find(partOrQuestion => { - return partOrQuestion.glassLocation === answer.glassLocation && partOrQuestion.glassName === answer.glassName; + return partOrQuestion.location === answer.location && partOrQuestion.name === answer.name; }).parts[0].childParts = [ { partNumber: answer.partNum @@ -250,7 +250,7 @@ export default { }); // Update the key to re-render this part's question-chain component - this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].glassLocation + this.moldingQuestionsData[gpIndex].glassName + Date.now().toString(); + this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].location + this.moldingQuestionsData[gpIndex].name + Date.now().toString(); // handle suppressing downstream in this question chain @@ -336,7 +336,7 @@ export default { }); // Update the key to re-render this part's question-chain component - this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].glassLocation + this.moldingQuestionsData[gpIndex].glassName + Date.now().toString(); + this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].location + this.moldingQuestionsData[gpIndex].name + Date.now().toString(); } diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index 131a70f44..0b0cc0165 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -23,7 +23,7 @@
{ return { - glassLocation: glass.glassLocation, - glassName: glass.glassName, + location: glass.location, + name: glass.name, result: glass.answerData.answerResult, answeredQuestions: glass.answerData.answeredQuestions, isSuppressedPart: glass.isSuppressedPart, @@ -154,9 +154,9 @@ export default { return this.$refs.funnelFooter.removeLoader(); }); - const glassNameAndPartsForStore = partsLookup.data.glassNameAndParts; + const glassPiecePartsForStore = partsLookup.data.glassPieceParts; - this.navigateForward(glassNameAndPartsForStore); + this.navigateForward(glassPiecePartsForStore); }, handleAnswerUpdates(answer) { // only runs when all questions in a question-chain have been answered @@ -246,7 +246,7 @@ export default { }); // Update the key to re-render this part's question-chain component - this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].glassLocation + this.partsQuestionsData[gpIndex].glassName + Date.now().toString(); + this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].location + this.partsQuestionsData[gpIndex].name + Date.now().toString(); // handle suppressing downstream in this question chain @@ -332,7 +332,7 @@ export default { }); // Update the key to re-render this part's question-chain component - this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].glassLocation + this.partsQuestionsData[gpIndex].glassName + Date.now().toString(); + this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].location + this.partsQuestionsData[gpIndex].name + Date.now().toString(); } diff --git a/src/layouts/vehicle-damage/vehicle-damage.spec.js b/src/layouts/vehicle-damage/vehicle-damage.spec.js index 7791dff37..27778feed 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.spec.js +++ b/src/layouts/vehicle-damage/vehicle-damage.spec.js @@ -81,8 +81,8 @@ describe("vehicle-damage.vue", () => { //Arrange const partsData = { partsOrQuestions: [{ - glassName: "Single", - glassLocation: "Windshield", + name: "Single", + location: "Windshield", parts: null, partQuestions: [{ questionSequence: 1, @@ -144,8 +144,8 @@ describe("vehicle-damage.vue", () => { wrapper.vm.selectedRearReplaceOptions = ["Stationary"]; - const expectedGlassToReplace = [{ glassLocation: "Windshield", glassName: "Single" }, { glassLocation: "Driver", glassName: "Back" }, - { glassLocation: "Passenger", glassName: "Quarter" }, { glassLocation: "Rear", glassName: "Stationary" }]; + const expectedGlassToReplace = [{ location: "Windshield", name: "Single" }, { location: "Driver", name: "Back" }, + { location: "Passenger", name: "Quarter" }, { location: "Rear", name: "Stationary" }]; //Act vehicleDamage.beforeRouteEnter.call( @@ -168,8 +168,8 @@ describe("vehicle-damage.vue", () => { const partsData = { partsOrQuestions: [ { - glassLocation: "Windshield", - glassName: "Single", + location: "Windshield", + name: "Single", partQuestions: null, parts: [ { @@ -189,8 +189,8 @@ describe("vehicle-damage.vue", () => { ] }, { - glassName: "Stationary", - glassLocation: "Rear", + name: "Stationary", + location: "Rear", parts: [ { partNumber: "DB09626GTYN", @@ -235,7 +235,7 @@ describe("vehicle-damage.vue", () => { selectedWindshieldDamageType: "Replace" }; - const expectedGlassToReplace = [{ glassLocation: "Windshield", glassName: "Single" },]; + const expectedGlassToReplace = [{ location: "Windshield", name: "Single" },]; //Act vehicleDamage.beforeRouteEnter.call( @@ -509,7 +509,7 @@ describe("vehicle-damage.vue", () => { (c) => c(wrapper.vm) ); - store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation }] }, isRepair: true }; + store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation }] }, isRepair: true }; var glassSelections = wrapper.vm.getDamageLocationsFromStore(); @@ -553,7 +553,7 @@ describe("vehicle-damage.vue", () => { eventBusItem: jest.fn(), damage: { - glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }], + glassToReplace: [{ location: damageLocation, name: damageName }], isRepair: isRepair, numberOfChips: 2 }, @@ -583,7 +583,7 @@ describe("vehicle-damage.vue", () => { (c) => c(wrapper.vm) ); - store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }] }, isRepair: true }; + store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation, name: damageName }] }, isRepair: true }; var glassSelections = wrapper.vm.getDriverSideReplaceOptionsFromStore(); @@ -610,7 +610,7 @@ describe("vehicle-damage.vue", () => { (c) => c(wrapper.vm) ); - store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }] }, isRepair: true }; + store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation, name: damageName }] }, isRepair: true }; var glassSelections = wrapper.vm.getPassengerSideReplaceOptionsFromStore(); @@ -634,7 +634,7 @@ describe("vehicle-damage.vue", () => { (c) => c(wrapper.vm) ); - store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }] }, isRepair: true }; + store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation, name: damageName }] }, isRepair: true }; var glassSelections = wrapper.vm.getRearReplaceOptionsFromStore(); diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 2b9f08db3..f729b8b1a 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -179,16 +179,16 @@ export default { getDamageLocationsFromStore() { var glassSelections = []; - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD }) || + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD }) || store.getters.damage.isRepair) { glassSelections.push(damageLocationsSelected.WINDSHIELD); } - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER || - glass.glassLocation === damageLocationsSelected.PASSENGER })) { + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER || + glass.location === damageLocationsSelected.PASSENGER })) { glassSelections.push(damageLocationsSelected.SIDEDOOR); } - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.REAR })) { + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.REAR })) { glassSelections.push(damageLocationsSelected.REARWINDOW); } @@ -201,20 +201,20 @@ export default { if (store.getters.damage.isRepair === undefined) return windshieldOptions; if (!store.getters.damage.isRepair) { - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD && - glass.glassName === damageLocationsSelected.SINGLE })) { + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD && + glass.name === damageLocationsSelected.SINGLE })) { windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE; windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE); } - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD && - glass.glassName === damageLocationsSelected.DRIVER })) { + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD && + glass.name === damageLocationsSelected.DRIVER })) { windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE; windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER); } - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD && - glass.glassName === damageLocationsSelected.PASSENGER })) { + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD && + glass.name === damageLocationsSelected.PASSENGER })) { windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE; windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER); } @@ -231,11 +231,11 @@ export default { getDoorSidesFromStore() { var doorSides = []; - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER })){ + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER })){ doorSides.push(damageLocationsSelected.DRIVERSIDE); } - if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.PASSENGER })){ + if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.PASSENGER })){ doorSides.push(damageLocationsSelected.PASSENGERSIDE); } @@ -246,8 +246,8 @@ export default { var driverSideReplaceOptions = []; store.getters.damage.glassToReplace?.forEach(glass => { - if (glass.glassLocation === damageLocationsSelected.DRIVER){ - driverSideReplaceOptions.push(glass.glassName); + if (glass.location === damageLocationsSelected.DRIVER){ + driverSideReplaceOptions.push(glass.name); } }); @@ -258,8 +258,8 @@ export default { var passengerSideReplaceOptions = []; store.getters.damage.glassToReplace?.forEach(glass => { - if (glass.glassLocation === damageLocationsSelected.PASSENGER){ - passengerSideReplaceOptions.push(glass.glassName); + if (glass.location === damageLocationsSelected.PASSENGER){ + passengerSideReplaceOptions.push(glass.name); } }); @@ -270,8 +270,8 @@ export default { var rearReplaceOptions = []; store.getters.damage.glassToReplace?.forEach(glass => { - if (glass.glassLocation === damageLocationsSelected.REAR){ - rearReplaceOptions.push(glass.glassName); + if (glass.location === damageLocationsSelected.REAR){ + rearReplaceOptions.push(glass.name); } }); @@ -304,25 +304,25 @@ export default { const selectedGlassToReplace = []; if (this.isWindshieldDamageLocation && !this.isWindshieldRepair){ this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach(wsItem => { - selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.WINDSHIELD, glassName: wsItem}); + selectedGlassToReplace.push({ location: damageLocationsSelected.WINDSHIELD, name: wsItem}); }) } if (this.isDriverSideReplace){ this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach(driverItem => { - selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.DRIVER, glassName: driverItem}); + selectedGlassToReplace.push({ location: damageLocationsSelected.DRIVER, name: driverItem}); }) } if (this.isPassengerSideReplace){ this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach(passengerItem => { - selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.PASSENGER, glassName: passengerItem}); + selectedGlassToReplace.push({ location: damageLocationsSelected.PASSENGER, name: passengerItem}); }) } if (this.isRearWindowDamageLocation) { this.selectedRearReplaceOptions.forEach(rearItem => { - selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.REAR, glassName: rearItem}); + selectedGlassToReplace.push({ location: damageLocationsSelected.REAR, name: rearItem}); }) } diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js index 52471bf34..2acf1d87d 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.spec.js @@ -13,8 +13,8 @@ const featureListData = { { ColorAnswerText: 'Green Tint', FeatureAnswers: [{ FeatureAnswerText: "heated glass, solar, 1 hole", PartNumber: "DB12209GTYN" }] }, { ColorAnswerText: 'Gray Tint Privacy', FeatureAnswers: [{ FeatureAnswerText: "heated glass, solar, 1 hole", PartNumber: "DB12209YPYN" }] } ], - glassLocationProp: "Rear", - glassNameProp: "Stationary", + locationProp: "Rear", + nameProp: "Stationary", modelValueProp: {} } @@ -37,7 +37,7 @@ describe("glass-part-question.vue", () => { }); - test("Tint mapper, should get tint image by glassLocation and tintColor", async () => { + test("Tint mapper, should get tint image by location and tintColor", async () => { //Arrange @@ -72,7 +72,7 @@ describe("glass-part-question.vue", () => { //Arrange const { wrapper } = setupMocks(featureListData); store.getters.pageData.mockReset(); - store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] }); + store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] }); //Act await wrapper.vm.$nextTick(); @@ -111,7 +111,7 @@ describe("glass-part-question.vue", () => { test("default is selected if only one option", async () => { // Arrange store.getters.pageData.mockReset(); - store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] }); + store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] }); const { wrapper } = setupMocks(featureListData); // Act @@ -129,7 +129,7 @@ describe("glass-part-question.vue", () => { test("default is not selected if more than one option", async () => { // Arrange store.getters.pageData.mockReset(); - store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}, { partNumber: "DB12209GTYNXXX", color: "Green Tint"}]}] }); + store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}, { partNumber: "DB12209GTYNXXX", color: "Green Tint"}]}] }); const { wrapper } = setupMocks(featureListData); // Act @@ -150,13 +150,13 @@ describe("glass-part-question.vue", () => { ["Windshield", "Single", "Blue Tint", []], ["Driver", "Quarter", "Green Tint", []] ]; - test.each(partsForSelectedTintTestCases)("partsForSelectedTint returns correct parts", async (glassLocation, glassName, selectedTint, expectedResults) => { + test.each(partsForSelectedTintTestCases)("partsForSelectedTint returns correct parts", async (location, name, selectedTint, expectedResults) => { // Arrange store.getters.pageData.mockReset(); store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [ { - glassName: "Stationary", - glassLocation: "Rear", + name: "Stationary", + location: "Rear", parts: [ { partNumber: "Glass1", color: "Green Tint"}, { partNumber: "Glass2", color: "Blue Tint"}, @@ -168,14 +168,14 @@ describe("glass-part-question.vue", () => { ] }, { - glassName: "Single", - glassLocation: "Windshield", + name: "Single", + location: "Windshield", parts: [{ partNumber: "Windshield1", color: "Green Tint"}, { partNumber: "Windshield2", color: "Green Tint"}] } ]}); const { wrapper } = setupMocks({ - glassLocationProp: glassLocation, - glassNameProp: glassName, + locationProp: location, + nameProp: name, colorAnswersProp: [], }); @@ -189,9 +189,9 @@ describe("glass-part-question.vue", () => { -function setupMocks({ glassNameProp, glassLocationProp, colorAnswersProp, modelValueProp }) { +function setupMocks({ nameProp, locationProp, colorAnswersProp, modelValueProp }) { //Mock store - store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: []}] }); + store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: []}] }); store.getters.lineItems = { glassParts: {} } const mountOptions = getMountOptions({ @@ -206,8 +206,8 @@ function setupMocks({ glassNameProp, glassLocationProp, colorAnswersProp, modelV }); mountOptions.propsData = { - glassName: glassNameProp, - glassLocation: glassLocationProp, + name: nameProp, + location: locationProp, colorAnswers: colorAnswersProp, modelValue: modelValueProp }; diff --git a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue index 608cf55cb..8154f2ca4 100644 --- a/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue +++ b/src/layouts/vehicle-parts/glass-part-question/glass-part-question.vue @@ -12,7 +12,7 @@ :isWide="true" altText="" isRequired - :groupName="`${glassLocation}-${glassName}`" + :groupName="`${location}-${name}`" @isCheckedChanged="ResetTintAndPartSelections" :validationRules="tintValidationRules" > @@ -27,7 +27,7 @@ textPosition="text-start" :loaderEnabled="false" isRequired - :groupName="`${glassLocation}-${glassName}-${selectedTint}`" + :groupName="`${location}-${name}-${selectedTint}`" :validationRules="partValidationRules" />
@@ -60,8 +60,8 @@ export default { }; }, props: { - glassName: String, - glassLocation: String, + name: String, + location: String, colorAnswers: Array, modelValue: Object, alreadyPopulatedPartsData: Array @@ -74,30 +74,31 @@ export default { }, computed: { tintValidationRules() { - const validationRuleName = `${this.glassLocation}-${this.glassName}-tint-required`; + const validationRuleName = `${this.location}-${this.name}-tint-required`; defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED)); return validationRuleName; }, partValidationRules() { - const validationRuleName = `${this.glassLocation}-${this.glassName}-part-required`; + const validationRuleName = `${this.location}-${this.name}-part-required`; defineRule(validationRuleName, required(errorMessages.OPTION_REQUIRED)); return validationRuleName; }, colorQuestionText() { return getCustomTransformValue( this.glassColorQuestion, - `${this.glassLocation} ${this.glassName}` + `${this.location} ${this.name}` ); }, tintSelectionOptions() { let tintOptions = []; + Object.keys(this.featureListData).forEach((tintOption) => { tintOptions.push({ Name: tintOption, Text: tintOption, AnswerImageUrl: require(`@/assets/img/tints/${this.getTintSourceImage( - this.glassLocation, + this.location, tintOption )}`), }); @@ -116,9 +117,9 @@ export default { }, partsForSelectedTint() { - const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(dataForGlassLocationAndName => - dataForGlassLocationAndName.glassName == this.glassName && - dataForGlassLocationAndName.glassLocation == this.glassLocation); + const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(dataForlocationAndName => + dataForlocationAndName.name == this.name && + dataForlocationAndName.location == this.location); const matchingGlassParts = matchingGlass?.length == 1 ? matchingGlass[0].parts : []; return matchingGlassParts.filter(part => part.color == this.selectedTint) ?? []; }, @@ -166,8 +167,8 @@ export default { // Gets tint images based on the glass type, and tint name. // Returns an empty string if the src or object is undefined. - getTintSourceImage(glassLocation, tintColor) { - const tintSourceObject = getTintImage(glassLocation, tintColor); + getTintSourceImage(location, tintColor) { + const tintSourceObject = getTintImage(location, tintColor); if ( tintSourceObject === undefined || @@ -198,7 +199,7 @@ export default { this.$nextTick(() => { if (this.modelValue !== undefined) { // Populate button-question model-value if parts data already exists in VueX - this.selectedTint = this.alreadyPopulatedPartsData?.filter(part => part.partNumber === this.selectedPartNumber)[0].color; + this.selectedTint = this.alreadyPopulatedPartsData?.filter(part => part.partNumber === this.selectedPartNumber)[0]?.color; } }); }, diff --git a/src/layouts/vehicle-parts/vehicle-parts.spec.js b/src/layouts/vehicle-parts/vehicle-parts.spec.js index 2fce952c2..3f54b300c 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.spec.js +++ b/src/layouts/vehicle-parts/vehicle-parts.spec.js @@ -41,8 +41,8 @@ store.getters = { const basePartResponse = { partsOrQuestions: [ { - glassName: "Stationary", - glassLocation: "Rear", + name: "Stationary", + location: "Rear", parts: [ { partNumber: "DB12209GTYN", @@ -207,8 +207,8 @@ describe("vehicle-parts.vue", () => { return { partsOrQuestions: [ { - glassName: "Stationary", - glassLocation: "Rear", + name: "Stationary", + location: "Rear", parts: null, partQuestions: [{ testProperty: "some value" @@ -287,8 +287,8 @@ describe("vehicle-parts.vue", () => { store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [ { - glassName: "Single", - glassLocation: "Windshield", + name: "Single", + location: "Windshield", parts: [ { "partNumber": "FW03861GTYN", @@ -365,8 +365,8 @@ describe("vehicle-parts.vue", () => { store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [ { - glassName: "Single", - glassLocation: "Windshield", + name: "Single", + location: "Windshield", parts: [ { partNumber: "DB12209GTYN", diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index fcc656b33..2c4583685 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -29,10 +29,10 @@
@@ -102,7 +102,7 @@ export default { return { selectedGlassParts: {}, alertWidgetData: Object, - alreadyPopulatedPartsData: {}, + alreadyPopulatedPartsData: [], }; }, computed: { @@ -125,8 +125,8 @@ export default { // Map API result data, to vehicle-parts data structure const mappedData = partsData.partsOrQuestions.map((g) => { return { - glassName: g.glassName, - glassLocation: g.glassLocation, + name: g.name, + location: g.location, colorAnswers: g.parts?.reduce((arr, p) => { arr.push({ ColorAnswerText: p.color, @@ -175,8 +175,8 @@ export default { if (isMatched) { matchedParts.push({ - glassLocation: value.glassLocation, - glassName: value.glassName, + location: value.location, + name: value.name, parts: [currentPart] }); } @@ -198,20 +198,20 @@ export default { const partsData = this.PartsFromApi; const alreadyPopulatedPartsData = this.$store.getters.lineItems.glassParts === null - ? {} + ? [] : this.$store.getters.lineItems.glassParts; partsData.partsOrQuestions.map((g) => { // If the part is already populated, use the value from the store and populate the v-model. Object.keys(alreadyPopulatedPartsData).forEach((key) => { - const partNumber = alreadyPopulatedPartsData[key].partNumber; - g.parts.forEach((p) => { - if (p.partNumber === partNumber) { - this.selectedGlassParts[g.glassLocation + "-" + g.glassName] = { - [g.glassLocation]: [partNumber], - }; - } - }); + const partNumber = alreadyPopulatedPartsData[key].partNumber; + g.parts.forEach((p) => { + if (p.partNumber === partNumber) { + this.selectedGlassParts[g.location + "-" + g.name] = { + [g.location]: [partNumber], + }; + } + }); }); }); }, diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 415fa1e6d..5ac1c7758 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -65,20 +65,20 @@ export default { return this.comparePageIndices(currentPage, fmgPage) > 0; }, setupInitialData(glass, i, alreadyAnsweredQuestions, vm) { - glass.key = glass.glassLocation + "-" + glass.glassName; + glass.key = glass.location + "-" + glass.name; const self = vm ?? this; // clear answerData if no questions are already answered if (!alreadyAnsweredQuestions) { glass.answerData = null } - + alreadyAnsweredQuestions?.forEach((answeredGlass) => { // if answeredGlass lacks any of these properties then exit - if (!answeredGlass.glassLocation || - !answeredGlass.glassName || + if (!answeredGlass.location || + !answeredGlass.name || !answeredGlass.answeredQuestions || !answeredGlass.result && !answeredGlass.partNum) { return } // test if glass parts match - if (glass.glassLocation === answeredGlass.glassLocation && glass.glassName === answeredGlass.glassName) { + if (glass.location === answeredGlass.location && glass.name === answeredGlass.name) { let answerString = ""; // loop through answeredQuestions for matches @@ -118,7 +118,7 @@ export default { // Set up watch for each set of glass questions // (updated when all questions for a glass have been answered in question-chain) - self.$watch("selectedAnswers." + glass.key, (newValue) => { + self.$watch("selectedAnswers." + glass.location + '-' + glass.name, (newValue) => { if (newValue) { self.handleAnswerUpdates(newValue); } diff --git a/src/mixins/vehicle-questions-mixin.spec.js b/src/mixins/vehicle-questions-mixin.spec.js index e5a579f02..b2dab9645 100644 --- a/src/mixins/vehicle-questions-mixin.spec.js +++ b/src/mixins/vehicle-questions-mixin.spec.js @@ -71,8 +71,8 @@ describe("vehicle-questions-mixin", () => { // Act const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([ { - glassName: "Something", - glassLocation: "somewhere", + name: "Something", + location: "somewhere", parts: [{ partNumber: "1234567" }] @@ -90,22 +90,22 @@ describe("vehicle-questions-mixin", () => { // Act const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([ { - glassName: "Something", - glassLocation: "somewhere", + name: "Something", + location: "somewhere", parts: [{ partNumber: "1234567" }] }, { - glassName: "Another glass", - glassLocation: "somewhere else", + name: "Another glass", + location: "somewhere else", parts: [{ partNumber: "1234568" }] }, { - glassName: "Special glass", - glassLocation: "Another where", + name: "Special glass", + location: "Another where", parts: [{ partNumber: "1234569" }] @@ -123,22 +123,22 @@ describe("vehicle-questions-mixin", () => { // Act const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([ { - glassName: "Something", - glassLocation: "somewhere", + name: "Something", + location: "somewhere", parts: [{ partNumber: "1234567" }] }, { - glassName: "Another glass", - glassLocation: "somewhere else", + name: "Another glass", + location: "somewhere else", parts: [{ partNumber: "1234568" }] }, { - glassName: "Special glass", - glassLocation: "Another where", + name: "Special glass", + location: "Another where", parts: [ { partNumber: "1234569" @@ -321,8 +321,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const { wrapper } = setupMocks({}); const glass = { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", }; const i = 0; @@ -338,8 +338,8 @@ describe("vehicle-questions-mixin", () => { test("should return glass with answerData of null", async () => { // Arrange const glass = { - "glassName": "Single", - "glassLocation": "Windshield" + "name": "Single", + "location": "Windshield" }; const i = 0; const { wrapper } = setupMocks({}); @@ -356,8 +356,8 @@ describe("vehicle-questions-mixin", () => { test("should return glass with answerResult within answerData", async () => { // Arrange const glass = { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "questions": [ { "questionSequence": 1, @@ -380,8 +380,8 @@ describe("vehicle-questions-mixin", () => { const i = 0; const alreadyAnsweredQuestions = [ { - "glassLocation": "Windshield", - "glassName": "Single", + "location": "Windshield", + "name": "Single", "partNum": "WKT D1106 C", "answeredQuestions": [ { @@ -409,8 +409,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": null, "partQuestions": [ { @@ -449,8 +449,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": null, "partQuestions": [ { @@ -472,8 +472,8 @@ describe("vehicle-questions-mixin", () => { ] }, { - "glassName": "Front", - "glassLocation": "Driver", + "name": "Front", + "location": "Driver", "parts": [ { "partNumber": "DD08158GTYN", @@ -487,8 +487,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Quarter", - "glassLocation": "Driver", + "name": "Quarter", + "location": "Driver", "parts": [ { "partNumber": "DQ08162GTYN", @@ -502,8 +502,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "SideDoor", - "glassLocation": "Driver", + "name": "SideDoor", + "location": "Driver", "parts": null, "partQuestions": [ { @@ -525,8 +525,8 @@ describe("vehicle-questions-mixin", () => { ] }, { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "DB08165GTNN", @@ -557,8 +557,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": null, "partQuestions": [ { @@ -580,8 +580,8 @@ describe("vehicle-questions-mixin", () => { ] }, { - "glassName": "Front", - "glassLocation": "Driver", + "name": "Front", + "location": "Driver", "parts": [ { "partNumber": "DD08158GTYN", @@ -595,8 +595,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Quarter", - "glassLocation": "Driver", + "name": "Quarter", + "location": "Driver", "parts": [ { "partNumber": "DQ08162GTYN", @@ -610,8 +610,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "SideDoor", - "glassLocation": "Driver", + "name": "SideDoor", + "location": "Driver", "parts": [ { "partNumber": "DD08160GTYN", @@ -625,8 +625,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "DB08165GTNN", @@ -657,8 +657,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": null, "partQuestions": [ { @@ -680,8 +680,8 @@ describe("vehicle-questions-mixin", () => { ] }, { - "glassName": "Front", - "glassLocation": "Driver", + "name": "Front", + "location": "Driver", "parts": [ { "partNumber": "DD08158GTYN", @@ -695,8 +695,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Quarter", - "glassLocation": "Driver", + "name": "Quarter", + "location": "Driver", "parts": [ { "partNumber": "DQ08162GTYN", @@ -718,8 +718,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "SideDoor", - "glassLocation": "Driver", + "name": "SideDoor", + "location": "Driver", "parts": [ { "partNumber": "DD08160GTYN", @@ -741,8 +741,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "DB08165GTNN", @@ -807,8 +807,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "FB25724GTYN", @@ -847,8 +847,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": [ { "partNumber": "FW03647GTNN", @@ -868,8 +868,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Back", - "glassLocation": "Driver", + "name": "Back", + "location": "Driver", "parts": [ { "partNumber": "FD25747GTYN", @@ -883,8 +883,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Front", - "glassLocation": "Driver", + "name": "Front", + "location": "Driver", "parts": [ { "partNumber": "FD25719GTYN", @@ -898,8 +898,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Vent", - "glassLocation": "Driver", + "name": "Vent", + "location": "Driver", "parts": [ { "partNumber": "FV25749GTNN", @@ -913,8 +913,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "FB25724GTYN", @@ -953,8 +953,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": [ { "partNumber": "DW02101GTYN", @@ -968,8 +968,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Back", - "glassLocation": "Driver", + "name": "Back", + "location": "Driver", "parts": [ { "partNumber": "DD12202GTYN", @@ -991,8 +991,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Front", - "glassLocation": "Driver", + "name": "Front", + "location": "Driver", "parts": [ { "partNumber": "DD12198GTYN", @@ -1014,8 +1014,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Quarter", - "glassLocation": "Driver", + "name": "Quarter", + "location": "Driver", "parts": [ { "partNumber": "DQ12204GTYNOEM", @@ -1085,8 +1085,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "DB12209GTYN", @@ -1127,8 +1127,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "FB25724GTYN", @@ -1180,8 +1180,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": [ { "partNumber": "FB25724GTYN", @@ -1216,8 +1216,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": [ { "partNumber": "FW04186GTYN", @@ -1253,8 +1253,8 @@ describe("vehicle-questions-mixin", () => { // Arrange const partsOrQuestions = [ { - "glassName": "Single", - "glassLocation": "Windshield", + "name": "Single", + "location": "Windshield", "parts": [ { "partNumber": "FW04186GTYN", @@ -1274,8 +1274,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Back", - "glassLocation": "Driver", + "name": "Back", + "location": "Driver", "parts": [ { "partNumber": "FD25457GTYN", @@ -1289,8 +1289,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Front", - "glassLocation": "Driver", + "name": "Front", + "location": "Driver", "parts": [ { "partNumber": "FD27090GTYN", @@ -1304,8 +1304,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Vent", - "glassLocation": "Driver", + "name": "Vent", + "location": "Driver", "parts": [ { "partNumber": "FV25459GTNN", @@ -1319,8 +1319,8 @@ describe("vehicle-questions-mixin", () => { "partQuestions": null }, { - "glassName": "Stationary", - "glassLocation": "Rear", + "name": "Stationary", + "location": "Rear", "parts": [ { "partNumber": "FB25460GTYN", diff --git a/src/store/index.js b/src/store/index.js index 1a246befd..250971bd9 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -702,7 +702,7 @@ export const actions = { }, // PartsOrQuestions API Actions - getPartsOrQuestions(context) { + async getPartsOrQuestions(context) { const vehicle = context.getters.vehicle; const damage = context.getters.damage; const order = context.state.order; @@ -712,20 +712,30 @@ export const actions = { const zipCode = order.serviceLocation.zipCode; const vin = vehicle.vin; - return globalMethods.callHttpClient({ + const response = await globalMethods.callHttpClient({ method: endpoints.GetPartsOrQuestions.method, endpoint: endpoints.GetPartsOrQuestions.url, payload: { carId: carId, - glass: glassArray ?? [], + glassPieces: glassArray ?? [], zip: zipCode, vin: vin }, }); + + // Flatten location and name properties + response.data.partsOrQuestions.map(glass => { + glass.location = glass.glassPiece.location; + glass.name = glass.glassPiece.name; + delete glass.glassPiece; + return glass; + }); + + return response; }, // Parts API Actions - getParts(context) { + async getParts(context) { const vehicle = context.getters.vehicle; const damage = context.getters.damage; const order = context.state.order; @@ -736,17 +746,27 @@ export const actions = { const zipCode = order.serviceLocation.zipCode; const vin = vehicle.vin; - return globalMethods.callHttpClient({ + // Flatten location and name properties + const response = await globalMethods.callHttpClient({ method: endpoints.GetParts.method, endpoint: endpoints.GetParts.url, payload: { carId: carId, - glass: glassArray, + glassPieces: glassArray, answerResults: resultsArray, zip: zipCode, vin: vin }, }); + + response.data.glassPieceParts.map(glass => { + glass.location = glass.glassPiece.location; + glass.name = glass.glassPiece.name; + delete glass.glassPiece; + return glass; + }); + + return response; }, getCapabilityQuestions(context, { carId, partNumber }) { @@ -756,12 +776,12 @@ export const actions = { }) }, - getPartFromCapabilityQuestionAnswer(context, glassLocation) { + getPartFromCapabilityQuestionAnswer(context, location) { const pageData = context.getters.pageData(fmgPageValues.CAPABILITY_QUESTIONS); - const part = pageData.partsOrQuestions.find(x => x.glassLocation === glassLocation).parts[0]; + const part = pageData.partsOrQuestions.find(x => x.location === location).parts[0]; const capabilityQuestionAnswers = context.getters.damage.capabilityQuestionAnswers; - const capabilityQuestionAnswersForPart = capabilityQuestionAnswers.find(x => x.glassLocation === glassLocation); + const capabilityQuestionAnswersForPart = capabilityQuestionAnswers.find(x => x.location === location); return globalMethods.callHttpClient({ method: endpoints.GetPartFromCapabilityAnswer.method,