From 4cee44c1029a38bfff4a20ad3145702e311f6548 Mon Sep 17 00:00:00 2001 From: Volha Mardvilka Date: Fri, 4 Oct 2024 12:44:24 +0000 Subject: [PATCH] 371506031: (fix) make the welcome modal be on top completed test modal --- .../components/version/version.component.spec.ts | 14 ++++++++++---- .../app/components/version/version.component.ts | 8 +++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/ui/src/app/components/version/version.component.spec.ts b/modules/ui/src/app/components/version/version.component.spec.ts index 3e9e18ad8..381b6dbba 100644 --- a/modules/ui/src/app/components/version/version.component.spec.ts +++ b/modules/ui/src/app/components/version/version.component.spec.ts @@ -13,7 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { + ComponentFixture, + fakeAsync, + TestBed, + tick, +} from '@angular/core/testing'; import { VersionComponent } from './version.component'; import { @@ -70,17 +75,18 @@ describe('VersionComponent', () => { expect(labelVersion).toEqual('v1. Click to open the Welcome modal'); }); - it('should open consent window on start', () => { + it('should open consent window on start', fakeAsync(() => { const openSpy = spyOn(component.dialog, 'open').and.returnValue({ - afterClosed: () => of(true), + afterClosed: () => of({ grant: null }), } as MatDialogRef); versionBehaviorSubject$.next(VERSION); mockService.getVersion.and.returnValue(versionBehaviorSubject$); fixture.detectChanges(); component.ngOnInit(); + tick(2000); expect(openSpy).toHaveBeenCalled(); - }); + })); it('should open consent window when button clicked', () => { const openSpy = spyOn(component.dialog, 'open').and.returnValue({ diff --git a/modules/ui/src/app/components/version/version.component.ts b/modules/ui/src/app/components/version/version.component.ts index 9fadfd841..ad8fcafa0 100644 --- a/modules/ui/src/app/components/version/version.component.ts +++ b/modules/ui/src/app/components/version/version.component.ts @@ -34,7 +34,7 @@ import { tap } from 'rxjs/internal/operators/tap'; import { Observable } from 'rxjs/internal/Observable'; import { Subject } from 'rxjs/internal/Subject'; import { takeUntil } from 'rxjs/internal/operators/takeUntil'; -import { filter } from 'rxjs'; +import { filter, timer } from 'rxjs'; import { ConsentDialogComponent } from './consent-dialog/consent-dialog.component'; // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type @@ -64,8 +64,10 @@ export class VersionComponent implements OnInit, OnDestroy { filter(version => version !== null), tap(version => { if (!this.consentShown) { - this.openConsentDialog(version); - this.consentShownEvent.emit(); + timer(2000).subscribe(() => { + this.openConsentDialog(version); + this.consentShownEvent.emit(); + }); } // @ts-expect-error data layer is not null window.dataLayer.push({