From 4242851f9c4faa1ac8da4158594c774171c4794b Mon Sep 17 00:00:00 2001 From: qpismont Date: Fri, 8 Aug 2025 21:21:42 +0000 Subject: [PATCH] Remove obsolete tests and add new login page layout - Deleted test files for NavLink, Navbar, NavbarBrand, Progress, Row, SearchBar, Select, Spinner, Textarea, and a basic test for Button. - Introduced a new EmptyLayout component for consistent layout structure. - Added a new login page with a layout that includes a login form and an ASCII art header. - Updated CSS variables for improved styling consistency across components. - Removed Vitest configuration file as it is no longer needed. --- .claude/settings.local.json | 6 - .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 33 +- .oxlintrc.json | 14 + .prettierrc | 3 + .vscode/settings.json | 16 +- README.md | 27 +- TESTING.md | 188 - astro.config.mjs | 6 +- biome.json | 28 - bun.lock | 891 --- package-lock.json | 5714 +++++++++++++++++ package.json | 44 +- public/favicon.svg | 14 + public/logo.svg | 13 + src/actions/index.ts | 21 + src/assets/astro.svg | 1 - src/assets/background.svg | 1 - src/assets/logo.svg | 14 + src/components/Ascii.astro | 36 + src/components/forms/LoginForm.astro | 43 + src/components/ui/Container.astro | 10 +- src/components/ui/__tests__/Alert.test.ts | 59 - src/components/ui/__tests__/Badge.test.ts | 65 - src/components/ui/__tests__/Button.test.ts | 102 - src/components/ui/__tests__/Card.test.ts | 45 - src/components/ui/__tests__/Col.test.ts | 106 - src/components/ui/__tests__/Container.test.ts | 56 - src/components/ui/__tests__/FormGroup.test.ts | 44 - src/components/ui/__tests__/Input.test.ts | 103 - src/components/ui/__tests__/Modal.test.ts | 66 - src/components/ui/__tests__/ModalBody.test.ts | 44 - .../ui/__tests__/ModalFooter.test.ts | 44 - .../ui/__tests__/ModalHeader.test.ts | 54 - src/components/ui/__tests__/MovieCard.test.ts | 113 - src/components/ui/__tests__/NavLink.test.ts | 85 - src/components/ui/__tests__/Navbar.test.ts | 81 - .../ui/__tests__/NavbarBrand.test.ts | 60 - src/components/ui/__tests__/Progress.test.ts | 91 - src/components/ui/__tests__/Row.test.ts | 54 - src/components/ui/__tests__/SearchBar.test.ts | 94 - src/components/ui/__tests__/Select.test.ts | 71 - src/components/ui/__tests__/Spinner.test.ts | 71 - src/components/ui/__tests__/Textarea.test.ts | 78 - src/components/ui/__tests__/basic.test.ts | 15 - src/layouts/EmptyLayout.astro | 7 + src/pages/login.astro | 39 + src/styles/variables.css | 242 +- tsconfig.json | 6 +- vitest.config.ts | 7 - 50 files changed, 6115 insertions(+), 2912 deletions(-) delete mode 100644 .claude/settings.local.json create mode 100644 .oxlintrc.json create mode 100644 .prettierrc delete mode 100644 TESTING.md delete mode 100644 biome.json delete mode 100644 bun.lock create mode 100644 package-lock.json create mode 100644 public/favicon.svg create mode 100644 public/logo.svg create mode 100644 src/actions/index.ts delete mode 100644 src/assets/astro.svg delete mode 100644 src/assets/background.svg create mode 100644 src/assets/logo.svg create mode 100644 src/components/Ascii.astro create mode 100644 src/components/forms/LoginForm.astro delete mode 100644 src/components/ui/__tests__/Alert.test.ts delete mode 100644 src/components/ui/__tests__/Badge.test.ts delete mode 100644 src/components/ui/__tests__/Button.test.ts delete mode 100644 src/components/ui/__tests__/Card.test.ts delete mode 100644 src/components/ui/__tests__/Col.test.ts delete mode 100644 src/components/ui/__tests__/Container.test.ts delete mode 100644 src/components/ui/__tests__/FormGroup.test.ts delete mode 100644 src/components/ui/__tests__/Input.test.ts delete mode 100644 src/components/ui/__tests__/Modal.test.ts delete mode 100644 src/components/ui/__tests__/ModalBody.test.ts delete mode 100644 src/components/ui/__tests__/ModalFooter.test.ts delete mode 100644 src/components/ui/__tests__/ModalHeader.test.ts delete mode 100644 src/components/ui/__tests__/MovieCard.test.ts delete mode 100644 src/components/ui/__tests__/NavLink.test.ts delete mode 100644 src/components/ui/__tests__/Navbar.test.ts delete mode 100644 src/components/ui/__tests__/NavbarBrand.test.ts delete mode 100644 src/components/ui/__tests__/Progress.test.ts delete mode 100644 src/components/ui/__tests__/Row.test.ts delete mode 100644 src/components/ui/__tests__/SearchBar.test.ts delete mode 100644 src/components/ui/__tests__/Select.test.ts delete mode 100644 src/components/ui/__tests__/Spinner.test.ts delete mode 100644 src/components/ui/__tests__/Textarea.test.ts delete mode 100644 src/components/ui/__tests__/basic.test.ts create mode 100644 src/layouts/EmptyLayout.astro create mode 100644 src/pages/login.astro delete mode 100644 vitest.config.ts diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 783d087..0000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "permissions": { - "allow": [], - "deny": [] - } -} \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d8809bb..42c3e62 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts +FROM node:24 WORKDIR /app diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2cd2fe5..839dfac 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,22 +1,13 @@ { - "workspaceFolder": "/workspace", - "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z", - "runArgs": [ - "--network=dev-network" - ], - "build": { - "dockerfile": "Dockerfile" - }, - "customizations": { - "vscode": { - "extensions": [ - "oven.bun-vscode", - "biomejs.biome", - "astro-build.astro-vscode" - ] - } - }, - "forwardPorts": [ - 8080 - ] -} \ No newline at end of file + "workspaceFolder": "/workspace", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z", + "runArgs": ["--network=dev-network"], + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": ["astro-build.astro-vscode", "oxc.oxc-vscode", "esbenp.prettier-vscode"] + } + } +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..3c367a6 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,14 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["unicorn", "typescript", "oxc"], + "categories": { + "correctness": "error", + "perf": "error", + "suspicious": "off", + "style": "off", + "nursery": "off", + "pedantic": "off", + "restriction": "off" + }, + "ignorePatterns": ["node_modules/", ".astro/", "dist/"] +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..30a4169 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "plugins": ["@prettier/plugin-oxc"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c25522..08833f3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,9 @@ { - "editor.tabSize": 2, - "editor.formatOnSave": true, - "editor.defaultFormatter": "biomejs.biome", - "[astro]": { - "editor.defaultFormatter": "astro-build.astro-vscode" - }, - "[css]": { - "editor.defaultFormatter": "biomejs.biome" - } + "editor.tabSize": 2, + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[astro]": { + "editor.defaultFormatter": "astro-build.astro-vscode" + }, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/README.md b/README.md index bfd37d2..1150fdc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Une plateforme de streaming moderne pour films et séries, construite avec **Ast ## ✨ Fonctionnalités - 🎨 **Design System complet** avec thème sombre et couleurs violet pastel -- 📱 **Responsive** avec système de grille flexbox (Bootstrap-like) +- 📱 **Responsive** avec système de grille flexbox (Bootstrap-like) - 🧩 **Composants UI auto-contenus** avec styles scoped - ⚡ **Performance optimisée** avec styles scoped par composant - 🎭 **Composants spécialisés** pour le streaming (MovieCard, SearchBar) @@ -43,6 +43,7 @@ Une plateforme de streaming moderne pour films et séries, construite avec **Ast ## 🎨 Design System ### Couleurs + - **Couleur principale** : Violet pastel (`--primary-*`) - **Thème sombre** avec nuances de gris - **Couleurs sémantiques** : success, warning, error, info @@ -50,6 +51,7 @@ Une plateforme de streaming moderne pour films et séries, construite avec **Ast ### Composants disponibles #### Composants de base + - **Button** - Boutons avec variantes (primary, secondary, outline, ghost) - **Badge** - Badges colorés - **Alert** - Alertes contextuelles @@ -57,36 +59,44 @@ Une plateforme de streaming moderne pour films et séries, construite avec **Ast - **Progress** - Barres de progression #### Composants de formulaire + - **Input** - Champs de saisie - **Textarea** - Zones de texte - **Select** - Listes déroulantes - **FormGroup/FormLabel/FormError** - Éléments de formulaire #### Composants de mise en page + - **Container** - Conteneur responsive - **Row/Col** - Système de grille avec breakpoints (xs, sm, md, lg, xl, xxl) - **Card** - Cartes avec header/body/footer #### Composants de navigation + - **Navbar** - Barre de navigation - **Modal** - Modales avec backdrop - **Dropdown** - Menus déroulants #### Composants spécialisés streaming + - **MovieCard** - Cartes pour films/séries avec poster, titre, rating - **SearchBar** - Barre de recherche avec icône ## 🏗️ Architecture des Composants ### Composition et réutilisation + Les composants sont conçus pour être composés ensemble : + - **SearchBar** utilise le composant **Input** avec des styles personnalisés - **MovieCard** compose avec le composant **Card** de base - **ModalHeader** utilise le composant **Button** pour la fermeture - Classes `.form-control-base` partagées entre Input, Select et Textarea ### Styles scoped + Chaque composant contient ses propres styles avec ` diff --git a/src/components/forms/LoginForm.astro b/src/components/forms/LoginForm.astro new file mode 100644 index 0000000..8c56f65 --- /dev/null +++ b/src/components/forms/LoginForm.astro @@ -0,0 +1,43 @@ +--- +export interface Props { + action: string | null | undefined; + error: ActionInputError<{ username: string; password: string }> | null; +} + +import type { ActionInputError } from "astro:actions"; +import Button from "../ui/Button.astro"; +import FormGroup from "../ui/FormGroup.astro"; +import FormLabel from "../ui/FormLabel.astro"; +import Input from "../ui/Input.astro"; +import FormError from "../ui/FormError.astro"; + +const { action, error } = Astro.props; +--- + +
+ + Nom d'utilisateur + + {error?.fields.username && {error.fields.username}} + + + + Mot de passe + + {error?.fields.password && {error.fields.password}} + + + + + +
diff --git a/src/components/ui/Container.astro b/src/components/ui/Container.astro index 5d0d85b..a0ee457 100644 --- a/src/components/ui/Container.astro +++ b/src/components/ui/Container.astro @@ -2,14 +2,20 @@ export interface Props { fluid?: boolean; class?: string; + style?: string; } -const { fluid = false, class: className = "", ...rest } = Astro.props; +const { + fluid = false, + class: className = "", + style = "", + ...rest +} = Astro.props; const baseClasses = fluid ? "container-fluid" : "container"; const classes = [baseClasses, className].filter(Boolean).join(" "); --- -
+
diff --git a/src/components/ui/__tests__/Alert.test.ts b/src/components/ui/__tests__/Alert.test.ts deleted file mode 100644 index f4a1c78..0000000 --- a/src/components/ui/__tests__/Alert.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Alert from "../Alert.astro"; - -describe("Alert", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Alert, { - slots: { default: "Alert message" }, - }); - - expect(result).toContain("Alert message"); - expect(result).toContain('class="alert alert-info"'); - expect(result).toContain(" { - const container = await AstroContainer.create(); - const variants = ["success", "warning", "error", "info"] as const; - - for (const variant of variants) { - const result = await container.renderToString(Alert, { - props: { variant }, - slots: { default: "Test message" }, - }); - - expect(result).toContain(`alert-${variant}`); - } - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Alert, { - props: { class: "custom-alert" }, - slots: { default: "Message" }, - }); - - expect(result).toContain("alert alert-info custom-alert"); - }); - - it("renders as div element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Alert, { - slots: { default: "Test" }, - }); - - expect(result).toContain('
{ - const container = await AstroContainer.create(); - const result = await container.renderToString(Alert, { - props: { role: "alert" }, - slots: { default: "Important message" }, - }); - - expect(result).toContain('role="alert"'); - }); -}); diff --git a/src/components/ui/__tests__/Badge.test.ts b/src/components/ui/__tests__/Badge.test.ts deleted file mode 100644 index 610bd24..0000000 --- a/src/components/ui/__tests__/Badge.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Badge from "../Badge.astro"; - -describe("Badge", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Badge, { - slots: { default: "New" }, - }); - - expect(result).toContain("New"); - expect(result).toContain("badge-primary"); - expect(result).toContain(" { - const container = await AstroContainer.create(); - const variants = [ - "primary", - "secondary", - "success", - "warning", - "error", - ] as const; - - for (const variant of variants) { - const result = await container.renderToString(Badge, { - props: { variant }, - slots: { default: "Badge" }, - }); - - expect(result).toContain(`badge-${variant}`); - } - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Badge, { - props: { class: "custom-badge" }, - slots: { default: "Test" }, - }); - - expect(result).toContain("badge badge-primary custom-badge"); - }); - - it("renders as span element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Badge, { - slots: { default: "Test" }, - }); - - expect(result).toContain(' { - const container = await AstroContainer.create(); - const result = await container.renderToString(Badge, { - props: { "data-count": "5" }, - slots: { default: "5" }, - }); - - expect(result).toContain('data-count="5"'); - }); -}); diff --git a/src/components/ui/__tests__/Button.test.ts b/src/components/ui/__tests__/Button.test.ts deleted file mode 100644 index ad70b4d..0000000 --- a/src/components/ui/__tests__/Button.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Button from "../Button.astro"; - -describe("Button", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Button, { - slots: { default: "Click me" }, - }); - - expect(result).toContain("Click me"); - expect(result).toContain('class="btn btn-primary"'); - expect(result).toContain('type="button"'); - expect(result).toContain(" { - const container = await AstroContainer.create(); - const variants = ["primary", "secondary", "outline", "ghost"] as const; - - for (const variant of variants) { - const result = await container.renderToString(Button, { - props: { variant }, - slots: { default: "Test" }, - }); - - expect(result).toContain(`btn-${variant}`); - } - }); - - it("renders different sizes", async () => { - const container = await AstroContainer.create(); - const sizes = ["sm", "lg"] as const; - - for (const size of sizes) { - const result = await container.renderToString(Button, { - props: { size }, - slots: { default: "Test" }, - }); - - expect(result).toContain(`btn-${size}`); - } - }); - - it("renders as anchor when href is provided", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Button, { - props: { href: "/test" }, - slots: { default: "Link" }, - }); - - expect(result).toContain(" { - const container = await AstroContainer.create(); - const result = await container.renderToString(Button, { - props: { disabled: true }, - slots: { default: "Disabled" }, - }); - - expect(result).toContain("disabled"); - }); - - it("applies icon styling", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Button, { - props: { icon: true }, - slots: { default: "🔍" }, - }); - - expect(result).toContain("btn-icon"); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Button, { - props: { class: "custom-class" }, - slots: { default: "Test" }, - }); - - expect(result).toContain("custom-class"); - }); - - it("handles different button types", async () => { - const container = await AstroContainer.create(); - const types = ["button", "submit", "reset"] as const; - - for (const type of types) { - const result = await container.renderToString(Button, { - props: { type }, - slots: { default: "Test" }, - }); - - expect(result).toContain(`type="${type}"`); - } - }); -}); diff --git a/src/components/ui/__tests__/Card.test.ts b/src/components/ui/__tests__/Card.test.ts deleted file mode 100644 index f664680..0000000 --- a/src/components/ui/__tests__/Card.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Card from "../Card.astro"; - -describe("Card", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Card, { - slots: { default: "Card content" }, - }); - - expect(result).toContain("Card content"); - expect(result).toContain('class="card"'); - expect(result).toContain(" { - const container = await AstroContainer.create(); - const result = await container.renderToString(Card, { - props: { class: "custom-card" }, - slots: { default: "Content" }, - }); - - expect(result).toContain("card custom-card"); - }); - - it("renders as div element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Card, { - slots: { default: "Test" }, - }); - - expect(result).toContain('
{ - const container = await AstroContainer.create(); - const result = await container.renderToString(Card, { - props: { "data-testid": "test-card" }, - slots: { default: "Test" }, - }); - - expect(result).toContain('data-testid="test-card"'); - }); -}); diff --git a/src/components/ui/__tests__/Col.test.ts b/src/components/ui/__tests__/Col.test.ts deleted file mode 100644 index b9bae02..0000000 --- a/src/components/ui/__tests__/Col.test.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Col from "../Col.astro"; - -describe("Col", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - slots: { default: "Column content" }, - }); - - expect(result).toContain("Column content"); - expect(result).toContain('class="col"'); - expect(result).toContain(" { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - props: { - xs: 12, - sm: 6, - md: 4, - lg: 3, - }, - slots: { default: "Content" }, - }); - - expect(result).toContain("col--12"); - expect(result).toContain("col-sm-6"); - expect(result).toContain("col-md-4"); - expect(result).toContain("col-lg-3"); - }); - - it("renders with auto sizing", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - props: { md: "auto" }, - slots: { default: "Content" }, - }); - - expect(result).toContain("col-md-auto"); - }); - - it("renders with offset classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - props: { - md: 6, - offset: { md: 3, lg: 2 }, - }, - slots: { default: "Content" }, - }); - - expect(result).toContain("col-md-6"); - expect(result).toContain("offset-md-3"); - expect(result).toContain("offset-lg-2"); - }); - - it("renders with xl and xxl breakpoints", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - props: { - xl: 4, - xxl: 2, - }, - slots: { default: "Content" }, - }); - - expect(result).toContain("col-xl-4"); - expect(result).toContain("col-xxl-2"); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - props: { - class: "custom-col", - md: 6, - }, - slots: { default: "Content" }, - }); - - expect(result).toContain("col-md-6"); - expect(result).toContain("custom-col"); - }); - - it("renders as div element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - slots: { default: "Test" }, - }); - - expect(result).toContain('
{ - const container = await AstroContainer.create(); - const result = await container.renderToString(Col, { - props: { "data-column": "main" }, - slots: { default: "Test" }, - }); - - expect(result).toContain('data-column="main"'); - }); -}); diff --git a/src/components/ui/__tests__/Container.test.ts b/src/components/ui/__tests__/Container.test.ts deleted file mode 100644 index 32a453c..0000000 --- a/src/components/ui/__tests__/Container.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Container from "../Container.astro"; - -describe("Container", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Container, { - slots: { default: "Container content" }, - }); - - expect(result).toContain("Container content"); - expect(result).toContain('class="container"'); - expect(result).toContain(" { - const container = await AstroContainer.create(); - const result = await container.renderToString(Container, { - props: { fluid: true }, - slots: { default: "Fluid content" }, - }); - - expect(result).toContain("Fluid content"); - expect(result).toContain('class="container-fluid"'); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Container, { - props: { class: "custom-container" }, - slots: { default: "Content" }, - }); - - expect(result).toContain("container custom-container"); - }); - - it("renders as div element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Container, { - slots: { default: "Test" }, - }); - - expect(result).toContain('
{ - const container = await AstroContainer.create(); - const result = await container.renderToString(Container, { - props: { "data-section": "main" }, - slots: { default: "Test" }, - }); - - expect(result).toContain('data-section="main"'); - }); -}); diff --git a/src/components/ui/__tests__/FormGroup.test.ts b/src/components/ui/__tests__/FormGroup.test.ts deleted file mode 100644 index 7d747e2..0000000 --- a/src/components/ui/__tests__/FormGroup.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import FormGroup from "../FormGroup.astro"; - -describe("FormGroup", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(FormGroup, { - slots: { default: "" }, - }); - - expect(result).toContain("Form content"); - expect(result).toContain('class="form-group"'); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(FormGroup, { - props: { class: "custom-form-group" }, - slots: { default: "Content" }, - }); - - expect(result).toContain("form-group custom-form-group"); - }); - - it("renders as div element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(FormGroup, { - slots: { default: "Test" }, - }); - - expect(result).toContain('
{ - const container = await AstroContainer.create(); - const result = await container.renderToString(FormGroup, { - props: { "data-testid": "form-section" }, - slots: { default: "Test" }, - }); - - expect(result).toContain('data-testid="form-section"'); - }); -}); diff --git a/src/components/ui/__tests__/Input.test.ts b/src/components/ui/__tests__/Input.test.ts deleted file mode 100644 index a4d863f..0000000 --- a/src/components/ui/__tests__/Input.test.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Input from "../Input.astro"; - -describe("Input", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input); - - expect(result).toContain(" { - const container = await AstroContainer.create(); - const types = [ - "text", - "email", - "password", - "number", - "tel", - "url", - "search", - ] as const; - - for (const type of types) { - const result = await container.renderToString(Input, { - props: { type }, - }); - - expect(result).toContain(`type="${type}"`); - } - }); - - it("renders different sizes", async () => { - const container = await AstroContainer.create(); - const sizes = ["sm", "lg"] as const; - - for (const size of sizes) { - const result = await container.renderToString(Input, { - props: { size }, - }); - - expect(result).toContain(`input-${size}`); - } - }); - - it("applies placeholder", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input, { - props: { placeholder: "Enter text" }, - }); - - expect(result).toContain('placeholder="Enter text"'); - }); - - it("applies value", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input, { - props: { value: "test value" }, - }); - - expect(result).toContain('value="test value"'); - }); - - it("applies name and id attributes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input, { - props: { name: "username", id: "user-input" }, - }); - - expect(result).toContain('name="username"'); - expect(result).toContain('id="user-input"'); - }); - - it("applies disabled state", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input, { - props: { disabled: true }, - }); - - expect(result).toContain("disabled"); - }); - - it("applies required attribute", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input, { - props: { required: true }, - }); - - expect(result).toContain("required"); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Input, { - props: { class: "custom-input" }, - }); - - expect(result).toContain("custom-input"); - }); -}); diff --git a/src/components/ui/__tests__/Modal.test.ts b/src/components/ui/__tests__/Modal.test.ts deleted file mode 100644 index eefd0e3..0000000 --- a/src/components/ui/__tests__/Modal.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import Modal from "../Modal.astro"; - -describe("Modal", () => { - it("renders with required id prop", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Modal, { - props: { id: "test-modal" }, - slots: { default: "Modal content" }, - }); - - expect(result).toContain('class="modal-backdrop"'); - expect(result).toContain('class="modal"'); - expect(result).toContain('id="test-modal"'); - expect(result).toContain("Modal content"); - }); - - it("starts hidden by default", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Modal, { - props: { id: "hidden-modal" }, - slots: { default: "Content" }, - }); - - expect(result).toContain('style="display: none;"'); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Modal, { - props: { - id: "custom-modal", - class: "custom-modal-class", - }, - slots: { default: "Content" }, - }); - - expect(result).toContain("modal-backdrop custom-modal-class"); - }); - - it("renders nested modal structure", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Modal, { - props: { id: "nested-modal" }, - slots: { default: "Nested content" }, - }); - - expect(result).toContain('class="modal-backdrop"'); - expect(result).toContain('class="modal"'); - expect(result).toContain("Nested content"); - }); - - it("passes through additional props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(Modal, { - props: { - id: "props-modal", - "data-testid": "modal-test", - }, - slots: { default: "Test" }, - }); - - expect(result).toContain('data-testid="modal-test"'); - }); -}); diff --git a/src/components/ui/__tests__/ModalBody.test.ts b/src/components/ui/__tests__/ModalBody.test.ts deleted file mode 100644 index 972a779..0000000 --- a/src/components/ui/__tests__/ModalBody.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { experimental_AstroContainer as AstroContainer } from "astro/container"; -import { describe, it, expect } from "vitest"; -import ModalBody from "../ModalBody.astro"; - -describe("ModalBody", () => { - it("renders with default props", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(ModalBody, { - slots: { default: "Modal body content" }, - }); - - expect(result).toContain("Modal body content"); - expect(result).toContain('class="modal-body"'); - }); - - it("applies custom classes", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(ModalBody, { - props: { class: "custom-body" }, - slots: { default: "Content" }, - }); - - expect(result).toContain("modal-body custom-body"); - }); - - it("renders as div element", async () => { - const container = await AstroContainer.create(); - const result = await container.renderToString(ModalBody, { - slots: { default: "Test" }, - }); - - expect(result).toContain('