Skip to content

Commit

Permalink
test silent refresh page
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogge committed Mar 13, 2024
1 parent 6e3014c commit 71018db
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ exports[`TextButtonInput > TextButtonInput renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -165,7 +165,7 @@ exports[`TextButtonInput > TextButtonInput renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ exports[`ContactForm > renders form 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -518,7 +518,7 @@ exports[`ContactForm > renders form 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ exports[`FooterMenu > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -785,7 +785,7 @@ exports[`FooterMenu > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ exports[`DefaultLayout > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -1276,7 +1276,7 @@ exports[`DefaultLayout > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions presenter/src/pages/auth/__snapshots__/Page.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ exports[`AuthPage > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -1283,7 +1283,7 @@ exports[`AuthPage > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ exports[`DataPrivacyPage > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -1652,7 +1652,7 @@ exports[`DataPrivacyPage > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions presenter/src/pages/impressum/__snapshots__/Page.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ exports[`ImpressumPage > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -1929,7 +1929,7 @@ exports[`ImpressumPage > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions presenter/src/pages/index/__snapshots__/Page.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3199,7 +3199,7 @@ exports[`IndexPage > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -3211,7 +3211,7 @@ exports[`IndexPage > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions presenter/src/pages/optin/__snapshots__/Page.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ exports[`OptinPage > API call with error > renders error message 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -1327,7 +1327,7 @@ exports[`OptinPage > API call with error > renders error message 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down Expand Up @@ -2814,7 +2814,7 @@ exports[`OptinPage > API call with failure > renders error message 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -2826,7 +2826,7 @@ exports[`OptinPage > API call with failure > renders error message 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down Expand Up @@ -4277,7 +4277,7 @@ exports[`OptinPage > API call with success > renders success 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -4289,7 +4289,7 @@ exports[`OptinPage > API call with success > renders success 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down
59 changes: 49 additions & 10 deletions presenter/src/pages/silent-refresh/Page.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,62 @@
import { mount } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'
import { navigate } from 'vike/client/router'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import { authService } from '#tests/mock.authService'

import SilentRefreshPage from './+Page.vue'
import { title } from './+title'

vi.mock('vike/client/router')
vi.mocked(navigate).mockResolvedValue()

describe('SilentRefreshPage', () => {
const wrapper = mount(VApp, {
slots: {
default: h(SilentRefreshPage as Component),
},
})
const authServiceSpy = vi.spyOn(authService, 'renewToken')

const Wrapper = () => {
return mount(VApp, {
slots: {
default: h(SilentRefreshPage as Component),
},
})
}

let wrapper: ReturnType<typeof Wrapper>

describe('auth service with succes', () => {
beforeEach(() => {
wrapper = Wrapper()
})

it('title returns correct title', () => {
expect(title).toBe('DreamMall | Authentifizierung')
it('title returns correct title', () => {
expect(title).toBe('DreamMall | Authentifizierung')
})

it('renders', () => {
expect(wrapper.element).toMatchSnapshot()
})

it('calls renew token of auth service', () => {
expect(authServiceSpy).toBeCalled()
})

it('navigatesto /', () => {
expect(navigate).toBeCalledWith('/')
})
})

it('renders', () => {
expect(wrapper.element).toMatchSnapshot()
describe('auth service throws', () => {
const consoleSpy = vi.spyOn(global.console, 'log')

beforeEach(() => {
authServiceSpy.mockRejectedValue('Ouch!')
wrapper = Wrapper()
})

it('logs error to console', () => {
expect(consoleSpy).toBeCalledWith('auth error', 'Ouch!')
})
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`SilentRefreshPage > renders 1`] = `
exports[`SilentRefreshPage > auth service with succes > renders 1`] = `
<div
class="v-application v-theme--light v-layout v-layout--full-height v-locale--is-ltr"
>
Expand All @@ -12,7 +12,7 @@ exports[`SilentRefreshPage > renders 1`] = `
class="v-main main-layout"
data-v-75d0be1e=""
data-v-a3d38914=""
style="--v-layout-left: 0px; --v-layout-right: 0px; --v-layout-top: 64px; --v-layout-bottom: 0px;"
style="--v-layout-left: 0px; --v-layout-right: 0px; --v-layout-top: 64px; --v-layout-bottom: 0px; transition: none !important;"
>
<div
Expand All @@ -23,7 +23,7 @@ exports[`SilentRefreshPage > renders 1`] = `
<header
class="v-toolbar v-toolbar--flat v-toolbar--density-default v-theme--light v-locale--is-ltr v-app-bar"
data-v-5e2a2776=""
style="top: 0px; z-index: 1008; transform: translateY(0%); position: fixed; background-color: #f5f5f5; color: #000; caret-color: #000; left: 0px; width: calc(100% - 0px - 0px);"
style="top: 0px; z-index: 1008; transform: translateY(0%); position: fixed; transition: none !important; background-color: #f5f5f5; color: #000; caret-color: #000; left: 0px; width: calc(100% - 0px - 0px);"
>
<!---->
Expand Down Expand Up @@ -369,7 +369,7 @@ exports[`SilentRefreshPage > renders 1`] = `
<nav
class="v-navigation-drawer v-navigation-drawer--right v-navigation-drawer--temporary v-theme--light v-navigation-drawer--mobile nav-drawer d-flex d-md-none"
data-v-5e2a2776=""
style="background-color: #f5f5f5; color: #000; caret-color: #000; right: 0px; z-index: 1006; transform: translateX(110%); position: fixed; height: calc(100% - 64px - 0px); top: 64px; bottom: 0px; width: 256px;"
style="background-color: #f5f5f5; color: #000; caret-color: #000; right: 0px; z-index: 1006; transform: translateX(110%); position: fixed; transition: none !important; height: calc(100% - 64px - 0px); top: 64px; bottom: 0px; width: 256px;"
>
<!---->
<!---->
Expand Down Expand Up @@ -1271,7 +1271,7 @@ exports[`SilentRefreshPage > renders 1`] = `
<div
class="v-input__details"
>
<transition-group-stub
<transition-stub
appear="false"
aria-live="polite"
class="v-messages"
Expand All @@ -1283,7 +1283,7 @@ exports[`SilentRefreshPage > renders 1`] = `
tag="div"
>
<!---->
</transition-group-stub>
</transition-stub>
<!---->
</div>
</div>
Expand Down

0 comments on commit 71018db

Please sign in to comment.