From 97d053f56028572c26647bfc64c052f8609db525 Mon Sep 17 00:00:00 2001 From: EPortman <169073732+EPortman@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:48:08 -0800 Subject: [PATCH] 23752 namex version not picked up correctly (#1543) * fix: ui correctly fetches version of namex api * fix: corrected comparison of date on home page --- app/components/app_footer/VersionInfo.vue | 24 ++++++++++------------- app/package.json | 2 +- testing/cypress/appActions/Utilities.ts | 16 +++------------ testing/cypress/pageObjects/homePage.ts | 6 +----- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/app/components/app_footer/VersionInfo.vue b/app/components/app_footer/VersionInfo.vue index d96a4b85..2d55f609 100644 --- a/app/components/app_footer/VersionInfo.vue +++ b/app/components/app_footer/VersionInfo.vue @@ -38,23 +38,19 @@ onMounted(async () => { }) const fetchNameXVersion = async (): Promise => { - const devNameXVersionEndpoint = 'https://namex-dev.apps.silver.devops.gov.bc.ca/api/v1/meta/info' - // const testNameXVersionEndpoint = 'https://namex-test.apps.silver.devops.gov.bc.ca/api/v1/meta/info' - // const prodNameXVersionEndpoint = 'https://namex.apps.silver.devops.gov.bc.ca/api/v1/meta/info' + const baseUrl = process.env.NUXT_NAMEX_API_URL || 'https://namex-dev.apps.silver.devops.gov.bc.ca' + const versionPath = process.env.NUXT_NAMEX_API_VERSION || '/api/v1' + const versionEndpoint = `${baseUrl}${versionPath}/meta/info` try { - const response = await fetch(devNameXVersionEndpoint) - if (!response.ok) { - console.error('Failed to fetch:', response.status, response.statusText) - throw Error - } - const responseJson = await response.json() - const fullVersion = responseJson.API.split('/')[1] - const version = fullVersion.match(/^(\d+\.\d+\.\d+)/)?.[0] || 'Unknown' - - return version + const response = await fetch(versionEndpoint) + if (!response.ok) throw new Error(`Fetch failed: ${response.statusText}`) + + const { API } = await response.json() + return API.match(/\d+\.\d+\.\d+/)?.[0] || 'Unknown' + } catch (error) { - console.error('Error fetching data:', error) + console.error('Error fetching NameX API version:', error) return 'Error' } } diff --git a/app/package.json b/app/package.json index df832d81..e2e6a334 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "name-examination", - "version": "1.2.33", + "version": "1.2.34", "private": true, "scripts": { "build": "nuxt generate", diff --git a/testing/cypress/appActions/Utilities.ts b/testing/cypress/appActions/Utilities.ts index 9722b9a6..94bac269 100644 --- a/testing/cypress/appActions/Utilities.ts +++ b/testing/cypress/appActions/Utilities.ts @@ -47,22 +47,12 @@ class Utilities { } /** - * Returns the current date in the format "YYYYMMDD". + * Returns the current date in the format "YYYY-MM-DD". * - * @return The current date in the format "YYYYMMDD". + * @return The current date in the format "YYYY-MM-DD". */ getDate(): string { - const today = new Date() - let dd: any = today.getDate() - let mm: any = today.getMonth() + 1 // January is 0! - const yyyy = today.getFullYear() - if (dd < 10) { - dd = '0' + dd - } - if (mm < 10) { - mm = '0' + mm - } - return yyyy + mm + dd + return new Date().toLocaleDateString('en-CA') } /** diff --git a/testing/cypress/pageObjects/homePage.ts b/testing/cypress/pageObjects/homePage.ts index 48c47618..3398a4d6 100644 --- a/testing/cypress/pageObjects/homePage.ts +++ b/testing/cypress/pageObjects/homePage.ts @@ -40,11 +40,7 @@ class HomePage { .invoke('text') .then(($text) => { const date = util.getDate() - const formattedDate = `${date.substring(0, 4)}-${date.substring( - 4, - 6 - )}-${date.substring(6, 8)}` - expect($text).to.contain(formattedDate) + expect($text.trim()).to.include(date) cy.log($text) }) }