Skip to content

Fix renderer tests and enable Angular unit tests in CI#1174

Open
jacobsimionato wants to merge 2 commits intogoogle:mainfrom
jacobsimionato:fix_publish_tests
Open

Fix renderer tests and enable Angular unit tests in CI#1174
jacobsimionato wants to merge 2 commits intogoogle:mainfrom
jacobsimionato:fix_publish_tests

Conversation

@jacobsimionato
Copy link
Copy Markdown
Collaborator

Description of Changes

This PR fixes unit test failures in the web_core and angular packages that were discovered during the package publication process. It also enables these Angular unit tests in the CI workflow to prevent future regressions.

  • Web Core: Updated the test script in package.json to use a glob pattern ("dist/**/*.test.js"). This fixes an issue where the Node.js test runner failed to discover nested tests when pointed directly at the dist directory.
  • Angular Renderer:
    • Fixed RowComponent and ColumnComponent unit tests. The tests were incorrectly searching for child elements and raw property values; they now correctly inspect the host element and expect mapped CSS values.
    • Removed outdated gap: 4px assertions as the components default to 16px via CSS variables.
  • CI Configuration: Added a Test Angular renderer step to .github/workflows/ng_build_and_test.yml to ensure Angular unit tests are executed on every PR.

Rationale

These tests failed when trying to publish the new alpha versions. The failures went unnoticed because the Angular unit tests were not part of the standard CI pipeline, and the Web Core test discovery was inconsistent with how the other renderers were configured.

Testing/Running Instructions

Verify that tests pass locally:

  1. cd renderers/web_core && npm test
  2. cd renderers/angular && npm run test:ci

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the unit tests for ColumnComponent and RowComponent by switching the debug element target to the host element and updating flex style assertions. It also refines the test command in the web_core package.json to target specific test files. The review feedback correctly identifies that removing the gap property assertions reduces test coverage and suggests updating them to reflect the new CSS variable implementation instead of deleting them.

Comment on lines +97 to +99
const hostEl = fixture.debugElement;
expect(hostEl.styles['justify-content']).toBe('flex-start');
expect(hostEl.styles['align-items']).toBe('stretch');
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.

medium

While the gap value is now a CSS variable, it is still important to verify that the host binding is correctly applied to ensure the component's styling contract is maintained. Instead of removing the assertion, it should be updated to match the new expected value.

    const hostEl = fixture.debugElement;
    expect(hostEl.styles['justify-content']).toBe('flex-start');
    expect(hostEl.styles['align-items']).toBe('stretch');
    expect(hostEl.styles['gap']).toBe('var(--a2ui-column-gap, var(--a2ui-spacing-m, 16px))');
References
  1. If there are code changes, code should have tests. Removing assertions for existing functionality (even if the implementation changed) reduces test coverage. (link)

Comment on lines +97 to +99
const hostEl = fixture.debugElement;
expect(hostEl.styles['justify-content']).toBe('center');
expect(hostEl.styles['align-items']).toBe('baseline');
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.

medium

Similar to the Column component, the gap assertion should be updated rather than removed to ensure the host binding remains correctly configured.

    const hostEl = fixture.debugElement;
    expect(hostEl.styles['justify-content']).toBe('center');
    expect(hostEl.styles['align-items']).toBe('baseline');
    expect(hostEl.styles['gap']).toBe('var(--a2ui-row-gap, var(--a2ui-spacing-m, 16px))');
References
  1. If there are code changes, code should have tests. Removing assertions for existing functionality (even if the implementation changed) reduces test coverage. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant