Skip to content

refactor(ui): remove explicit any and enforce lint rule in ui tests - #1671

Draft
VLukiantsev wants to merge 3 commits into
refactor/fix-ui-templates-and-unused-lintfrom
refactor/eliminate-ui-test-explicit-any
Draft

VLukiantsev wants to merge 3 commits into
refactor/fix-ui-templates-and-unused-lintfrom
refactor/eliminate-ui-test-explicit-any

Conversation

@VLukiantsev

@VLukiantsev VLukiantsev commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Replace explicit any casts and annotations across 16 UI unit test/mock files and cmd/ui/app/testing/testing.d.ts with concrete Angular Router, ECharts, ComponentFixture, Subject, unknown, and proto types, and remove '@typescript-eslint/no-explicit-any': 'off' from the test/mock ESLint override in cmd/ui/eslint.config.js so explicit any is immediately enforced as an error.

Motivation & Context

Removing any without enabling the lint rule leaves unit tests and mocks open to regressions. Enforcing @typescript-eslint/no-explicit-any directly in cmd/ui/eslint.config.js locks down all *_test.ts, *.spec.ts, mock_*.ts, screenshot_tests/**, component/service testing/ harnesses, and testing.d.ts against silent type drift.

Key Changes

Modified 18 file(s):

  • cmd/ui/eslint.config.js: Remove '@typescript-eslint/no-explicit-any': 'off' from the general test/mock/screenshot override and restrict the exemption strictly to ['**/app/testing/test.ts', '**/app/protos/*.d.ts'].
  • cmd/ui/app/testing/testing.d.ts: Replace any with unknown on AsyncMatchers.toEmit and toEmitSequence.
  • cmd/ui/app/admin_panel.guard_test.ts
  • cmd/ui/app/admin_panel/admin_panel_test.ts
  • cmd/ui/app/auth.guard_test.ts
  • cmd/ui/app/common/components/artifacts_list/artifacts_list_test.ts
  • cmd/ui/app/common/components/dashboard/bar_options_builder_test.ts
  • cmd/ui/app/common/components/dashboard/echarts_options_builder_test.ts
  • cmd/ui/app/common/components/dashboard/scatter_options_builder_test.ts
  • cmd/ui/app/common/components/loading_bar/loading_bar_test.ts
  • cmd/ui/app/common/mock_data.ts
  • cmd/ui/app/guest.guard_test.ts
  • cmd/ui/app/pages/dashboards/dashboards_page_test.ts
  • cmd/ui/app/performance_dashboard.guard_test.ts
  • cmd/ui/app/resource_dashboard.guard_test.ts
  • cmd/ui/app/service/dashboard_normalizer_test.ts
  • cmd/ui/app/service/testing/mock_health_service.ts
  • cmd/ui/app/side_panel/contents/queue_jobs_table/queue_jobs_pipes_test.ts

Assumptions

  • Using as unknown as <Type> only on intentionally partial proto mocks preserves strict static checking without requiring dummy fields for optional nested submessages — verified by both tsconfig.json and tsconfig.spec.json — any future proto break triggers a compile error.
  • Leaving '@typescript-eslint/no-explicit-any': 'off' scoped to cmd/ui/app/testing/test.ts and cmd/ui/app/protos/*.d.ts does not expose tests or mocks to regressions — it preserves existing Angular bootstrap()/cleanState()/get() test helper ergonomics and proto stub declarations without rewriting 44 test callers or generated .d.ts files — if new code is added to test.ts or new proto .d.ts files, explicit any remains allowed there until those files are typed cleanly.

Verification & Testing

  • Commands Executed: npx prettier --check eslint.config.js app/testing/testing.d.ts, npm run lint (eslint . + root-cwd eslint check), npx tsc -p tsconfig.json --noEmit, npx tsc -p tsconfig.spec.json --noEmit, bazel test --test_output=errors //cmd/ui:ui_unit_tests, ./.githooks/pre-commit on commit, and python3 ./tools/analyze_diff_size.py --base-ref refactor/fix-ui-templates-and-unused-lint.
  • Coverage & Test Status: //cmd/ui:ui_unit_tests (Karma), Prettier, ESLint (with @typescript-eslint/no-explicit-any enabled across UI tests/mocks/harnesses/testing.d.ts), and both tsc builds passed; diff size is 6 prod lines / 159 test lines (165 total, threshold_exceeded: false).

Related Issues / Bugs

N/A

TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c

@VLukiantsev
VLukiantsev added this pull request to stack #1675 November 12, 2026 19:46

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

Copy link
Copy Markdown

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 improves type safety across various Angular and ECharts test files by replacing loose "as any" type assertions with explicit, strongly-typed interfaces and models (such as ActivatedRouteSnapshot, HealthStatusResponse, and ECharts component options). The feedback recommends further simplifying these assertions: first, by using TypeScript's bracket notation to access private component members in artifacts_list_test.ts instead of defining a verbose helper interface; and second, by removing a redundant intersection type when casting xAxis in bar_options_builder_test.ts since XAXisComponentOption already includes the data property.

@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 7398404 to 4d043a7 Compare November 12, 2026 23:50
@VLukiantsev

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@VLukiantsev

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

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 improves type safety across multiple Angular test files by replacing loose any types with explicit, strongly-typed interfaces and classes. The changes span various guards, components, and mock data files. Feedback on these changes suggests removing redundant as ArtifactSingle type assertions in artifacts_list_test.ts where the underlying observables are already strongly typed, and simplifying a type assertion in bar_options_builder_test.ts by removing an unnecessary intersection type on XAXisComponentOption.

@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 4d043a7 to b655a92 Compare November 13, 2026 08:22
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from b655a92 to 1c03423 Compare November 13, 2026 09:19
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch 2 times, most recently from 363aa57 to b9a047b Compare November 13, 2026 10:56
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch 2 times, most recently from cbb31ee to 3c236a4 Compare November 13, 2026 12:52
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 3c236a4 to 0fb0516 Compare November 13, 2026 13:16
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch 2 times, most recently from 991cb23 to 70211c2 Compare November 13, 2026 14:58
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 70211c2 to b876599 Compare November 16, 2026 08:37
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from b876599 to da38716 Compare November 16, 2026 09:17
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from da38716 to f628ef3 Compare November 16, 2026 11:13
@VLukiantsev
VLukiantsev removed this pull request from stack #1675 November 16, 2026 11:16
@VLukiantsev
VLukiantsev added this pull request to stack #1702 November 16, 2026 11:16
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from f628ef3 to 59beb55 Compare November 16, 2026 11:44
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 59beb55 to 3702af1 Compare November 16, 2026 12:36
@VLukiantsev VLukiantsev changed the title refactor: remove explicit any from ui unit tests and mocks refactor(ui): remove explicit any and enforce lint rule in ui tests Nov 16, 2026
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 3702af1 to 74ddc0a Compare November 16, 2026 19:53
VLukiantsev added a commit that referenced this pull request Nov 16, 2026
Remove `@typescript-eslint/no-explicit-any: 'off'` from the broad test override in `cmd/ui/eslint.config.js` so `any` cannot be reintroduced into UI tests, mocks, harnesses, or screenshot specs in PR #1671, narrow the legacy override to `**/app/testing/test.ts` and `**/app/protos/*.d.ts`, and replace `any` in `cmd/ui/app/testing/testing.d.ts` with `unknown`.

TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 74ddc0a to 3d23293 Compare November 16, 2026 19:55
@VLukiantsev

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

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 removes the use of "any" across various TypeScript test files, mock data, and guards, replacing them with explicit types and interfaces to enforce stronger type safety. It also updates the ESLint configuration to enable the "@typescript-eslint/no-explicit-any" rule, except for specific test and proto files. The review feedback suggests improving the robustness of the tests in "scatter_options_builder_test.ts" by using optional chaining when accessing "markLineData" elements, preventing potential runtime "TypeError"s if the data is undefined.

@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch 2 times, most recently from 8510954 to e797374 Compare November 17, 2026 11:37
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from e797374 to dd94307 Compare November 17, 2026 11:58
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from dd94307 to 5a1fedc Compare November 17, 2026 13:17
Replace explicit `any` casts and annotations across 16 UI unit test and mock files with concrete Angular Router, ECharts, ComponentFixture, Subject, and proto types, using `ArtifactsList` bracket access in `artifacts_list_test.ts`.

TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
Remove `@typescript-eslint/no-explicit-any: 'off'` from the broad test override in `cmd/ui/eslint.config.js` so `any` cannot be reintroduced into UI tests, mocks, harnesses, or screenshot specs in PR #1671, narrow the legacy override to `**/app/testing/test.ts` and `**/app/protos/*.d.ts`, and replace `any` in `cmd/ui/app/testing/testing.d.ts` with `unknown`.

TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
…test

Address PR #1671 review feedback (`4590818105`, `4590818117`) by typing `markLineData` as `| undefined` and asserting `markLineData?.[0]?.yAxis` in `scatter_options_builder_test.ts`.

TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
@VLukiantsev
VLukiantsev force-pushed the refactor/eliminate-ui-test-explicit-any branch from 5a1fedc to 2646abf Compare November 17, 2026 14:09

This branch has not been deployed

No deployments
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.

1 participant