Skip to content

feat: show star rating on game cards - #142

Closed
DHLFRAGILE wants to merge 1 commit into
github-samples:mainfrom
DHLFRAGILE:feature/game-card-star-rating
Closed

DHLFRAGILE wants to merge 1 commit into
github-samples:mainfrom
DHLFRAGILE:feature/game-card-star-rating

Conversation

@DHLFRAGILE

Copy link
Copy Markdown

Description

Show each game's star rating (out of 5) on the listing page cards. When a game has no rating (null), the card shows "No rating yet". The card layout is otherwise unchanged.

Related Issue

None.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🧪 Test update
  • 🔧 Refactor (no functional changes)

Changes Made

  • GameCard.astro: add a rating line (star glyphs + x.x / 5, or "No rating yet") with data-testid="game-card-rating"
  • src/lib/ratings.ts: add formatRatingLabel helper (clamps to 0–5)
  • Unit tests for formatRatingLabel; E2E check that every card shows a rating or "No rating yet"

Testing

Ran unit tests, ESLint, typecheck:all, and the Playwright E2E suite locally; all pass.

Data Layer Changes

  • Ran npm run test:unit - all tests pass
  • Added/updated Vitest tests for data-layer changes
  • Generated a migration (npm run db:generate) for any schema change (no schema change)

Frontend Changes

  • Ran npm run test:e2e - all tests pass
  • Added data-testid attributes to interactive elements (no new interactive elements; rating text has a test id)
  • Verified build succeeds (npm run build) (built implicitly by test:e2e)

Checklist

  • My code follows the project's coding standards
  • I have used explicit TypeScript types for function parameters and return values
  • I have built the UI with Astro components and Tailwind CSS utility classes (dark theme)
  • I have updated documentation (README, instruction files) if needed (not needed)
  • My changes are focused on a single concern
  • I have written clear commit messages explaining what and why

Additional Notes

Targets github-samples/tailspin-toys:main from a fork branch.

Display each game's rating out of 5 on listing cards, or
"No rating yet" when the rating is null. Adds a formatRatingLabel
helper with unit tests and an E2E check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The E2E check can pass when some cards omit ratings, leaving the every-card requirement unverified.

1 open finding
What changed in this PR

Adds star ratings to game cards on the listing page, with “No rating yet” for unrated games.

Changes:

  • Displays star glyphs and a numeric rating label.
  • Adds a clamped rating-label helper and unit tests.
  • Adds an E2E check for card ratings.
File Description
src/​lib/​ratings.ts Adds rating-label formatting.
src/​lib/​ratings.test.ts Tests formatting, null values, and clamping.
src/​components/​GameCard.astro Displays each game’s rating.
e2e-tests/​games.spec.ts Adds listing-page rating assertions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread e2e-tests/games.spec.ts
Comment on lines +27 to +32
const ratings = page.getByTestId('game-card').getByTestId('game-card-rating');
const texts = await ratings.allTextContents();
expect(texts.length).toBeGreaterThan(0);
for (const text of texts) {
expect(text).toMatch(/\d\.\d \/ 5|No rating yet/);
}
@DHLFRAGILE DHLFRAGILE closed this Oct 16, 2026
@DHLFRAGILE DHLFRAGILE reopened this Oct 16, 2026
@GeekTrainer

Copy link
Copy Markdown
Collaborator

Thanks for working through the workshop! This matches the star-rating exercise, which is intended for your own copy of Tailspin Toys rather than this shared workshop template. I am closing this here so the upstream template keeps the starting point available for everyone.

Please reopen this work against your own repository. If you have not created one yet, select Use this template → Create a new repository on the Tailspin Toys template, then follow the workshop setup instructions.

If you intended this as an upstream bug report or contribution rather than a workshop exercise, please reply with that context so we can take another look. Thanks for participating!

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.

3 participants