Skip to content

Inline SVG logo to eliminate navigation flash#667

Merged
yamcodes merged 7 commits intomainfrom
copilot/optimize-header-icon-loading
Dec 29, 2025
Merged

Inline SVG logo to eliminate navigation flash#667
yamcodes merged 7 commits intomainfrom
copilot/optimize-header-icon-loading

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

Fix Header Logo Flash Issue ✅

The header logo SVG takes a second to load and flashes when switching between pages. This is because Next.js Image component processes SVGs which can cause delays.

Summary of Changes:

  • Explore repository and understand the issue
  • Inline the SVG directly in the Logo component instead of using Image component
  • Update tests to reflect the changes (SVG element instead of img)
  • Run tests to ensure changes work correctly (all 99 tests passing)
  • Use Tailwind theme colors instead of hardcoded hex values
  • Code review completed - addressed feedback about theme colors
  • Security scan completed - no vulnerabilities found
  • Improve test accessibility and remove implementation details

Technical Solution:

Replaced the <Image src="/assets/icon.svg"> component with an inline SVG element directly in the Logo component. This eliminates the HTTP request and Next.js image processing overhead, providing instant rendering without any flash during navigation.

Key Improvements:

  • Zero loading delay: SVG is now part of the component bundle
  • Theme-aware: Uses stroke-blue-500 dark:stroke-blue-400 and fill-blue-500 dark:fill-blue-400 for proper light/dark mode support
  • Same visual appearance: Maintains the exact same look and accessibility features
  • All tests passing: 99 tests pass including improved logo component tests
  • Better test practices: Tests now use accessibility-first querying and avoid testing implementation details

Files Changed:

  • apps/www/components/page/logo.tsx - Inlined SVG with theme colors
  • apps/www/components/page/logo.test.tsx - Improved test accessibility and removed implementation detail checks
Original prompt

This section details on the original issue you should resolve

<issue_title>Header icon takes a second to load</issue_title>
<issue_description>The header logo icon takes a second to load, which is especially noticeable when switching between the homepage and a docs page, where the ArkEnv logo text in the header seemingly stays but the logo flashes.

Maybe we should cache it or find a more performant way to store it (not svg? Maybe png?) or maybe somehow simplify or optimize the svg to work better within NextJS. </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Summary by CodeRabbit

  • Refactor

    • Logo rendering switched to an inline SVG for more consistent display and improved performance.
  • Tests

    • Updated tests to validate the logo's inline SVG rendering and container styling instead of an external image element.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 28, 2025

⚠️ No Changeset found

Latest commit: 6b4b150

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Replaced Next/Image usage with an inline SVG in the Logo component and updated tests to assert the inline SVG is rendered (checking SVG presence/attributes). No exported API changes.

Changes

Cohort / File(s) Summary
Logo component & tests
apps/www/components/page/logo.tsx, apps/www/components/page/logo.test.tsx
Removed next/image usage and img assertions; added inline <svg> (width/height, viewBox, two <path> elements). Tests now locate the ArkEnv text container and assert an inline SVG exists and has expected attributes/classes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I swapped the sprite for painted lines so neat,
No loading pause — the header's heartbeat,
Paths in a circle, sharp and spry,
Hop, little logo, blink and fly,
Tiny paws, big sunny try.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing Image with an inline SVG to prevent the navigation flash issue identified in the PR objectives.
Linked Issues check ✅ Passed The PR successfully addresses issue #666 by inlining the SVG to eliminate the external asset request and Next.js image processing delay that caused the navigation flash.
Out of Scope Changes check ✅ Passed All changes are directly scoped to addressing the header icon loading delay: SVG inlining, theme color integration, and test updates to validate the new SVG implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Dec 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
arkenv Ready Ready Preview, Comment Dec 29, 2025 6:41am

Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize header logo icon loading performance Inline SVG logo to eliminate navigation flash Dec 28, 2025
Copilot AI requested a review from yamcodes December 28, 2025 19:09
@yamcodes
Copy link
Owner

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/www/components/page/logo.test.tsx (2)

19-22: Consider refactoring the SVG query and viewBox assertion.

The document.querySelector("svg") approach bypasses accessibility-first querying, and checking the viewBox attribute tests an implementation detail rather than component behavior.

Since the SVG is decorative (aria-hidden="true" in the component), consider querying via the container or parent element instead, and remove the viewBox assertion as it doesn't affect user-facing behavior.

🔎 Alternative query approach
 it("renders the logo icon", () => {
 	render(<Logo />);
-	// Check for the inline SVG element
-	const svg = document.querySelector("svg");
+	const container = screen.getByText("ArkEnv").parentElement;
+	const svg = container?.querySelector("svg");
 	expect(svg).toBeInTheDocument();
-	expect(svg).toHaveAttribute("viewBox", "0 0 12 12");
 });

Based on coding guidelines and learnings emphasizing accessibility-first queries and testing behavior over implementation details.


38-40: Optional: Reconsider testing CSS classes.

The guidelines suggest avoiding tests that check pure styling or CSS classes. While this test maintains the existing pattern, consider whether the size-6 class assertion provides value for the component's public API contract.

Based on coding guidelines discouraging CSS class testing in favor of behavior testing.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc38f29 and 0bf3d92.

📒 Files selected for processing (2)
  • apps/www/components/page/logo.test.tsx
  • apps/www/components/page/logo.tsx
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) function (or default import as arkenv) to create validated environment objects in TypeScript
Use built-in validators (host, port, url, email) from ArkEnv when available instead of custom ArkType schemas
Provide default values for optional environment variables using ArkType syntax (e.g., 'boolean = false')
Use ArkEnvError for environment variable errors instead of generic Error types
For environment schema definition, use ArkType string literal syntax for enumerated values (e.g., "'deve...

Files:

  • apps/www/components/page/logo.tsx
  • apps/www/components/page/logo.test.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use self-closing JSX elements (useSelfClosingElements error)

Files:

  • apps/www/components/page/logo.tsx
  • apps/www/components/page/logo.test.tsx
apps/www/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/www/.cursor/rules/posthog-integration.mdc)

apps/www/**/*.{ts,tsx,js,jsx}: If using TypeScript, use an enum to store feature flag names. If using JavaScript, store feature flag names as strings to an object declared as a constant to simulate an enum. Use UPPERCASE_WITH_UNDERSCORE naming convention for enum/const object members.
If a custom property for a person or event is referenced in two or more files or two or more callsites in the same file, use an enum or const object with UPPERCASE_WITH_UNDERSCORE naming convention, similar to feature flags.

Files:

  • apps/www/components/page/logo.tsx
  • apps/www/components/page/logo.test.tsx
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Co-locate tests with components: Component.tsx next to Component.test.tsx

**/*.test.{ts,tsx}: Use Vitest for unit and integration tests
Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Unit tests should focus on individual function logic and edge cases, component rendering and props, error handling and validation, and type checking
Unit tests should execute in less than 100ms per test
Mock external dependencies (clipboard, network, etc.) in unit tests
Co-locate unit test files with source files using naming convention: source file → test file (e.g., create-env.ts → create-env.test.ts)
Test component behavior, not aesthetics, and focus on what users can do and what the component guarantees through its API
Test component public API (props, events, and component contract), user behavior (clicks, typing, focus, keyboard, ARIA), state transitions, accessibility, and side effects in component tests
Do not test pure styling or CSS classes, library internals (Radix/shadcn), implementation details (hooks, setState, private variables), or visual variants in component tests
Use Testing Library with user-event for real user simulation in component tests
Query by role, name, label, and text (accessibility first) in component tests
Use beforeEach/afterEach for cleanup, not beforeAll/afterAll when possible
Keep tests fast, deterministic, and parallelizable
Mock at component boundaries (network, time, context)

Create unit tests with .test.ts or .test.tsx suffix located alongside source files, testing individual functions and components in isolation with mocked dependencies

Files:

  • apps/www/components/page/logo.test.tsx
**/*.{test,integration.test}.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{test,integration.test}.{ts,tsx}: Use Vitest's describe/it structure for all test files
Test both success and failure cases in unit and integration tests
Mock process.env in unit tests to test different environment variable scenarios

Files:

  • apps/www/components/page/logo.test.tsx
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Test component public API (props, events, and component contract), user behavior (clicks, typing, focus, keyboard, ARIA), state transitions, accessibility, and side effects in component tests
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Test component behavior, not aesthetics, and focus on what users can do and what the component guarantees through its API
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Test component public API (props, events, and component contract), user behavior (clicks, typing, focus, keyboard, ARIA), state transitions, accessibility, and side effects in component tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Test component behavior, not aesthetics, and focus on what users can do and what the component guarantees through its API

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Do not test pure styling or CSS classes, library internals (Radix/shadcn), implementation details (hooks, setState, private variables), or visual variants in component tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Unit tests should focus on individual function logic and edge cases, component rendering and props, error handling and validation, and type checking

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Integration tests should focus on component and hook interactions, function composition and data flow, real dependencies between units, and state synchronization across boundaries

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-23T07:09:57.130Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-23T07:09:57.130Z
Learning: Applies to **/*.{test,integration.test}.{ts,tsx} : Test both success and failure cases in unit and integration tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Query by role, name, label, and text (accessibility first) in component tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Test how multiple units (components, hooks, functions) work together without mocking their interactions in integration tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to tooling/playwright-www/**/*.{ts,tsx} : End-to-end tests should focus on user-facing behavior, not implementation details

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-23T07:09:57.130Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-23T07:09:57.130Z
Learning: Applies to **/*.test.{ts,tsx} : Create unit tests with `.test.ts` or `.test.tsx` suffix located alongside source files, testing individual functions and components in isolation with mocked dependencies

Applied to files:

  • apps/www/components/page/logo.test.tsx
🔇 Additional comments (1)
apps/www/components/page/logo.tsx (1)

12-43: LGTM! Inline SVG successfully eliminates external asset loading.

The implementation correctly replaces the Image component with an inline SVG, using Tailwind theme classes for color support and aria-hidden="true" for decorative content. The mix of Tailwind classes and inline styles is appropriate for SVG-specific properties that lack Tailwind equivalents.

@yamcodes yamcodes marked this pull request as ready for review December 28, 2025 20:45
@github-actions github-actions bot added www Improvements or additions to arkenv.js.org tests This issue or PR is about adding, removing or changing tests labels Dec 28, 2025
@yamcodes
Copy link
Owner

@copilot

apps/www/components/page/logo.test.tsx (2)

1-
19-22: Consider refactoring the SVG query and viewBox assertion.

The document.querySelector("svg") approach bypasses accessibility-first querying, and checking the viewBox attribute tests an implementation detail rather than component behavior.

Since the SVG is decorative (aria-hidden="true" in the component), consider querying via the container or parent element instead, and remove the viewBox assertion as it doesn't affect user-facing behavior.

2-

38-40: Optional: Reconsider testing CSS classes.

The guidelines suggest avoiding tests that check pure styling or CSS classes. While this test maintains the existing pattern, consider whether the size-6 class assertion provides value for the component's public API contract.

Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 28, 2025

@copilot

apps/www/components/page/logo.test.tsx (2)
...

Updated the test in commit cbf88b4:

  1. SVG querying: Changed from document.querySelector("svg") to querying via the container element (logoText.parentElement?.querySelector("svg")), following accessibility-first practices similar to other tests in the codebase.

  2. Removed viewBox assertion: Eliminated the viewBox attribute check as it tests implementation details rather than component behavior.

  3. Removed size-6 class assertion: Removed the CSS class check from the "applies default styling classes" test, as it doesn't provide value for the component's public API contract.

@yamcodes
Copy link
Owner

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/www/components/page/logo.test.tsx (1)

26-38: Remove CSS class assertions per coding guidelines.

This test violates the explicit coding guideline: "Do not test pure styling or CSS classes."

Testing Tailwind utility classes (flex, items-center, gap-2, font-medium, text-fd-foreground, text-sm) creates brittle coupling to styling implementation. These tests will break if you refactor styles (e.g., switching to CSS modules or different utility classes) even when visual appearance remains identical.

Recommendation: Remove this entire test case. Component styling is an implementation detail, not part of the public API contract.

Based on coding guidelines and your optional PR comment about reconsidering CSS class tests.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bf3d92 and cbf88b4.

📒 Files selected for processing (1)
  • apps/www/components/page/logo.test.tsx
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) function (or default import as arkenv) to create validated environment objects in TypeScript
Use built-in validators (host, port, url, email) from ArkEnv when available instead of custom ArkType schemas
Provide default values for optional environment variables using ArkType syntax (e.g., 'boolean = false')
Use ArkEnvError for environment variable errors instead of generic Error types
For environment schema definition, use ArkType string literal syntax for enumerated values (e.g., "'deve...

Files:

  • apps/www/components/page/logo.test.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use self-closing JSX elements (useSelfClosingElements error)

Files:

  • apps/www/components/page/logo.test.tsx
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Co-locate tests with components: Component.tsx next to Component.test.tsx

**/*.test.{ts,tsx}: Use Vitest for unit and integration tests
Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Unit tests should focus on individual function logic and edge cases, component rendering and props, error handling and validation, and type checking
Unit tests should execute in less than 100ms per test
Mock external dependencies (clipboard, network, etc.) in unit tests
Co-locate unit test files with source files using naming convention: source file → test file (e.g., create-env.ts → create-env.test.ts)
Test component behavior, not aesthetics, and focus on what users can do and what the component guarantees through its API
Test component public API (props, events, and component contract), user behavior (clicks, typing, focus, keyboard, ARIA), state transitions, accessibility, and side effects in component tests
Do not test pure styling or CSS classes, library internals (Radix/shadcn), implementation details (hooks, setState, private variables), or visual variants in component tests
Use Testing Library with user-event for real user simulation in component tests
Query by role, name, label, and text (accessibility first) in component tests
Use beforeEach/afterEach for cleanup, not beforeAll/afterAll when possible
Keep tests fast, deterministic, and parallelizable
Mock at component boundaries (network, time, context)

Create unit tests with .test.ts or .test.tsx suffix located alongside source files, testing individual functions and components in isolation with mocked dependencies

Files:

  • apps/www/components/page/logo.test.tsx
apps/www/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/www/.cursor/rules/posthog-integration.mdc)

apps/www/**/*.{ts,tsx,js,jsx}: If using TypeScript, use an enum to store feature flag names. If using JavaScript, store feature flag names as strings to an object declared as a constant to simulate an enum. Use UPPERCASE_WITH_UNDERSCORE naming convention for enum/const object members.
If a custom property for a person or event is referenced in two or more files or two or more callsites in the same file, use an enum or const object with UPPERCASE_WITH_UNDERSCORE naming convention, similar to feature flags.

Files:

  • apps/www/components/page/logo.test.tsx
**/*.{test,integration.test}.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{test,integration.test}.{ts,tsx}: Use Vitest's describe/it structure for all test files
Test both success and failure cases in unit and integration tests
Mock process.env in unit tests to test different environment variable scenarios

Files:

  • apps/www/components/page/logo.test.tsx
🧠 Learnings (10)
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Test component public API (props, events, and component contract), user behavior (clicks, typing, focus, keyboard, ARIA), state transitions, accessibility, and side effects in component tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Do not test pure styling or CSS classes, library internals (Radix/shadcn), implementation details (hooks, setState, private variables), or visual variants in component tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Test component behavior, not aesthetics, and focus on what users can do and what the component guarantees through its API

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Integration tests should focus on component and hook interactions, function composition and data flow, real dependencies between units, and state synchronization across boundaries

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.test.{ts,tsx} : Unit tests should focus on individual function logic and edge cases, component rendering and props, error handling and validation, and type checking

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.test.{ts,tsx} : Co-locate tests with components: `Component.tsx` next to `Component.test.tsx`

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-23T07:09:57.130Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-23T07:09:57.130Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Create integration tests with `.integration.test.ts` or `.integration.test.tsx` suffix, testing how multiple units work together without mocking their interactions (except external APIs)

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-23T07:09:57.130Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-23T07:09:57.130Z
Learning: Applies to **/*.test.{ts,tsx} : Create unit tests with `.test.ts` or `.test.tsx` suffix located alongside source files, testing individual functions and components in isolation with mocked dependencies

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-26T19:27:11.710Z
Learnt from: danciudev
Repo: yamcodes/arkenv PR: 614
File: packages/vite-plugin/src/index.test.ts:641-654
Timestamp: 2025-12-26T19:27:11.710Z
Learning: In packages/vite-plugin/src/**/*.test.ts: The test suite uses `env.test` files (without leading dot) as test fixtures that are manually read by the `readTestConfig` helper function and stubbed into process.env with `vi.stubEnv`, not as files to be read by Vite's loadEnv during tests.

Applied to files:

  • apps/www/components/page/logo.test.tsx
📚 Learning: 2025-12-12T13:20:01.954Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-12-12T13:20:01.954Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Test how multiple units (components, hooks, functions) work together without mocking their interactions in integration tests

Applied to files:

  • apps/www/components/page/logo.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
🔇 Additional comments (1)
apps/www/components/page/logo.test.tsx (1)

40-46: LGTM - Tests public API contract.

This test correctly validates the component's public API by verifying that the className prop is accepted and applied. Unlike the previous test, this doesn't assert internal styling decisions but rather tests the component's prop contract.

Comment on lines 17 to 24
it("renders the logo icon", () => {
render(<Logo />);
// Check for the image element
const img = document.querySelector("img");
expect(img).toBeInTheDocument();
expect(img).toHaveAttribute(
"src",
expect.stringContaining("/assets/icon.svg"),
);
// Check for the inline SVG element via the container
const logoText = screen.getByText("ArkEnv");
const container = logoText.parentElement;
const svg = container?.querySelector("svg");
expect(svg).toBeInTheDocument();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Remove or refactor test to focus on behavior rather than implementation details.

This test violates the coding guidelines in multiple ways:

  • Uses querySelector("svg") instead of accessibility-first queries
  • Tests implementation details (that the logo uses an SVG element internally)
  • Since the SVG is decorative (aria-hidden="true" per PR description), it shouldn't be queried directly

The first test already confirms the Logo component renders successfully by verifying the "ArkEnv" text appears. Testing the internal rendering mechanism provides minimal value and couples the test to implementation rather than behavior.

Recommendation: Remove this test entirely. If specific visual behavior needs verification (e.g., logo displays correctly), consider visual regression testing instead.

Based on coding guidelines: "Do not test implementation details" and "Query by role, name, label, and text (accessibility first)". This aligns with your own PR comment flagging the same concern.

🤖 Prompt for AI Agents
In apps/www/components/page/logo.test.tsx around lines 17 to 24, remove the
entire test that queries container.querySelector("svg") because it tests
implementation details (that the logo uses an SVG) and uses a non-accessibility
query; delete this test block entirely (or replace it with a behavior-focused
assertion that only verifies visible text "ArkEnv" or an accessible role/label
if needed), relying on visual regression for presentation checks.

@yamcodes yamcodes merged commit 4de02bc into main Dec 29, 2025
12 of 13 checks passed
@yamcodes yamcodes deleted the copilot/optimize-header-icon-loading branch December 29, 2025 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests This issue or PR is about adding, removing or changing tests www Improvements or additions to arkenv.js.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Header icon takes a second to load

2 participants