Skip to content

Commit

Permalink
Merge pull request #8 from turb0c0w/sam/mock-login
Browse files Browse the repository at this point in the history
Sam/mock login
  • Loading branch information
samIndustrio authored Apr 29, 2024
2 parents fb43808 + 5c6b53e commit c9b848a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
10 changes: 5 additions & 5 deletions strr-web/middleware/setupAuth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export default defineNuxtRouteMiddleware(async (to) => {
if ((!to.query.error) && !process.env.VITEST_WORKER_ID) {
// keycloak redirects with the error param when not logged in (nuxt/keycloak issue)
// - removing ^ condition will cause an infinite loop of keycloak redirects when not authenticated
const { kcURL, kcRealm, kcClient } = useRuntimeConfig().public
await useBcrosAuth().setupAuth(
{ url: kcURL, realm: kcRealm, clientId: kcClient },
to.params.currentAccountId as string || to.query.currentAccountId as string
)
// const { kcURL, kcRealm, kcClient } = useRuntimeConfig().public
// await useBcrosAuth().setupAuth(
// { url: kcURL, realm: kcRealm, clientId: kcClient },
// to.params.currentAccountId as string || to.query.currentAccountId as string
// )

// For e2e testing, leave for now
if (process.client && sessionStorage?.getItem('FAKE_LOGIN')) {
Expand Down
19 changes: 15 additions & 4 deletions strr-web/pages/account-select.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div data-cy="account-select-page">
<div v-if="activeUserAccounts.length > 0">
<div v-if="userAccounts.length > 0">
<div class="mobile:px-[8px]">
<BcrosTypographyH1 text="account.title" data-cy="accountPageTitle" class="mobile:pb-[20px]" />
<BcrosAlertsMessage :flavour="alertFlavour">
Expand All @@ -9,7 +9,7 @@
<BcrosTypographyH2 :text="existingAcccountsTitle" data-cy="accountPageAccountSectionTitle" />
<span class="text-[16px] mb-[20px] block">{{ t('account.existing-account-section.sub-title') }}</span>
</div>
<BcrosExistingAccountsList :accounts="activeUserAccounts" />
<BcrosExistingAccountsList :accounts="userAccounts" />
</div>
<div v-else>
<BcrosTypographyH1 text="account.logIn" data-cy="accountPageTitle" class="mobile:pb-[20px]" />
Expand All @@ -18,14 +18,25 @@
</template>

<script setup lang="ts">
import { AlertsFlavourE } from '#imports'
import { AccountI, AlertsFlavourE } from '#imports'
import testAccounts from './test-accounts.json'
const t = useNuxtApp().$i18n.t
const alertFlavour: AlertsFlavourE = AlertsFlavourE.INFO
const { activeUserAccounts } = useBcrosAccount()
const existingAcccountsTitle = `${t('account.existing-account-section.title')} (${activeUserAccounts.length})`
const query = useRoute().query;
let userAccounts = activeUserAccounts;
if ('test' in query && query.test === "true") {
const testData: AccountI = testAccounts as unknown as AccountI;
userAccounts = [ testData ];
}
const existingAcccountsTitle = `${t('account.existing-account-section.title')} (${userAccounts.length})`
</script>
27 changes: 27 additions & 0 deletions strr-web/pages/test-accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"accessType": "REGULAR",
"branchName": "",
"businessName": "PPR Dev JR 2",
"businessSize": "2-5",
"businessType": "REALA",
"created": "2022-01-06T00:14:08+00:00",
"createdBy": "BCREGTEST HARRIETT FORTY",
"hasApiAccess": false,
"id": 2869,
"isBusinessAccount": true,
"mailingAddress": {
"city": "Lake Country",
"country": "CA",
"postalCode": "V4V 1V7",
"region": "BC",
"street": "9874 Pollard Rd",
"streetAdditional": ""
},
"modified": "2022-01-06T00:14:08+00:00",
"name": "PPR Dev JR 2",
"orgStatus": "ACTIVE",
"orgType": "PREMIUM",
"statusCode": "ACTIVE",
"uuid": "e3d5c9da-4853-4e1d-bef9-0b765df3c523",
"label": "PPR Dev JR 2"
}

0 comments on commit c9b848a

Please sign in to comment.