Skip to content

feat: Add tessoku book to contest table (#2776)#2780

Merged
KATO-Hiro merged 8 commits intostagingfrom
#2776
Nov 2, 2025
Merged

feat: Add tessoku book to contest table (#2776)#2780
KATO-Hiro merged 8 commits intostagingfrom
#2776

Conversation

@KATO-Hiro
Copy link
Collaborator

@KATO-Hiro KATO-Hiro commented Nov 2, 2025

close #2776
See #662

Summary by CodeRabbit

  • New Features

    • Added Tessoku Book contest support with provider registration, filtering, metadata, and custom display behavior.
  • Tests

    • Added and refactored comprehensive tests for the Tessoku Book provider covering filtering, metadata, display, headers, round labeling, multi-source and edge cases, empty inputs, and parity with other providers; introduced centralized mock/test scaffolding.
  • Documentation

    • Added a phased test plan detailing scope, rollout phases, test specs, and timeline.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 2025

Walkthrough

Adds a TessokuBookProvider class and registers it in provider presets/groups, introduces Tessoku Book mock fixtures and test cases, updates tests to include and re-export the provider, and adds a planning document for expanding and refactoring ContestTableProvider tests.

Changes

Cohort / File(s) Summary
Documentation & Plan
docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md
Adds a detailed plan for adding and refactoring ContestTableProvider tests: scope, phased rollout, test specs for TessokuBookProvider, centralized mock management, checklists, lessons learned, and timelines.
Provider Implementation
src/lib/utils/contest_table_provider.ts
Adds TessokuBookProvider (extends ContestTableProviderBase) with filter based on classifyContest(contest_id) === ContestType.TESSOKU_BOOK, metadata title "競技プログラミングの鉄則" (abbr "tessoku-book"), display config (hide headers and round labels, set body width, show task indices), getContestRoundLabel returns empty; registers TessokuBook preset and exposes tessokuBook in contestTableProviderGroups.
Test Suite
src/test/lib/utils/contest_table_provider.test.ts
Adds and runs comprehensive tests for TessokuBookProvider (filtering, metadata, display config, round label, header/round IDs, empty and mixed input cases), re-exports TessokuBookProvider, and extends test mocks/classifier to recognize tessoku-book.
Test Fixtures
src/test/lib/utils/test_cases/contest_table_provider.ts
Adds taskResultsForTessokuBookProvider export and creates tessoku_* mock tasks via createContestTasks(...), updating task identifiers and taskTableIndex/statusName mappings to support TessokuBookProvider tests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Tests as Test harness / UI
  participant Group as ContestTableProviderGroup
  participant Provider as TessokuBookProvider
  participant Classifier as classifyContest
  participant Generator as TableGenerator

  rect rgb(240,248,255)
    Tests->>Group: request provider "tessokuBook"
    Group->>Provider: instantiate / request rows
  end

  rect rgb(245,255,240)
    Provider->>Classifier: classifyContest(contest_id)
    Classifier-->>Provider: ContestType.TESSOKU_BOOK
    Provider->>Provider: setFilterCondition() → filter tessoku-book tasks
    Provider->>Generator: generate rows using displayConfig (hide headers/round labels, show indices)
    Generator-->>Tests: table rows / rendered structure
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus review on:
    • filter condition correctness and edge-case contest_id classification
    • provider registration and integration into presets/groups
    • i18n literal placement for the title/abbr
    • test fixtures alignment with expected task indices and exported taskResultsForTessokuBookProvider
    • re-exports to ensure public API consistency

Poem

🐰 I found new tessoku trails to chart,
Mocked tasks ready, every part,
A provider snug in preset rows,
Tests hop through where logic flows —
Click, assert, repeat — and off I dart!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat: Add tessoku book to contest table (#2776)" is clear, concise, and directly summarizes the main changes. It accurately reflects the primary objective of adding TessokuBookProvider support to the contest table system. The title avoids vague terminology and provides enough specificity that a reviewer can understand the feature being added.
Linked Issues Check ✅ Passed The linked issue #2776 requests enabling tessoku book problem imports in the contest table. The PR implementation directly addresses this requirement by introducing a new TessokuBookProvider class that extends ContestTableProviderBase with appropriate filtering logic for ContestType.TESSOKU_BOOK, registering it in the provider presets system, configuring display settings with title "競技プログラミングの鉄則", and providing comprehensive test coverage. All code changes align with the stated objective of supporting tessoku book problems.
Out of Scope Changes Check ✅ Passed The PR changes consist of the TessokuBookProvider implementation, corresponding test suite, test case fixtures, and a development planning document. The core implementation changes (TessokuBookProvider class, test files, and mock data) are directly in scope for the requirement to enable tessoku book support. The plan.md development notes document, while tangentially related to testing strategy, is housed in the dev-notes directory and represents planning documentation rather than out-of-scope implementation of unrelated features.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch #2776

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 0ba5c3a and cb3bcc4.

📒 Files selected for processing (4)
  • docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1 hunks)
  • src/lib/utils/contest_table_provider.ts (3 hunks)
  • src/test/lib/utils/contest_table_provider.test.ts (3 hunks)
  • src/test/lib/utils/test_cases/contest_table_provider.ts (2 hunks)
⏰ 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). (1)
  • GitHub Check: preview
🔇 Additional comments (7)
src/test/lib/utils/contest_table_provider.test.ts (2)

33-34: LGTM! Mock correctly handles the new contest type.

The mock for tessoku-book is consistent with other contest type classifications in the test suite.


357-493: Excellent test coverage for TessokuBookProvider!

The test suite comprehensively validates all aspects of the provider:

  • Filtering logic and metadata
  • Display configuration matching the grid layout requirements
  • Proper handling of mixed problem sources (math_and_algorithm, typical90, abc)
  • Correct alphanumeric sorting across sections (A01-A77, B01-B69, C01-C20)
  • Edge cases (empty input, mixed contest types)

The tests follow established patterns from Typical90Provider and maintain consistency with the existing test suite.

src/test/lib/utils/test_cases/contest_table_provider.ts (1)

199-298: Well-structured test data for TessokuBook.

The test fixture properly represents the mixed-source nature of Tessoku Book problems, covering:

  • Multiple problem sources (tessoku_book, math_and_algorithm, typical90, dp, abc)
  • All three sections (A, B, C) with representative samples
  • Various submission statuses for comprehensive testing

The export is correctly structured for use in the test suite.

src/lib/utils/contest_table_provider.ts (3)

242-269: LGTM! TessokuBookProvider implementation follows established patterns.

The implementation is consistent with other single-contest providers (Typical90, EDPC, TDPC):

  • Filtering logic correctly uses classifyContest for type-based filtering
  • Display configuration appropriately hides headers and round labels while showing task indices
  • Table width configuration (2xl:w-1/7) accommodates the large number of problems
  • Metadata accurately reflects the contest name and abbreviation

516-523: Preset registration is correct and consistent.

The TessokuBook preset follows the established pattern for single-contest providers, with appropriate metadata and provider registration.


550-550: Export correctly added to provider groups.

The tessokuBook entry properly exposes the TessokuBook provider group for application usage.

docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1)

1-833: Well-documented implementation plan.

This planning document provides excellent context for the TessokuBookProvider implementation, including specifications, test strategies, and lessons learned. The documentation will be valuable for future provider additions.

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

🧹 Nitpick comments (1)
docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1)

948-956: Add a language tag to the process diagram code block.

markdownlint flags this fence (MD040). Label it (e.g., text) so the doc passes lint and renders consistently.

-```
+```text
 フェーズ1(計画・テスト設計)
  ↓
 フェーズ1.5(実装)
  ↓
 フェーズ2(テスト強化・既存プロバイダー検証)
  ↓
 フェーズ3(最適化・ドキュメント同期)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between cb3bcc4 and 8b5b723.

📒 Files selected for processing (3)
  • docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1 hunks)
  • src/test/lib/utils/contest_table_provider.test.ts (6 hunks)
  • src/test/lib/utils/test_cases/contest_table_provider.ts (2 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md

947-947: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ 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). (1)
  • GitHub Check: preview

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: 3

🧹 Nitpick comments (2)
src/test/lib/utils/contest_table_provider.test.ts (2)

81-161: Excellent refactoring: Parameterized tests reduce duplication.

The use of describe.each() to test common behavior across ABCLatest20RoundsProvider, ABC319OnwardsProvider, and ABC212ToABC318Provider is a solid improvement. This approach:

  • Reduces code duplication
  • Ensures consistent test coverage across similar providers
  • Makes it easier to add new common test cases

The structure maintains readability while being more maintainable.


555-598: Nice refactoring: EDPC/TDPC parameterization reduces duplication.

The parameterized tests for EDPCProvider and TDPCProvider eliminate ~60 lines of duplicate code while maintaining full test coverage. The structure is clean and easy to extend for additional similar providers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 8b5b723 and 9607f5d.

📒 Files selected for processing (3)
  • docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1 hunks)
  • src/test/lib/utils/contest_table_provider.test.ts (6 hunks)
  • src/test/lib/utils/test_cases/contest_table_provider.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/lib/utils/test_cases/contest_table_provider.ts
⏰ 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). (1)
  • GitHub Check: preview
🔇 Additional comments (8)
src/test/lib/utils/contest_table_provider.test.ts (7)

14-14: LGTM: TessokuBookProvider properly imported.

The TessokuBookProvider is correctly added to the imports alongside other provider classes.


33-34: LGTM: Mock correctly handles tessoku-book contest type.

The mock function properly maps 'tessoku-book' to ContestType.TESSOKU_BOOK, ensuring test isolation.


417-430: LGTM: TessokuBookProvider filtering test is comprehensive.

The test correctly verifies that only tessoku-book contest tasks are included and that tasks from other contests are properly excluded. The use of mixed task sources (abc123, tessoku_book_a, math_and_algorithm_ai, typical90_a) provides good coverage.


490-503: LGTM: Header ID ordering test is thorough.

This test properly verifies that header IDs are returned in ascending order across all sections (A01, A06, A77, B07, B63, C09). The explicit ordering validation with toEqual() ensures sort stability.


517-530: Excellent boundary testing for section ranges.

This test validates all section boundaries (A01-A77, B01-B69, C01-C20) comprehensively. Testing the exact start and end values for each section helps catch off-by-one errors and ensures the implementation handles edge cases correctly.


539-552: LGTM: Mixed contest type filtering is properly tested.

The test correctly validates that when multiple contest types are present, only tessoku-book tasks are retained. The length assertion (toHaveLength(3)) combined with the every() check provides strong validation.


460-477: No issues found - test correctly uses valid TaskResult property.

The test on line 475 correctly uses task_id as the property name. The TaskResult type, which extends Task, includes the task_id property defined in the Task interface, so the expect.objectContaining({ task_id: 'math_and_algorithm_ai' }) assertion will properly validate that the returned object contains the expected task identifier.

docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1)

534-762: LGTM: Implementation report is comprehensive and valuable.

The completed checklist, performance metrics, and lessons learned sections provide excellent documentation of the implementation process. The measured efficiency gains (31 minutes vs. 5 days planned) and the learning curve improvements (0 debug cycles in phases 2-3) demonstrate effective iterative development.

The integration of lessons learned from previous work (task_results.test.ts) into this implementation is particularly noteworthy and should serve as a template for future test development.

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)
docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (2)

315-376: Consider documenting mock data ordering strategy.

The mock data fixture is intentionally unsorted (A01, A06, A27, A29, A39, A63, A77, B07, B16, B28, B63, C09, C18), which appears designed to verify that the provider's sorting logic works correctly. However, this isn't explicitly stated in the commentary. Adding a brief note explaining why the fixture is unsorted would clarify the test design intent for future maintainers.

Suggested addition to line 312-313:

 モックは `src/test/lib/utils/test_cases/contest_table_provider.ts` に統合管理:
+// Note: Mock data is intentionally unsorted to verify provider-level sorting behavior

708-714: Provide context for the describe.each() consolidation strategy.

The Phase 3 consolidation example (lines 708-714) compresses EDPC and TDPC tests into a parameterized describe block. While this improves maintainability, consider adding a note about why EDPC and TDPC were candidates for consolidation (e.g., >90% test logic overlap mentioned at line 701) and why others (like ABC) were not fully consolidated, to guide future decisions on parameterization.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 9607f5d and 2d326f1.

📒 Files selected for processing (1)
  • docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (1 hunks)
⏰ 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). (1)
  • GitHub Check: preview
🔇 Additional comments (5)
docs/dev-notes/2025-11-01/add_and_refactoring_tests_for_contest_table_provider/plan.md (5)

72-307: Documentation test specifications are comprehensive and well-aligned.

All 11 test cases are clearly specified with proper examples, expected values, and verification methods. Code examples correctly use ContestType.TESSOKU_BOOK, task_id, and task_table_index throughout (addressing all past review comments). Test coverage spans filtering, metadata, display config, sorting, boundaries, and edge cases—solid specification completeness.


534-556: Verify Phase 3 test consolidation maintained code coverage.

The document reports Phase 3 consolidation compressed EDPC/TDPC tests by 60 lines using describe.each() while maintaining 77 total tests. Line 552 states "全63テスト合格" for Phase 1, but later mentions 77 total tests post-Phase 3. Ensure the final test count (77) is accurate and that no coverage gaps were introduced during consolidation, especially in boundary and edge-case scenarios.

Can you confirm the final passing test count after all three phases? The document shows 63 tests after Phase 1 but references 77 tests in the Phase 3 summary.


628-671: Implementation phase learnings are well-documented and actionable.

Sections 10–11 effectively capture lessons from each phase, including the type safety issue (lines 640–641), reference-driven development benefits (line 657), and the strategic use of parameterized tests (line 671). The progression from debugging challenges in Phase 1 to zero failures in Phases 2–3 demonstrates clear learning and best practice application. This section will be valuable for future provider implementations.


584-592: Risk mitigation strategies are concrete and well-addressed.

The risk table identifies four key concerns (sort order ambiguity, section gaps, mock conflicts, Vitest limitations) with practical mitigations:

  • Test 9 provides explicit 0-padding verification (line 258–262)
  • Centralized fixture management prevents conflicts
  • Workaround for toBeSorted() is documented (line 591)

These risks are either testing-time validation or fixtures/workarounds—all addressed without external dependencies.


1-49: Document structure, objectives, and scope are clear and well-defined.

The overview effectively establishes context (TessokuBookProvider integration), states clear objectives (unit tests, refactoring, test design guide), and defines scope with an organized table. The document is written in clear Japanese with good use of markdown formatting. Scope boundaries (e.g., excluding E2E and integration tests) are explicitly stated.

Copy link
Collaborator Author

@KATO-Hiro KATO-Hiro left a comment

Choose a reason for hiding this comment

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

LGTM

@KATO-Hiro KATO-Hiro merged commit 43751dc into staging Nov 2, 2025
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #2776 branch November 2, 2025 11:54
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.

[Feat] 鉄則本の問題をインポートできるようにしましょう

1 participant