Skip to content

Commit

Permalink
23752 namex version not picked up correctly (bcgov#1543)
Browse files Browse the repository at this point in the history
* fix: ui correctly fetches version of namex api

* fix: corrected comparison of date on home page
  • Loading branch information
EPortman authored Nov 7, 2024
1 parent d083683 commit 97d053f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 33 deletions.
24 changes: 10 additions & 14 deletions app/components/app_footer/VersionInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,19 @@ onMounted(async () => {
})
const fetchNameXVersion = async (): Promise<string> => {
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'
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-examination",
"version": "1.2.33",
"version": "1.2.34",
"private": true,
"scripts": {
"build": "nuxt generate",
Expand Down
16 changes: 3 additions & 13 deletions testing/cypress/appActions/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

/**
Expand Down
6 changes: 1 addition & 5 deletions testing/cypress/pageObjects/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit 97d053f

Please sign in to comment.