@sbc-connect/nuxt-auth 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @sbc-connect/nuxt-auth
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#121](https://github.com/bcgov/connect-nuxt/pull/121) [`e4d8d9e`](https://github.com/bcgov/connect-nuxt/commit/e4d8d9e510af321a2cc7ba12ca270a5f018981e5) Thanks [@kialj876](https://github.com/kialj876)! - Updated account mocking so that tests can mock their own account instead of the hardcoded mock
8
+
9
+ - Updated dependencies []:
10
+ - @sbc-connect/nuxt-base@0.6.0
11
+ - @sbc-connect/nuxt-forms@0.4.0
12
+
3
13
  ## 0.4.0
4
14
 
5
15
  ### Minor Changes
@@ -10,7 +10,7 @@ const isLargeScreen = useMediaQuery('(min-width: 1024px)')
10
10
  id="account-options-menu"
11
11
  :items="loggedInUserOptions"
12
12
  :ui="{
13
- content: 'max-w-[90dvw]',
13
+ content: 'max-w-[90dvw] account-options-menu-pw-selector',
14
14
  }"
15
15
  >
16
16
  <UButton
@@ -45,14 +45,19 @@ export default defineNuxtRouteMiddleware(async (to) => {
45
45
  }
46
46
  $connectAuth.authenticated = true
47
47
 
48
- currentAccount.value = {
49
- id: 1,
50
- label: 'Playwright',
51
- accountStatus: AccountStatus.ACTIVE,
52
- accountType: AccountType.PREMIUM,
53
- type: UserSettingsType.ACCOUNT,
54
- urlorigin: '',
55
- urlpath: ''
48
+ if (rtc.playwrightFetchTestAccount) {
49
+ // allows each test to mock the account information with its own data
50
+ await useConnectAccountStore().setAccountInfo()
51
+ } else {
52
+ currentAccount.value = {
53
+ id: 1,
54
+ label: 'Playwright',
55
+ accountStatus: AccountStatus.ACTIVE,
56
+ accountType: AccountType.PREMIUM,
57
+ type: UserSettingsType.ACCOUNT,
58
+ urlorigin: '',
59
+ urlpath: ''
60
+ }
56
61
  }
57
62
  }
58
63
  })
@@ -119,7 +119,7 @@ export const useConnectAccountStore = defineStore('connect-auth-account-store',
119
119
 
120
120
  /** Get the user's account list */
121
121
  async function getUserAccounts(): Promise<ConnectAccount[] | undefined> {
122
- if (!authUser.value?.keycloakGuid) {
122
+ if (!authUser.value?.keycloakGuid && !rtc.playwright) {
123
123
  return undefined
124
124
  }
125
125
  // TODO: use orgs fetch instead to get branch name ? $authApi<UserSettings[]>('/users/orgs')
package/nuxt.config.ts CHANGED
@@ -77,7 +77,8 @@ export default defineNuxtConfig({
77
77
  tokenMinValidity: '',
78
78
  sessionInactivityTimeout: '',
79
79
  sessionModalTimeout: '',
80
- playwright: process.env.playwright === 'true'
80
+ playwright: process.env.playwright === 'true',
81
+ playwrightFetchTestAccount: process.env.playwrightFetchTestAccount === 'true'
81
82
  }
82
83
  }
83
84
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sbc-connect/nuxt-auth",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "repository": "github:bcgov/connect-nuxt",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "./nuxt.config.ts",
@@ -11,9 +11,9 @@
11
11
  "nuxt": "4.2.2",
12
12
  "typescript": "5.9.3",
13
13
  "vue-tsc": "3.2.1",
14
- "@sbc-connect/playwright-config": "0.1.0",
15
- "@sbc-connect/vitest-config": "0.1.0",
16
- "@sbc-connect/eslint-config": "0.0.8"
14
+ "@sbc-connect/eslint-config": "0.0.8",
15
+ "@sbc-connect/playwright-config": "0.1.1",
16
+ "@sbc-connect/vitest-config": "0.1.0"
17
17
  },
18
18
  "dependencies": {
19
19
  "@pinia/colada": "0.20.0",
@@ -0,0 +1 @@
1
+ export * from './settings'
@@ -0,0 +1,11 @@
1
+ import fs from 'fs'
2
+ import { createResolver } from 'nuxt/kit'
3
+
4
+ import type { ConnectAccount } from '#auth/app/interfaces/connect-account'
5
+
6
+ const { resolve } = createResolver(import.meta.url)
7
+
8
+ export const getUserSettingsMock = (accountType: AccountType) => {
9
+ const json: ConnectAccount[] = JSON.parse(fs.readFileSync(resolve(`./json/${accountType}.json`), 'utf8'))
10
+ return json
11
+ }
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "accountStatus": "ACTIVE",
4
+ "accountType": "PREMIUM",
5
+ "additionalLabel": "Test Branch 1",
6
+ "id": 1222,
7
+ "label": "Test Tester",
8
+ "productSettings": "/account/1222/restricted-product",
9
+ "type": "ACCOUNT",
10
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
11
+ "urlpath": "/account/1222/settings"
12
+ },
13
+ {
14
+ "accountStatus": "ACTIVE",
15
+ "accountType": "PREMIUM",
16
+ "additionalLabel": "Test Branch 2",
17
+ "id": 1223,
18
+ "label": "Test Tester 2",
19
+ "productSettings": "/account/1223/restricted-product",
20
+ "type": "ACCOUNT",
21
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
22
+ "urlpath": "/account/1223/settings"
23
+ },
24
+ {
25
+ "id": 1111,
26
+ "label": "USER PROFILE",
27
+ "type": "USER_PROFILE",
28
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
29
+ "urlpath": "/userprofile"
30
+ },
31
+ {
32
+ "id": 1111,
33
+ "label": "CREATE ACCOUNT",
34
+ "type": "CREATE_ACCOUNT",
35
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
36
+ "urlpath": "/setup-account"
37
+ }
38
+ ]
@@ -0,0 +1,27 @@
1
+ [
2
+ {
3
+ "accountStatus": "ACTIVE",
4
+ "accountType": "SBC_STAFF",
5
+ "additionalLabel": "Sbc staff example",
6
+ "id": 1239,
7
+ "label": "Ministry of Finance",
8
+ "productSettings": "/account/1239/restricted-product",
9
+ "type": "ACCOUNT",
10
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
11
+ "urlpath": "/account/1239/settings"
12
+ },
13
+ {
14
+ "id": 1111,
15
+ "label": "USER PROFILE",
16
+ "type": "USER_PROFILE",
17
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
18
+ "urlpath": "/userprofile"
19
+ },
20
+ {
21
+ "id": 1111,
22
+ "label": "CREATE ACCOUNT",
23
+ "type": "CREATE_ACCOUNT",
24
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
25
+ "urlpath": "/setup-account"
26
+ }
27
+ ]
@@ -0,0 +1,27 @@
1
+ [
2
+ {
3
+ "accountStatus": "ACTIVE",
4
+ "accountType": "STAFF",
5
+ "additionalLabel": "BC Registries and Online Services Staff",
6
+ "id": 1234,
7
+ "label": "Ministry of Citizens' Services",
8
+ "productSettings": "/account/1234/restricted-product",
9
+ "type": "ACCOUNT",
10
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
11
+ "urlpath": "/account/1234/settings"
12
+ },
13
+ {
14
+ "id": 1111,
15
+ "label": "USER PROFILE",
16
+ "type": "USER_PROFILE",
17
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
18
+ "urlpath": "/userprofile"
19
+ },
20
+ {
21
+ "id": 1111,
22
+ "label": "CREATE ACCOUNT",
23
+ "type": "CREATE_ACCOUNT",
24
+ "urlorigin": "https://dev.account.bcregistry.gov.bc.ca",
25
+ "urlpath": "/setup-account"
26
+ }
27
+ ]
@@ -0,0 +1,12 @@
1
+ import type { Page } from '@playwright/test'
2
+ import { AccountType } from '#auth/app/enums/account-type'
3
+ import { getUserSettingsMock } from '#auth/testMocks/auth'
4
+
5
+ export const mockApiCallsForSetAccount = async (
6
+ page: Page,
7
+ accountType: AccountType = AccountType.PREMIUM
8
+ ) => {
9
+ page.route('**/users/**/settings', async (route) => {
10
+ await route.fulfill({ json: getUserSettingsMock(accountType) })
11
+ })
12
+ }