-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update agencie stat to 250 from 560. * wip testing optional params in login destination. * Create placeholder gspc registration page and place it behind login. Also allow for params to be passed into the login redirect. * fix the failing tests. * Resolve error thrown by test. * Code cleanup.
- Loading branch information
1 parent
4c28014
commit 91e8d5b
Showing
12 changed files
with
204 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<script setup> | ||
import { ref, onErrorCaptured, onBeforeMount } from 'vue'; | ||
import USWDSAlert from './USWDSAlert.vue' | ||
import Loginless from './LoginlessFlow.vue'; | ||
onErrorCaptured((err) => { | ||
setError(err) | ||
return false | ||
}) | ||
let expirationDate = "" | ||
onBeforeMount(async () => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
expirationDate = urlParams.get('expirationDate') | ||
}) | ||
const error = ref() | ||
function startLoading() { | ||
error.value = undefined | ||
} | ||
function setError(event){ | ||
error.value = event | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
class="padding-top-4 padding-bottom-4" | ||
:class="{'bg-base-lightest': isStarted && !isSubmitted}" | ||
> | ||
<div | ||
class="grid-container" | ||
data-test="post-submit" | ||
> | ||
<div class="grid-row"> | ||
<div class="tablet:grid-col-12"> | ||
<USWDSAlert | ||
v-if="error" | ||
class="tablet:grid-col-8" | ||
status="error" | ||
:heading="error.name" | ||
> | ||
{{ error.message }} | ||
</USWDSAlert> | ||
<Suspense> | ||
<template #fallback> | ||
…Loading | ||
</template> | ||
<Loginless | ||
page-id="gspc_registration" | ||
title="gspc_registration" | ||
:header="header" | ||
link-destination-text="GSPC Registration" | ||
:parameters="expirationDate" | ||
@start-loading="startLoading" | ||
@error="setError" | ||
> | ||
<template #initial-greeting> | ||
<h2>GSPC Registration</h2> | ||
<p>Enter your email address to login. You'll receive an email with an access link.</p> | ||
</template> | ||
|
||
<template #more-info> | ||
<h2>Welcome!</h2> | ||
<p>Before you can register for GSPC, you'll need to create and complete your profile.</p> | ||
</template> | ||
|
||
<h2>GSPC Placeholder</h2> | ||
<p>logged in</p> | ||
</Loginless> | ||
</Suspense> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
training-front-end/src/components/__tests__/GspcRegistration.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { describe, it, expect, afterEach, vi} from 'vitest' | ||
import { mount, flushPromises } from '@vue/test-utils' | ||
import GspcRegistration from '../GspcRegistration.vue' | ||
|
||
|
||
import { cleanStores } from 'nanostores' | ||
import { profile } from '../../stores/user.js' | ||
|
||
describe('GspcRegistration', () => { | ||
afterEach(() => { | ||
vi.restoreAllMocks() | ||
cleanStores(profile) | ||
profile.set({}) | ||
}) | ||
|
||
it('loads initial view with unknown user', async () => { | ||
vi.spyOn(global, 'fetch').mockImplementation(() => { | ||
return Promise.resolve({ok: false, status:404, json: () => Promise.resolve([]) }) | ||
}) | ||
const wrapper = await mount(GspcRegistration) | ||
await flushPromises() | ||
expect(wrapper.text()).toContain("GSPC Registration") | ||
expect(wrapper.text()).toContain("Enter your email address to login. You'll receive an email with an access link.") | ||
}) | ||
|
||
it('shows start registration form once user is known', async () => { | ||
vi.spyOn(global, 'fetch').mockImplementation(() => { | ||
return Promise.resolve({ok: false, status:404, json: () => Promise.resolve([]) }) | ||
}) | ||
profile.set({name:"John Smith", jwt:"some-token-value"}) | ||
const wrapper = await mount(GspcRegistration) | ||
await flushPromises() | ||
expect(wrapper.text()).toContain("GSPC Placeholder") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,7 +371,7 @@ describe('Loginless', () => { | |
await second_form.trigger('submit.prevent') | ||
await flushPromises() | ||
expect(fetchspy).nthCalledWith(2, expect.any(URL), { | ||
body: '{"user":{"name":"Molly","email":"[email protected]","agency_id":"3"},"dest":{"page_id":"page-id","title":"Training Title"}}', | ||
body: '{"user":{"name":"Molly","email":"[email protected]","agency_id":"3"},"dest":{"page_id":"page-id","parameters":"","title":"Training Title"}}', | ||
method: 'POST', | ||
headers: {'Content-Type': 'application/json'}, | ||
}) | ||
|
@@ -401,7 +401,7 @@ describe('Loginless', () => { | |
|
||
expect(fetchspy).toBeCalledTimes(2) | ||
expect(fetchspy).nthCalledWith(2, expect.any(URL), { | ||
body: '{"user":{"name":"Molly","email":"[email protected]","agency_id":"1"},"dest":{"page_id":"page-id","title":"Training Title"}}', | ||
body: '{"user":{"name":"Molly","email":"[email protected]","agency_id":"1"},"dest":{"page_id":"page-id","parameters":"","title":"Training Title"}}', | ||
method: 'POST', | ||
headers: {'Content-Type': 'application/json'}, | ||
}) | ||
|
17 changes: 17 additions & 0 deletions
17
training-front-end/src/pages/gspc_registration/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
import BaseLayout from '@layouts/BaseLayout.astro'; | ||
import HeroTraining from '@components/HeroTraining.astro'; | ||
import GspcRegistration from '@components/GspcRegistration.vue'; | ||
const pageTitle = "GSPC Registration"; | ||
--- | ||
|
||
<BaseLayout title={pageTitle} description="GSPC registration page"> | ||
<HeroTraining background_class='bg_smartpay_cool_grey'> | ||
GSPC Registration | ||
</HeroTraining> | ||
<GspcRegistration | ||
client:load | ||
client:only > | ||
</GspcRegistration> | ||
</BaseLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,5 @@ class WebDestination(BaseModel): | |
after the loginless flow completes | ||
''' | ||
page_id: str | ||
parameters: str | ||
title: str |
Oops, something went wrong.