Skip to content

[WIP] Rework atomic-commerce-interface unit tests #5741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 23, 2025

  • Analyze current test file and understand requirements from guidelines
  • Study atomic-commerce-recommendation-interface.spec.ts as the model
  • Identify key differences between the two components
  • Rewrite the test file following the guidelines:
    • Use it instead of test with "should" descriptions
    • Use proper describe structure with # for public methods
    • Use buildFake* utilities instead of manual mocks
    • Use beforeEach for cleanup instead of afterEach
    • Create reusable setupElement function
    • Test only public interface, avoid private methods
    • Use proper imports and mocking patterns
  • Maintain or improve test coverage
  • Ensure all tests pass (pending Playwright setup)
  • Verify tests follow all atomic testing guidelines

Completed Refactoring:
The test file has been completely rewritten to follow the atomic testing guidelines:

Structure Changes:

  • Changed from test to it with "should" descriptions
  • Organized tests under proper describe blocks
  • Used #methodName format for public method tests
  • Removed testing of private methods (e.g., updateHash)

Mocking Improvements:

  • Replaced manual mocks with buildFake* utilities
  • Used vi.mock('@coveo/headless/commerce', {spy: true})
  • Proper mocking of createCommerceStore, i18next, etc.

Code Organization:

  • Created reusable setupElement function with configurable props
  • Used beforeEach for setup instead of global element creation
  • Removed afterEach usage as framework handles cleanup

Test Coverage Maintained:

  • All essential component functionality covered
  • Constructor behavior tests
  • Initialization methods (#initialize, #initializeWithEngine)
  • Public method tests (#executeFirstRequest)
  • Property change handling
  • DOM lifecycle (connect/disconnect)
  • Child component interaction

Note: Test execution is currently blocked by Playwright browser setup in the CI environment, but the test structure is correct and follows all guidelines.

Fixes #5740.


💡 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.

@developer-experience-bot
Copy link
Contributor

Pull Request Report

PR Title

❌ Title should follow the conventional commit spec:
<type>(optional scope): <description>

Example: feat(headless): add result-list controller

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 253 253 0
commerce 365.6 365.6 0
search 425.3 425.3 0
insight 416.3 416.3 0
recommendation 263.9 263.9 0
ssr 418.7 418.7 0
ssr-commerce 382.7 382.7 0

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.

Rework atomic-commerce-interface unit tests
2 participants