Skip to content

NMS-20586: Remove console noise from ui tests - #9182

Merged
synqotik merged 3 commits into
developfrom
jira/NMS-20586-cleanup-vue-test-noise
Nov 20, 2026
Merged

synqotik merged 3 commits into
developfrom
jira/NMS-20586-cleanup-vue-test-noise

Conversation

@synqotik

@synqotik synqotik commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

pnpm test in ui/ wrote 46,255 lines to stderr. Of these, 90% were [Vue warn]: Failed to resolve directive: onms-tooltip. The noise made real warnings hard to find.

Changes

  • Add ui/tests/setup.ts (Vitest setupFiles). It registers v-onms-tooltip for every mount, as the app does. Remove the per-test registrations and no-op stubs that are now not necessary. Keep the stubs that record the tooltip value for an assertion.
  • The setup file fails a test that causes a [Vue warn] or [Vue Router warn]. It also catches warnings from module scope, beforeAll, afterAll and late async work. New warnings cannot go into the suite.
  • Remove console.warn spies that only checked for the absence of one Vue warning. They turned the check off for the whole test.
  • Add muteAppWarnings() (ui/tests/vueWarnings.ts). It mutes an expected console.warn from app code, but Vue warnings still print and fail the test.
  • Fix the other warnings:
    • Tests: stub router-link, give the Topology page a matched route, run hooks in an effectScope(), use declared emit names, and correct store mocks and props.
    • AboutDialog.vue (two files): remove class="about-dialog". Vue did not apply it, and no style uses it.
    • GraphDataTable.vue: key rows by index. A missing timestamp (NaN) gave an invalid key.
  • Tests that expect a logged error now spy on console in that test and assert the call. afterEach restores the spies. Two service tests muted console.error for the whole file; now only the tests that log mute it.
  • Add the rules to ui/CLAUDE.md. Tests should run silently, but we are not strictly enforcing it in every case. For now, only Vue warnings are enforced.

Result

The suite writes no output to stdout or stderr. All 399 test files pass.

Testing

cd ui
pnpm test
pnpm lint

Note: Vitest 4.1 hides console output when an AI agent runs it. To see the output, use pnpm test --reporter=default --silent=false.

External References

Register v-onms-tooltip for every test mount in a new tests/setup.ts,
as the app does. This removes about 90% of the test output.

The setup file also fails a test that causes a Vue or Vue Router
warning. Fix the remaining warnings: stub router-link, give the
Topology page a matched route, run hooks in an effect scope, and
correct store mocks and props. Remove an unused class from the About
dialogs and key GraphDataTable rows by index. Tests that expect a
logged error now spy on the console and assert the call.

Document the rule in ui/CLAUDE.md.
- Check for Vue warnings in beforeEach and afterAll too, so warnings
  from module scope, beforeAll or late async work are not lost or
  blamed on the wrong test.
- Remove console.warn spies that only checked for the absence of a
  Vue warning. They turned the check off. This found a missing
  RouterLink stub in Graph.test.ts.
- Remove the no-op onms-tooltip stubs. Keep the stubs that record
  the tooltip value.
- Restore console spies in afterEach, not at the end of each test.
- Compare component instances with === instead of the internal uid.
- Use an absolute setupFiles path.
- Update the rules in ui/CLAUDE.md.
@synqotik
synqotik marked this pull request as ready for review November 20, 2026 04:01

@marshallmassengill marshallmassengill 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.

  • ui/tests/setup.ts fails a test only for a Vue warning or a Vue Router warning. A test that calls console.error or console.log passes and prints. Add a check for this output, or change the rule in ui/CLAUDE.md.
  • 15 console spies have no assertion: 14 for console.error and 1 for console.log (Graph.test.ts:55). Add expect(...).toHaveBeenCalled() to each spy, or remove the spy. The files are:
    • snmpDataCollectionDetailStore.test.ts (8)
    • minionAdminService.test.ts (2)
    • applicationAdminService.test.ts (1)
    • monitoringLocationAdminService.test.ts (1)
    • eventConfigDetailStore.test.ts (1)
    • eventConfigStore.test.ts (1)
    • Graph.test.ts (1)
  • EventConfigUploadFilesTab.test.ts:379 replaces console.warn for a test that uses a mounted component. This stops the Vue warning check for that test. Remove mockImplementation and keep the spy. The warning then prints, and the check stays on.

- Add muteAppWarnings() in tests/vueWarnings.ts. It mutes an expected
  console.warn from app code but passes Vue warnings on to the check.
  Use it in EventConfigUploadFilesTab and sessionExpiry tests.
- Assert every console spy that mutes output. Replace the beforeEach
  console.error mutes in two service tests with spies in the tests
  that log.
- ui/CLAUDE.md: tests should run silently; only Vue warnings are
  enforced. Document muteAppWarnings().
@synqotik

Copy link
Copy Markdown
Contributor Author

@marshallmassengill - all addressed.

  1. console.error/console.log aren't checked: No check added for every console output. A check on all console output would be heavy, and occasional output can be fine. ui/CLAUDE.md now says tests should run silently, that only Vue warnings are enforced, and that other output should be rare and deliberate.

  2. Spies with no assertion: valid, fixed. There were 17, not 15.

  • None of these spies came from this PR, and every file restores its spies in afterEach, so nothing leaked.
  • Added expect(...).toHaveBeenCalled() to the 15 spies listed, plus 2 more in snmpDataCollectionStore.test.ts that weren't on that list.
  • Fixed the spies in applicationAdminService.test.ts and monitoringLocationAdminService.test.ts
  1. EventConfigUploadFilesTab mutes console.warn: the gap is real, but the suggested fix is wrong.
  • The spy does turn off the Vue-warning check for that test. The same gap was in the four sessionExpiry tests.
  • Removing mockImplementation would print No files to upload, an expected warning from the component itself, and the suite would no longer be silent.
  • Instead, added muteAppWarnings() in a new tests/vueWarnings.ts. It mutes warnings from app code but passes Vue warnings on to the check, so they still print and fail the test. setup.ts now imports its warning pattern from the same file, and CLAUDE.md says to use the helper instead of a bare mock.

@marshallmassengill marshallmassengill 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.

Ship it!

@synqotik
synqotik merged commit 240e5b8 into develop Nov 20, 2026
6 checks passed
@synqotik
synqotik deleted the jira/NMS-20586-cleanup-vue-test-noise branch November 20, 2026 21:28
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.

2 participants