Compare commits
No commits in common. "f8f460fe745c1d4498766327c7ff8cf54c8d5581" and "5f8c34ef7811d424e19a569f28677c40924cd692" have entirely different histories.
f8f460fe74
...
5f8c34ef78
12 changed files with 982 additions and 441 deletions
23
package.json
23
package.json
|
@ -6,6 +6,7 @@
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"test": "npm run test:integration && npm run test:unit",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
||||||
|
@ -23,13 +24,14 @@
|
||||||
"mode-watcher": "^0.3.1",
|
"mode-watcher": "^0.3.1",
|
||||||
"svelte-boring-avatars": "^1.2.6",
|
"svelte-boring-avatars": "^1.2.6",
|
||||||
"svelte-sonner": "^0.3.28",
|
"svelte-sonner": "^0.3.28",
|
||||||
"tailwind-merge": "^2.5.4",
|
"tailwind-merge": "^2.5.2",
|
||||||
"tailwind-variants": "^0.2.1",
|
"tailwind-variants": "^0.2.1",
|
||||||
"vaul-svelte": "^0.3.2"
|
"vaul-svelte": "^0.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-node": "^5.2.7",
|
"@playwright/test": "^1.47.1",
|
||||||
"@sveltejs/kit": "^2.7.1",
|
"@sveltejs/adapter-node": "^5.2.3",
|
||||||
|
"@sveltejs/kit": "^2.5.28",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||||
|
@ -38,18 +40,19 @@
|
||||||
"boring-avatars": "^1.11.2",
|
"boring-avatars": "^1.11.2",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-svelte": "^2.44.1",
|
"eslint-plugin-svelte": "^2.44.0",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.47",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-svelte": "^3.2.7",
|
"prettier-plugin-svelte": "^3.2.6",
|
||||||
"prettier-plugin-tailwindcss": "^0.5.14",
|
"prettier-plugin-tailwindcss": "^0.5.14",
|
||||||
"svelte": "^4.2.19",
|
"svelte": "^4.2.19",
|
||||||
"svelte-check": "^3.8.6",
|
"svelte-check": "^3.8.6",
|
||||||
"sveltekit-superforms": "^2.19.1",
|
"sveltekit-superforms": "^2.18.1",
|
||||||
"tailwindcss": "^3.4.14",
|
"tailwindcss": "^3.4.12",
|
||||||
"tslib": "^2.8.0",
|
"tslib": "^2.7.0",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.6.2",
|
||||||
"vite": "^5.4.9",
|
"vite": "^5.4.6",
|
||||||
|
"vitest": "^1.6.0",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1306
pnpm-lock.yaml
generated
1306
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -25,7 +25,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user = await res.json() as User;
|
const user: User = await res.json();
|
||||||
event.locals.user = user;
|
event.locals.user = user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
event.locals.user = undefined;
|
event.locals.user = undefined;
|
||||||
|
|
7
src/index.test.ts
Normal file
7
src/index.test.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
|
||||||
|
describe('sum test', () => {
|
||||||
|
it('adds 1 + 2 to equal 3', () => {
|
||||||
|
expect(1 + 2).toBe(3);
|
||||||
|
});
|
||||||
|
});
|
17
src/lib/stores/plausible.ts
Normal file
17
src/lib/stores/plausible.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { browser } from '$app/environment';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
|
const defaultValue = true;
|
||||||
|
const initialValue = browser
|
||||||
|
? window.localStorage.getItem('plausible_ignore') === 'true'
|
||||||
|
: defaultValue;
|
||||||
|
|
||||||
|
const plausible = writable<boolean>(initialValue);
|
||||||
|
|
||||||
|
plausible.subscribe((value) => {
|
||||||
|
if (browser) {
|
||||||
|
window.localStorage.setItem('plausible_ignore', value ? 'true' : 'false');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default plausible;
|
|
@ -54,7 +54,6 @@
|
||||||
<Form.Control let:attrs>
|
<Form.Control let:attrs>
|
||||||
<Form.Label>Prénom</Form.Label>
|
<Form.Label>Prénom</Form.Label>
|
||||||
<Input {...attrs} bind:value={$formData.firstname} placeholder="Philip" />
|
<Input {...attrs} bind:value={$formData.firstname} placeholder="Philip" />
|
||||||
<Form.Description>Votre prénom de famille ne sera pas visible par les autres utilisateurs.</Form.Description>
|
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
<Form.FieldErrors />
|
<Form.FieldErrors />
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
|
@ -62,7 +61,6 @@
|
||||||
<Form.Control let:attrs>
|
<Form.Control let:attrs>
|
||||||
<Form.Label>Nom de famille</Form.Label>
|
<Form.Label>Nom de famille</Form.Label>
|
||||||
<Input {...attrs} bind:value={$formData.lastname} placeholder="Barlow" />
|
<Input {...attrs} bind:value={$formData.lastname} placeholder="Barlow" />
|
||||||
<Form.Description>Votre nom de famille ne sera pas visible par les autres utilisateurs.</Form.Description>
|
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
<Form.FieldErrors />
|
<Form.FieldErrors />
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
|
@ -71,7 +69,7 @@
|
||||||
<Form.Label>Nom d'utilisateur</Form.Label>
|
<Form.Label>Nom d'utilisateur</Form.Label>
|
||||||
<Input {...attrs} bind:value={$formData.pseudo} placeholder="Cypherwolf" />
|
<Input {...attrs} bind:value={$formData.pseudo} placeholder="Cypherwolf" />
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
<Form.Description>Votre nom d'utilisateur sera visible par les autres utilisateurs.</Form.Description>
|
<Form.Description>Ce nom sera visible par les autres utilisateurs.</Form.Description>
|
||||||
<Form.FieldErrors />
|
<Form.FieldErrors />
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -21,6 +21,7 @@ export const load: PageServerLoad = async ({ locals: { user } }) => {
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
default: async ({ request, cookies, fetch, url: { searchParams } }) => {
|
default: async ({ request, cookies, fetch, url: { searchParams } }) => {
|
||||||
|
|
||||||
const form = await superValidate(request, zod(loginSchema));
|
const form = await superValidate(request, zod(loginSchema));
|
||||||
|
|
||||||
if (!form.valid) {
|
if (!form.valid) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ export const load: PageServerLoad = async ({ locals: { user } }) => {
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
register: async ({ request }) => {
|
register: async ({ request }) => {
|
||||||
|
|
||||||
const form = await superValidate(request, zod(registerSchema));
|
const form = await superValidate(request, zod(registerSchema));
|
||||||
|
|
||||||
if (!form.valid) {
|
if (!form.valid) {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import { superForm } from 'sveltekit-superforms/client';
|
import { superForm } from 'sveltekit-superforms/client';
|
||||||
|
|
||||||
import * as Form from '$lib/components/ui/form';
|
import * as Form from '$lib/components/ui/form';
|
||||||
import { Input } from '$lib/components/ui/input';
|
import Input from '$lib/components/ui/input/input.svelte';
|
||||||
|
|
||||||
import { registerConfirmationSchema, registerSchema } from '$lib/validations/auth';
|
import { registerConfirmationSchema, registerSchema } from '$lib/validations/auth';
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
<Input
|
<Input
|
||||||
{...attrs}
|
{...attrs}
|
||||||
bind:value={$registerConfirmationFormData.code}
|
bind:value={$registerConfirmationFormData.code}
|
||||||
placeholder="0a0a-a0a0"
|
placeholder="0000"
|
||||||
/>
|
/>
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
<Form.FieldErrors />
|
<Form.FieldErrors />
|
||||||
|
@ -220,9 +220,9 @@
|
||||||
{/if}
|
{/if}
|
||||||
<ul class="flex justify-between">
|
<ul class="flex justify-between">
|
||||||
<li>
|
<li>
|
||||||
<a class="text-muted-foreground hover:text-primary" href="/login{$page.url.search}">
|
<a class="text-muted-foreground hover:text-primary" href="/login{$page.url.search}"
|
||||||
Se connecter
|
>Se connecter</a
|
||||||
</a>
|
>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
|
|
||||||
import { Metadata } from '$lib/components';
|
import { Metadata } from '$lib/components';
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Metadata />
|
<Metadata />
|
||||||
|
|
51
tests/index.test.ts
Normal file
51
tests/index.test.ts
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
test('index page redirects to login page', async ({ page }) => {
|
||||||
|
await page.goto('/');
|
||||||
|
|
||||||
|
await page.waitForURL('/login');
|
||||||
|
|
||||||
|
await expect(page.url()).toContain('/login');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('login page has a register link that redirects to the register page', async ({ page }) => {
|
||||||
|
await page.goto('/login');
|
||||||
|
|
||||||
|
const link = await page.$('a[href*="/register"]');
|
||||||
|
|
||||||
|
await link?.click();
|
||||||
|
|
||||||
|
await page.waitForURL('/register');
|
||||||
|
|
||||||
|
await expect(page.url()).toContain('/register');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('register page has a login link that redirects to the login page', async ({ page }) => {
|
||||||
|
await page.goto('/register');
|
||||||
|
|
||||||
|
const link = await page.$('a[href*="/login"]');
|
||||||
|
|
||||||
|
await link?.click();
|
||||||
|
|
||||||
|
await page.waitForURL('/login');
|
||||||
|
|
||||||
|
await expect(page.url()).toContain('/login');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('dashboard page redirects to login page if user is not logged in', async ({ page }) => {
|
||||||
|
await page.goto('');
|
||||||
|
await expect(page.url()).toContain('/login');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('login form accepts valid credentials', async ({ page }) => {
|
||||||
|
await page.context().clearCookies();
|
||||||
|
|
||||||
|
await page.goto('/login');
|
||||||
|
|
||||||
|
await page.fill('input[name="pseudo"]', 'glazk0');
|
||||||
|
await page.fill('input[name="passwd"]', 'Cookies Are #Miam42');
|
||||||
|
|
||||||
|
await Promise.all([page.getByRole('button').click(), page.waitForURL('')]);
|
||||||
|
|
||||||
|
await expect(page.url()).toContain('');
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue