Skip to content

Commit

Permalink
Ongoing unit test refactors and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-eyds committed Dec 12, 2024
1 parent 42725e1 commit 173a901
Show file tree
Hide file tree
Showing 13 changed files with 845 additions and 42 deletions.
65 changes: 65 additions & 0 deletions assets-ui/devops/cloudbuild-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
steps:
# install / setup ci
- name: node:16.14.2
entrypoint: npm
dir: "ppr-ui"
args: ['install']

# setup .env
- name: 'bash'
dir: "ppr-ui"
script: |
#!/usr/bin/env bash
cp .env.example .env
#
# Generate the static site
#
- name: node:16.14.2
dir: "ppr-ui"
entrypoint: npm
env:
- 'VUE_APP_ADDRESS_COMPLETE_KEY=$_VUE_APP_ADDRESS_COMPLETE_KEY'
- 'VUE_APP_PPR_LD_CLIENT_ID=$_VUE_APP_PPR_LD_CLIENT_ID'
- 'VUE_APP_PPR_API_KEY=$_VUE_APP_PPR_API_KEY'
- 'VUE_APP_MHR_API_KEY=$_VUE_APP_MHR_API_KEY'
- 'VUE_APP_LTSA_API_KEY=$_VUE_APP_LTSA_API_KEY'
- 'VUE_APP_REGISTRIES_SEARCH_API_KEY=$_VUE_APP_REGISTRIES_SEARCH_API_KEY'
args: ['--openssl-legacy-provider', 'run', 'build']

#
# Deploy to firebase channel, using the PR #
# store log to /workspace to get the channel URL
#
- name: gcr.io/yfthig-dev/firebase
dir: "ppr-ui"
entrypoint: bash
args: ['-c', 'firebase hosting:channel:deploy --project=yfthig-dev PR-$_PR_NUMBER > /workspace/firebase-deploy.txt']

#
# Update the PR with the temporary URL
#
- id: "Update the PR"
name: gcr.io/cloud-builders/curl
dir: "ppr-ui"
entrypoint: bash
args:
- -c
- |
# Read from "/workspace"
cat /workspace/firebase-deploy.txt
url=`cat /workspace/firebase-deploy.txt| grep 'Channel URL' | grep -Eo "https://[a-zA-Z0-9./?=_%:-]*"`
echo "this is the body:"
echo '{"body": "Temporary Url for review:'"$url"'"}'
curl -X POST \
https://api.github.com/repos/bcgov/ppr/issues/$_PR_NUMBER/comments \
--header "Authorization: Token $$TOKEN" \
--header "Accept: application/vnd.github.v3+json" \
--data-binary '{"body": "Temporary Url for review: '"$url"'"}'
secretEnv: ['TOKEN']
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/token-pr-review/versions/latest
env: 'TOKEN'
options:
dynamic_substitutions: true
53 changes: 53 additions & 0 deletions assets-ui/devops/vaults.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Base Path Openshift: /ppr Firebase: /
VUE_APP_PATH="/"

#vaults canadapost
VUE_APP_ADDRESS_COMPLETE_KEY="op://canadapost/$APP_ENV/address-key/ADDRESS_COMPLETE_KEY"

#vaults assets
VUE_APP_POD_NAMESPACE="op://ppr/$APP_ENV/ppr-ui/POD_NAMESPACE"
VUE_APP_PPR_STAFF_PARTY_CODE="op://ppr/$APP_ENV/ppr-ui/PPR_STAFF_PARTY_CODE"
VUE_APP_BCOL_STAFF_PARTY_CODE="op://ppr/$APP_ENV/ppr-ui/BCOL_STAFF_PARTY_CODE"

#vaults web-url
VUE_APP_REGISTRY_URL="op://web-url/$APP_ENV/registry/REGISTRY_URL"
VUE_APP_AUTH_WEB_URL="op://web-url/$APP_ENV/auth-web/AUTH_WEB_URL"
VUE_APP_DOCUMENTS_UI_URL="op://web-url/$APP_ENV/documents-ui/DOCUMENTS_UI_URL"
VUE_APP_SITEMINDER_LOGOUT_URL="op://web-url/$APP_ENV/siteminder/SITEMINDER_LOGOUT_URL"

#vaults API
VUE_APP_PPR_API_URL="op://API/$APP_ENV/ppr-api/PPR_API_URL"
VUE_APP_PPR_API_VERSION="op://API/$APP_ENV/ppr-api/PPR_API_VERSION"
VUE_APP_PPR_API_KEY="op://API/$APP_ENV/ppr-api/PPR_API_KEY"
VUE_APP_MHR_API_URL="op://API/$APP_ENV/ppr-api/MHR_API_URL"
VUE_APP_MHR_API_VERSION="op://API/$APP_ENV/ppr-api/MHR_API_VERSION"
VUE_APP_MHR_API_KEY="op://API/$APP_ENV/ppr-api/MHR_API_KEY"
VUE_APP_LTSA_API_URL="op://API/$APP_ENV/ltsa-api/LTSA_API_URL"
VUE_APP_LTSA_API_VERSION="op://API/$APP_ENV/ltsa-api/LTSA_API_VERSION"
VUE_APP_LTSA_API_KEY="op://API/$APP_ENV/ltsa-api/LTSA_API_KEY"
VUE_APP_DOC_API_URL="op://API/$APP_ENV/doc-api/DOC_API_URL"
VUE_APP_DOC_API_VERSION="op://API/$APP_ENV/doc-api/DOC_API_VERSION"
VUE_APP_DOC_API_KEY="op://API/$APP_ENV/doc-api/DOC_API_KEY"
VUE_APP_AUTH_API_URL="op://API/$APP_ENV/auth-api/AUTH_API_URL"
VUE_APP_AUTH_API_VERSION="op://API/$APP_ENV/auth-api/AUTH_API_VERSION"
VUE_APP_STATUS_API_URL="op://API/$APP_ENV/status-api/STATUS_API_URL"
VUE_APP_STATUS_API_VERSION="op://API/$APP_ENV/status-api/STATUS_API_VERSION"
VUE_APP_PAY_API_URL="op://API/$APP_ENV/pay-api/PAY_API_URL"
VUE_APP_PAY_API_VERSION="op://API/$APP_ENV/pay-api/PAY_API_VERSION"
VUE_APP_VON_API_URL="op://API/$APP_ENV/von-api/VON_API_URL"
VUE_APP_VON_API_VERSION="op://API/$APP_ENV/von-api/VON_API_VERSION"
VUE_APP_REGISTRIES_SEARCH_API_URL="op://API/$APP_ENV/registries-search-api/REGISTRIES_SEARCH_API_URL"
VUE_APP_REGISTRIES_SEARCH_API_VERSION="op://API/$APP_ENV/registries-search-api/REGISTRIES_SEARCH_API_VERSION"
VUE_APP_REGISTRIES_SEARCH_API_KEY="op://API/$APP_ENV/registries-search-api/REGISTRIES_SEARCH_API_KEY"


#vaults launchdarkly
VUE_APP_PPR_LD_CLIENT_ID="op://launchdarkly/$APP_ENV/ppr/PPR_LD_CLIENT_ID"

#vaults keycloak
VUE_APP_KEYCLOAK_AUTH_URL="op://keycloak/$APP_ENV/base/KEYCLOAK_AUTH_BASE_URL"
VUE_APP_KEYCLOAK_REALM="op://keycloak/$APP_ENV/base/KEYCLOAK_REALMNAME"
VUE_APP_KEYCLOAK_CLIENTID="op://keycloak/$APP_ENV/ppr-web/UI_KEYCLOAK_RESOURCE_NAME"

#vaults sentry
VUE_APP_SENTRY_DSN="op://sentry/$APP_ENV/ppr/SENTRY_DSN"
37 changes: 36 additions & 1 deletion assets-ui/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from 'nuxt/config'
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'

import fs from 'fs'
import path from 'path'

const packageJson = fs.readFileSync('./package.json', 'utf-8')
const appName = JSON.parse(packageJson).appName
const appVersion = JSON.parse(packageJson).version
const sbcName = JSON.parse(packageJson).sbcName
const sbcVersion = JSON.parse(packageJson).dependencies['sbc-common-components']
const aboutText1 = (appName && appVersion) ? `${appName} v${appVersion}` : ''
const aboutText2 = (sbcName && sbcVersion) ? `${sbcName} v${sbcVersion}` : ''
const aboutText = (aboutText1 && aboutText2)
? `${aboutText1}<br>${aboutText2}`
: aboutText1
? `${aboutText1}`
: aboutText2
? `${aboutText2}`
: ''

export default defineNuxtConfig({
compatibilityDate: '2024-11-01',
devtools: { enabled: true },
Expand Down Expand Up @@ -78,7 +96,7 @@ export default defineNuxtConfig({
interval: 1000, // Polling interval in milliseconds
},
},
modules: ['@pinia/nuxt', '@nuxt/eslint', 'nuxt-lodash',
modules: ['@pinia/nuxt', '@nuxt/eslint', 'nuxt-lodash', '@nuxt/test-utils/module',
(_options, nuxt) => {
nuxt.hooks.hook('vite:extendConfig', (config) => {
config.plugins.push(vuetify({ autoImport: true }))
Expand Down Expand Up @@ -112,8 +130,25 @@ export default defineNuxtConfig({
},
}
},
test: {
server: {
deps: {
inline: ['vuetify', 'vue-pdf-embed']
}
},
globals: true,
threads: true,
environment: 'jsdom',
testTimeout: 60000,
setupFiles: './tests/setup.ts',
onConsoleLog (log) {
if (log.includes('Vue warn')) return false // Filter out Vue warnings while preserving errors and logs.
if (log.includes('AggregateError')) return false // Filter out failed network requests vs mocking them all.
}
},
runtimeConfig: {
public: {
ABOUT_TEXT: aboutText,
VUE_APP_PATH: process.env.VUE_APP_PATH || '',
VUE_APP_LOCAL_DEV: process.env.VUE_APP_LOCAL_DEV || '',
BASE_URL: process.env.BASE_URL || '',
Expand Down
13 changes: 10 additions & 3 deletions assets-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "nuxt-app",
"name": "ppr-ui",
"version": "4.0.0",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
"type": "module",
"scripts": {
"build": "nuxt build",
Expand Down Expand Up @@ -44,7 +47,7 @@
"npm": "^10.9.1",
"nuxt": "3.14.0",
"pinia": "^2.1.3",
"sbc-common-components": "4.0.8",
"sbc-common-components": "4.0.9",
"vue": "latest",
"vue-pdf-embed": "1.1.6",
"vue-plugin-helper-decorator": "^0.0.12",
Expand All @@ -55,6 +58,8 @@
},
"devDependencies": {
"@mdi/font": "^6.9.96",
"@nuxt/test-utils": "^3.13.1",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@originjs/vite-plugin-require-context": "^1.0.9",
"@pinia/testing": "^0.1.3",
Expand All @@ -65,7 +70,7 @@
"@vue/compiler-sfc": "^3.3.4",
"@vue/eslint-config-standard": "^8.0.1",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/test-utils": "^2.4.1",
"@vue/test-utils": "^2.4.6",
"axe-core": "^4.8.1",
"css-loader": "^7.1.2",
"eslint": "^8.51.0",
Expand All @@ -75,6 +80,7 @@
"eslint-plugin-vue": "^9.17.0",
"eslint-plugin-vuetify": "^2.0.5",
"jsdom": "^22.1.0",
"happy-dom": "^14.12.0",
"maska": "^2.1.10",
"nuxt-lodash": "^2.5.3",
"sass": "~1.32.13",
Expand All @@ -87,6 +93,7 @@
"vite-plugin-vuetify": "^2.0.4",
"vitest": "^0.34.6",
"vitest-axe": "^0.1.0",
"vitest-environment-nuxt": "^1.0.0",
"vue": "^3.3.6",
"vue-axe": "^2.4.4",
"vue-cli-plugin-vuetify": "^2.5.8",
Expand Down
Loading

0 comments on commit 173a901

Please sign in to comment.