test: reset global dialog state between specs #9100 (#9183)

Co-authored-by: p1 <giridharpavan593@gmail.com>
This commit is contained in:
giri256 2026-07-21 15:02:41 +05:30 committed by GitHub
parent b26fb1093f
commit e1d15212ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,6 +25,7 @@ import 'fake-indexeddb/auto';
import { IDBFactory } from 'fake-indexeddb';
import { asyncScheduler } from 'rxjs';
import { clearDeferredActions } from './app/op-log/capture/operation-capture.meta-reducer';
import { _resetDevErrorState } from './app/util/dev-error';
import { getTestBed, TestBed } from '@angular/core/testing';
import {
@ -108,6 +109,18 @@ beforeEach(() => {
// the phantom-change guard (#8751) reads it and silently skips compaction
// and snapshot saves — an order-dependent failure that passes standalone.
clearDeferredActions();
// The dialog spies below are created once at module load, so reset their
// call history before every spec to prevent assertions from passing on a
// stale call from an unrelated test. Re-arm devError's alert latch as well
// so legitimate alerts remain observable regardless of spec order.
if (jasmine.isSpy(window.alert)) {
(window.alert as jasmine.Spy).calls.reset();
}
if (jasmine.isSpy(window.confirm)) {
(window.confirm as jasmine.Spy).calls.reset();
}
_resetDevErrorState();
});
// Mock browser dialogs globally for tests