Skip to content

Commit 01af2ca

Browse files
committed
test: add unit test for auth page
1 parent febc936 commit 01af2ca

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

app/pages/index.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ import Button from '~/components/ui/Button.vue';
1717
<main>
1818
<section>
1919
<div class="flex flex-col gap-4">
20-
<Button variant="outline" class="w-75">{{ $t('root.auth.github-signin') }}</Button>
21-
<Button variant="outline" class="w-75">{{ $t('root.auth.google-signin') }}</Button>
20+
<Button id="github-signin" variant="outline" class="w-75">{{
21+
$t('root.auth.github-signin')
22+
}}</Button>
23+
<Button id="google-signin" variant="outline" class="w-75">{{
24+
$t('root.auth.google-signin')
25+
}}</Button>
2226
</div>
2327
<div class="flex max-w-75 items-center justify-center gap-2 py-2">
2428
<div class="w-full border-b-1" />
2529
<span class="uppercase">{{ $t('root.auth.separator') }}</span>
2630
<div class="w-full border-b-1" />
2731
</div>
28-
<Button variant="default" class="w-75">{{ $t('root.auth.signup') }}</Button>
32+
<Button id="signup" variant="default" class="w-75">{{ $t('root.auth.signup') }}</Button>
2933
<p class="text-muted-foreground mt-4 max-w-75 text-xs">
3034
{{ $t('root.auth.signup-info') }}
3135
</p>
@@ -34,7 +38,7 @@ import Button from '~/components/ui/Button.vue';
3438
<p class="font-semibold">
3539
{{ $t('root.auth.already-have-account') }}
3640
</p>
37-
<Button variant="outline" class="my-4 w-75" type="button">
41+
<Button id="signin" variant="outline" class="my-4 w-75" type="button">
3842
{{ $t('root.auth.signin') }}
3943
</Button>
4044
</section>

test/nuxt/pages/index.spec.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import { describe, expect, it } from 'vitest';
22
import { mountSuspended } from '@nuxt/test-utils/runtime';
33
import IndexPage from '@/pages/index.vue';
44

5-
describe('Index Page', () => {
6-
it('renders welcome heading and button text', async () => {
5+
describe('Auth Page', () => {
6+
it('renders page with correct content', async () => {
77
const wrapper = await mountSuspended(IndexPage);
88

9-
// Check translated welcome text from i18n
10-
expect(wrapper.html()).toContain('Welcome to Raven');
9+
const html = wrapper.html();
10+
expect(html).toContain('Happening now');
11+
expect(html).toContain('Join today');
12+
expect(wrapper.find('#github-signin').exists()).toBe(true);
13+
expect(wrapper.find('#google-signin').exists()).toBe(true);
14+
expect(wrapper.find('#signup').exists()).toBe(true);
15+
expect(wrapper.find('#signin').exists()).toBe(true);
1116
});
1217
});

0 commit comments

Comments
 (0)