Skip to content

Conversation

@jefische
Copy link
Contributor

@jefische jefische commented Oct 28, 2025

Description

Before:

The JourneyCard component lacked unit tests.

After:

Unit tests have been added for JourneyCard component:

  • renders the journey card using drawingDate and exchangeDate values
  • verifies the drawingDate value is displaying the expected long date format (e.g. 'October 27th, 2025')
  • verifies the exchangeDate value is displaying the expected long date format (e.g. 'November 20th, 2025')

Closes #196

Screenshot

image

Pre-submission checklist

  • Code builds and passes locally
  • PR title follows Conventional Commit format (e.g. test #001: created unit test for __ component)
  • Request reviews from the Peer Code Reviewers and Senior+ Code Reviewers groups
  • Thread has been created in Discord and PR is linked in gis-code-questions

@vercel
Copy link

vercel bot commented Oct 28, 2025

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

Project Deployment Preview Comments Updated (UTC)
elecretanta Ready Ready Preview Comment Nov 3, 2025 4:57pm
elecretanta-storybook Ready Ready Preview Comment Nov 3, 2025 4:57pm
elecretanta-unit-test Ready Ready Preview Comment Nov 3, 2025 4:57pm

@shashilo shashilo requested review from a team, Yassahr and nickytonline and removed request for a team, HoldUpFjord, alexappleget, bethanyann, jennifertieu, kepsteen, nickytonline and shashilo October 28, 2025 15:17

describe('JourneyCard Component', () => {

it('Renders the component given serialized ISO date string values', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be better. If you read the component top down, that's how it should be tested.

  1. Check that the component renders on screen
  2. Check that each step renders
  3. Check that the dynamic generated content renders properly

Instead of looking it up in the doc, find the index the dynamic content should be at. If we switched the order, this unit test would still be true when it should fail.

Copy link
Contributor Author

@jefische jefische Oct 31, 2025

Choose a reason for hiding this comment

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

Thanks for the detailed feedback. I went ahead and created 3 separate test scenarios to follow your outline above and included test-ids for each journey step to be able to look up by index. Now if the order of steps 1 or 4 change, which have the dynamic dates, the test will fail.

This is feeling closer to a complete test of the component, but let me know if I'm missing anything or my scenarios are off.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds test coverage for the JourneyCard component by introducing a new test file and adding test IDs to the component for easier DOM querying. The changes enable verification of the component's rendering behavior and date formatting logic.

  • Adds data-testid attributes to the card and journey steps for testing
  • Introduces comprehensive test suite covering component rendering and date display

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
components/JourneyCard/JourneyCard.tsx Adds test IDs to the Card and journey step elements for testability
components/JourneyCard/JourneyCard.test.tsx New test file with three test cases covering component rendering and date verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
import { JourneyCard } from './JourneyCard';
import { render, screen } from '@testing-library/react';
import { formatDate } from '@/lib/utils';
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Missing copyright header. Other test files in the codebase include '// Copyright (c) Gridiron Survivor.' and '// Licensed under the MIT License.' at the top of the file.

Copilot uses AI. Check for mistakes.
expect(journeyStepTwoElement).toBeInTheDocument();
expect(journeyStepThreeElement).toBeInTheDocument();
expect(journeyStepFourElement).toBeInTheDocument();

Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Remove trailing whitespace on line 28.

Suggested change

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create unit test for JourneyCard.tsx

3 participants