Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions __tests__/loading-skeleton-responsive.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Issue #275 – Implement responsive sizing layouts on loading_spinner_skeleton
*
* Verifies that the LoadingSkeleton component resizes and stacks
* responsively across mobile, tablet, and desktop viewports.
*/
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import LoadingSkeleton from "@/app/components/LoadingSkeleton";

describe("LoadingSkeleton – responsive sizing layout (issue #275)", () => {
it("root wrapper spans the full available width", () => {
render(<LoadingSkeleton />);
expect(screen.getByTestId("loading-skeleton")).toHaveClass("w-full");
});

it("card wrapper uses responsive padding (p-4 on mobile, sm:p-6 on larger screens)", () => {
render(<LoadingSkeleton />);
const card = screen.getByTestId("loading-skeleton-card");
expect(card).toHaveClass("p-4");
expect(card).toHaveClass("sm:p-6");
});

it("card wrapper uses responsive vertical spacing (space-y-4 / sm:space-y-6)", () => {
render(<LoadingSkeleton />);
const card = screen.getByTestId("loading-skeleton-card");
expect(card).toHaveClass("space-y-4");
expect(card).toHaveClass("sm:space-y-6");
});

it("stats grid stacks to a single column on mobile", () => {
render(<LoadingSkeleton />);
expect(screen.getByTestId("loading-skeleton-stats")).toHaveClass("grid-cols-1");
});

it("stats grid expands to two columns on tablet (sm:grid-cols-2)", () => {
render(<LoadingSkeleton />);
expect(screen.getByTestId("loading-skeleton-stats")).toHaveClass("sm:grid-cols-2");
});

it("stats grid expands to three columns on desktop (md:grid-cols-3)", () => {
render(<LoadingSkeleton />);
expect(screen.getByTestId("loading-skeleton-stats")).toHaveClass("md:grid-cols-3");
});

it("header stacks vertically on mobile and switches to a row on sm+ (flex-col / sm:flex-row)", () => {
render(<LoadingSkeleton />);
const card = screen.getByTestId("loading-skeleton-card");
const header = card.firstElementChild as HTMLElement;
expect(header).toHaveClass("flex-col");
expect(header).toHaveClass("sm:flex-row");
});

it("milestone rows use responsive padding (p-3 on mobile, sm:p-4 on larger screens)", () => {
render(<LoadingSkeleton />);
const rows = screen.getByTestId("loading-skeleton-rows");
const firstRow = rows.firstElementChild as HTMLElement;
expect(firstRow).toHaveClass("p-3");
expect(firstRow).toHaveClass("sm:p-4");
});

it("still renders the accessible loading status region", () => {
render(<LoadingSkeleton />);
expect(screen.getByRole("status")).toHaveAttribute("aria-live", "polite");
expect(screen.getByText("Loading job data…")).toBeInTheDocument();
});
});
41 changes: 24 additions & 17 deletions app/components/LoadingSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
export default function LoadingSkeleton() {
return (
<div className="animate-pulse" role="status" aria-live="polite">
<div className="animate-pulse w-full" role="status" aria-live="polite" data-testid="loading-skeleton">
<span className="sr-only">Loading job data…</span>
<div className="border border-gray-800 rounded-xl bg-gray-900 p-6 space-y-6" aria-hidden="true">
<div className="flex items-center justify-between mb-6">
<div>
<div className="h-6 w-32 bg-gray-800 rounded mb-2"></div>
<div className="h-4 w-24 bg-gray-800 rounded"></div>
<div
className="border border-gray-800 rounded-xl bg-gray-900 p-4 sm:p-6 space-y-4 sm:space-y-6"
aria-hidden="true"
data-testid="loading-skeleton-card"
>
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 mb-4 sm:mb-6">
<div className="space-y-2">
<div className="h-6 w-24 sm:w-32 bg-gray-800 rounded"></div>
<div className="h-4 w-20 sm:w-24 bg-gray-800 rounded"></div>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div
className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3 sm:gap-4 mb-4 sm:mb-6"
data-testid="loading-skeleton-stats"
>
<div className="bg-gray-800 rounded-lg p-3">
<div className="h-4 w-12 bg-gray-700 rounded mb-2"></div>
<div className="h-4 w-28 bg-gray-700 rounded"></div>
<div className="h-4 w-full sm:w-28 bg-gray-700 rounded"></div>
</div>
<div className="bg-gray-800 rounded-lg p-3">
<div className="h-4 w-12 bg-gray-700 rounded mb-2"></div>
<div className="h-4 w-28 bg-gray-700 rounded"></div>
<div className="h-4 w-full sm:w-28 bg-gray-700 rounded"></div>
</div>
<div className="bg-gray-800 rounded-lg p-3">
<div className="h-4 w-12 bg-gray-700 rounded mb-2"></div>
<div className="h-4 w-28 bg-gray-700 rounded"></div>
<div className="h-4 w-full sm:w-28 bg-gray-700 rounded"></div>
</div>
</div>
<div className="space-y-4">
<div className="border border-gray-800 rounded-lg p-4 bg-gray-900">
<div className="h-4 w-24 bg-gray-800 rounded mb-2"></div>
<div className="h-4 w-32 bg-gray-800 rounded"></div>
<div className="space-y-3 sm:space-y-4" data-testid="loading-skeleton-rows">
<div className="border border-gray-800 rounded-lg p-3 sm:p-4 bg-gray-900">
<div className="h-4 w-20 sm:w-24 bg-gray-800 rounded mb-2"></div>
<div className="h-4 w-full sm:w-32 bg-gray-800 rounded"></div>
</div>
<div className="border border-gray-800 rounded-lg p-4 bg-gray-900">
<div className="h-4 w-24 bg-gray-800 rounded mb-2"></div>
<div className="h-4 w-32 bg-gray-800 rounded"></div>
<div className="border border-gray-800 rounded-lg p-3 sm:p-4 bg-gray-900">
<div className="h-4 w-20 sm:w-24 bg-gray-800 rounded mb-2"></div>
<div className="h-4 w-full sm:w-32 bg-gray-800 rounded"></div>
</div>
</div>
</div>
Expand Down