From 3bededcd9434dbdc95a07f5813f737168db46ff8 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 9 Apr 2024 07:47:40 +0200 Subject: [PATCH 1/2] refactor: refs #6973 updated label and updated cypress test --- cypress.config.js | 1 + src/components/CreateNewPostcodeForm.vue | 22 ++++++++++++--- src/components/common/VnLocation.vue | 10 +++++-- test/cypress/integration/VnLocation.spec.js | 30 ++++++++++----------- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/cypress.config.js b/cypress.config.js index 1934f833e..e2046d6c4 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -3,6 +3,7 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ e2e: { baseUrl: 'http://localhost:9000/', + experimentalStudio: true, fixturesFolder: 'test/cypress/fixtures', screenshotsFolder: 'test/cypress/screenshots', supportFile: 'test/cypress/support/index.js', diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index 47836c05b..514e564ae 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -28,8 +28,24 @@ const countriesOptions = ref([]); const provincesOptions = ref([]); const townsLocationOptions = ref([]); -const onDataSaved = (dataSaved) => { - emit('onDataSaved', dataSaved); +const onDataSaved = (formData) => { + const newPostcode = { + ...formData + }; + const townObject = townsLocationOptions.value.find( + ({id}) => id === formData.townFk + ); + newPostcode.town = townObject ? townObject.name : undefined; + const provinceObject = provincesOptions.value.find( + ({id}) => id === formData.provinceFk + ); + newPostcode.province = provinceObject ? provinceObject.name : undefined; + const countryObject = countriesOptions.value.find( + ({id}) => id === formData.countryFk + ); + newPostcode.country = countryObject ? countryObject.country : undefined; + emit('onDataSaved', newPostcode); + }; const onCityCreated = async ({ name, provinceFk }, formData) => { @@ -73,7 +89,7 @@ const onProvinceCreated = async ({ name }, formData) => { :title="t('New postcode')" :subtitle="t('Please, ensure you put the correct data!')" :form-initial-data="postcodeFormData" - @on-data-saved="onDataSaved($event)" + @on-data-saved="onDataSaved" >