Skip to content

Angular - Align the UI tests with the v22 upgrade#25729

Merged
sumeyyeKurtulus merged 9 commits into
devfrom
task/update-ng-ui-tests
Jun 30, 2026
Merged

Angular - Align the UI tests with the v22 upgrade#25729
sumeyyeKurtulus merged 9 commits into
devfrom
task/update-ng-ui-tests

Conversation

@sumeyyeKurtulus

Copy link
Copy Markdown
Contributor

Description

Updates the UI tests to align the ng v22 upgrade.

How to test it?

  • You can use yarn test:vitest, yarn test:vitest --project core, or yarn test:vitest --project core packages/core/src/lib/tests/form-submit.directive.spec.ts for specific files as you prefer.

@sumeyyeKurtulus sumeyyeKurtulus added this to the 10.6-preview milestone Jun 30, 2026
Copilot AI review requested due to automatic review settings June 30, 2026 12:57
@sumeyyeKurtulus sumeyyeKurtulus requested review from fahrigedik and removed request for Copilot June 30, 2026 12:57
Copilot AI review requested due to automatic review settings June 30, 2026 13:33
@sumeyyeKurtulus sumeyyeKurtulus merged commit 9b0a1c9 into dev Jun 30, 2026
2 of 3 checks passed
@sumeyyeKurtulus sumeyyeKurtulus deleted the task/update-ng-ui-tests branch June 30, 2026 13:36

Copilot AI 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.

Pull request overview

Updates the Angular UI/unit test suite (core + theme-shared) to be compatible with the Angular v22 upgrade, primarily by switching tests to signal-based inputs, adjusting directive selectors/usages, and modernizing timer/mocking patterns.

Changes:

  • Added a setInputSignal test helper and refactored many specs to set signal inputs explicitly (instead of setInput/property assignment).
  • Updated multiple directive/component tests to match Angular v22 selector and timing behavior (e.g., [input.debounce], [click.stop], fake timers).
  • Hardened AbpLocalStorageService browser access via a guarded storage getter (but introduces a behavioral bug for empty-string values).

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
npm/ng-packs/packages/theme-shared/src/lib/tests/utils/input-signal.ts Adds test helper for setting input signals.
npm/ng-packs/packages/theme-shared/src/lib/tests/utils/index.ts Re-exports new test helper.
npm/ng-packs/packages/theme-shared/src/lib/tests/toaster.service.spec.ts Updates toast container mocking.
npm/ng-packs/packages/theme-shared/src/lib/tests/modal.component.spec.ts Migrates host inputs to input() + signal-setting helper.
npm/ng-packs/packages/theme-shared/src/lib/tests/loading.directive.spec.ts Refactors directive input setting to signals and adjusts templates.
npm/ng-packs/packages/theme-shared/src/lib/tests/loader-bar.component.spec.ts Adapts expectations to signal getters and updated component API.
npm/ng-packs/packages/theme-shared/src/lib/tests/form-input.component.spec.ts Uses signal helper to set input flags.
npm/ng-packs/packages/theme-shared/src/lib/tests/ellipsis.directive.spec.ts Migrates directive inputs to signals with manual detectChanges flow.
npm/ng-packs/packages/theme-shared/src/lib/tests/checkbox.component.spec.ts Migrates component inputs to signals with manual detectChanges flow.
npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.directive.spec.ts Normalizes host template setup.
npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.component.spec.ts Switches style input setup to signals.
npm/ng-packs/packages/theme-shared/src/lib/tests/card-footer.component.spec.ts Switches style input setup to signals.
npm/ng-packs/packages/theme-shared/src/lib/tests/card-body.component.spec.ts Switches style input setup to signals.
npm/ng-packs/packages/theme-shared/src/lib/tests/button.component.spec.ts Migrates loading and iconClass input handling to signals.
npm/ng-packs/packages/theme-shared/src/lib/tests/breadcrumb.component.spec.ts Adjusts test module options and suppresses console noise.
npm/ng-packs/packages/theme-shared/src/lib/directives/loading.directive.ts Exposes targetElement (visibility changed) to support updated tests.
npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.ts Changes signal fields visibility (protected → public) to support tests.
npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts Moves setLoading method placement (no functional change).
npm/ng-packs/packages/core/src/lib/tests/utils/input-signal.ts Adds core test helper for setting input signals.
npm/ng-packs/packages/core/src/lib/tests/utils/index.ts Exports test utilities including new helper.
npm/ng-packs/packages/core/src/lib/tests/stop-propagation.directive.spec.ts Updates directive usage to [click.stop] selector semantics.
npm/ng-packs/packages/core/src/lib/tests/show-password-directive.spec.ts Refactors to set signal inputs via helper + effect flushing.
npm/ng-packs/packages/core/src/lib/tests/replaceable-template.directive.spec.ts Migrates test components/inputs toward signal usage.
npm/ng-packs/packages/core/src/lib/tests/permission.guard.spec.ts Updates testbed wiring/mocks for Angular v22.
npm/ng-packs/packages/core/src/lib/tests/permission.directive.spec.ts Refactors directive inputs to signals and manual ngOnChanges.
npm/ng-packs/packages/core/src/lib/tests/local-storage.service.spec.ts Switches to stubbing global localStorage and asserting calls.
npm/ng-packs/packages/core/src/lib/tests/form-submit.directive.spec.ts Moves to fake timers + signal input setting for debounce.
npm/ng-packs/packages/core/src/lib/tests/for.directive.spec.ts Refactors structural directive tests to explicit input-signal setup.
npm/ng-packs/packages/core/src/lib/tests/factory-utils.spec.ts Updates assertions for module factory shape.
npm/ng-packs/packages/core/src/lib/tests/environment-utils.spec.ts Replaces jest.spyOn with vi.spyOn.
npm/ng-packs/packages/core/src/lib/tests/debounce.directive.spec.ts Updates to fake timers and [input.debounce] selector.
npm/ng-packs/packages/core/src/lib/tests/capsLock.directive.spec.ts Refactors event simulation to call directive handlers and assert emits.
npm/ng-packs/packages/core/src/lib/tests/autofocus.directive.spec.ts Updates default delay expectation and uses fake timers.
npm/ng-packs/packages/core/src/lib/services/local-storage.service.ts Adds guarded storage accessor and switches to optional chaining.
npm/ng-packs/package.json Updates Angular devDependencies to v22 and adjusts schematics dev script.

Comment on lines +34 to 38
return this.storage?.getItem(key) || null;
}
key(index: number): string | null {
if (!isPlatformBrowser(this.platformId)) {
return null;
}
return localStorage.key(index);
return this.storage?.key(index) || null;
}
Comment on lines 23 to 27
spectator = createDirective(
'<form [formGroup]="formGroup" (ngSubmit)="submitEventFn()" [debounce]="20">form content</form>',
'<form ngSubmit [formGroup]="formGroup" (ngSubmit)="submitEventFn()">form content</form>',
{
hostProps: {
submitEventFn,
Comment on lines +61 to 65
vi.advanceTimersByTime(199);
expect(submitEventFn).not.toHaveBeenCalled();

vi.advanceTimersByTime(1);
expect(submitEventFn).toHaveBeenCalled();
import { combineLatest, firstValueFrom, Subject, timer } from 'rxjs';
import { LoaderBarComponent } from '../components/loader-bar/loader-bar.component';
import { setupComponentResources } from './utils';
import { setupComponentResources, setInputSignal } from './utils';
Comment on lines 14 to +17
class DefaultComponent {
@Input()
oneWay;
onOneWay = input<any>();

@Input()
twoWay: boolean;
twoWay = input<boolean>();
readonly delay = input(0, { alias: 'abpLoadingDelay' });

private targetElement: HTMLElement | undefined;
targetElement: HTMLElement | undefined;
Comment on lines +43 to +44
readonly isLoading = signal(false);
readonly progressLevel = signal(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants