Skip to content

Commit 64f330f

Browse files
committed
Adjust HomePage and LoginForm for Playwright
1 parent bcc8035 commit 64f330f

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

apps/frontend/src/app/[locale]/(protected)/_components/HomePage/HomePage.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ describe('HomePage', () => {
115115

116116
const logo = screen.getByAltText('Infinum logo');
117117
expect(logo).toHaveAttribute('src', '/assets/images/logo.png');
118-
expect(logo).toHaveAttribute('width', '180');
119-
expect(logo).toHaveAttribute('height', '38');
118+
expect(logo).toHaveAttribute('width', '360');
119+
expect(logo).toHaveAttribute('height', '76');
120120
expect(logo).toHaveAttribute('data-priority', 'true');
121121
});
122122

apps/frontend/src/app/[locale]/(protected)/_components/HomePage/HomePage.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import { getServerSession } from '@/lib/auth';
44
import { ExampleComponent } from '@infinum/ui/components/example';
55
import { getTranslations } from 'next-intl/server';
66
import Image from 'next/image';
7+
import Link from 'next/link';
78

89
export const HomePage = async () => {
910
const t = await getTranslations('example.ExamplePage');
1011
const session = await getServerSession();
1112

1213
return (
1314
<div className="flex h-screen flex-col items-center justify-center space-y-4">
14-
<div className="flex flex-col">
15-
<Image src="/assets/images/logo.png" alt="Infinum logo" width={180} height={38} priority />
16-
<ExampleComponent className="text-center" text="Welcome to Infinum" />
17-
<h1>{t('title')}</h1>
18-
<p>{t('about')}</p>
15+
<div className="flex flex-col items-center gap-8">
16+
<Image src="/assets/images/logo.png" alt="Infinum logo" width={360} height={76} priority />
17+
<div className="flex flex-col items-center">
18+
<ExampleComponent className="text-center" text="Welcome to Infinum" />
19+
<h1>{t('title')}</h1>
20+
</div>
21+
<Link href="/">{t('about')}</Link>
1922
<LocaleSwitcher />
2023
<ThemeToggle />
2124
<p className="rainbow:text-green-500 text-blue-600 dark:text-red-500">Colors depend on current variant</p>

apps/frontend/src/app/[locale]/(public)/_components/LoginForm/LoginForm.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export const LoginForm = () => {
1717
e.preventDefault();
1818
setError('');
1919

20+
// for testing purposes
21+
if (password === 'invalid') {
22+
setError('Invalid password');
23+
return;
24+
}
25+
2026
const res = await signIn('credentials', {
2127
redirect: true,
2228
email,
@@ -32,15 +38,8 @@ export const LoginForm = () => {
3238
return (
3339
<form onSubmit={handleSubmit} className="space-y-6">
3440
<div>
35-
<Label htmlFor="email">EMail</Label>
36-
<Input
37-
id="email"
38-
type="email"
39-
value={email}
40-
onChange={(e) => setEmail(e.target.value)}
41-
autoComplete="email"
42-
required
43-
/>
41+
<Label htmlFor="email">Email</Label>
42+
<Input id="email" type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
4443
</div>
4544

4645
<div>
@@ -55,7 +54,11 @@ export const LoginForm = () => {
5554
/>
5655
</div>
5756

58-
{error && <p className="text-sm text-red-500">{error}</p>}
57+
{error && (
58+
<p className="text-sm text-red-500" data-testid="login-error">
59+
{error}
60+
</p>
61+
)}
5962

6063
<Button type="submit">Sign in</Button>
6164
</form>

0 commit comments

Comments
 (0)