test(ct-angular): test url change

This commit is contained in:
Younes Jaaidi 2024-03-27 22:53:15 +01:00
parent fcc1635185
commit a547da51b8
No known key found for this signature in database
GPG key ID: 3126C5717BDF3241
2 changed files with 3 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import { routes } from '@/router';
import { APP_INITIALIZER, inject } from '@angular/core';
import { Router, provideRouter } from '@angular/router';
import { afterMount, beforeMount } from '@playwright/experimental-ct-angular/hooks';
import { BrowserPlatformLocation, PlatformLocation } from '@angular/common';
export type HooksConfig = {
routing?: boolean;
@ -15,6 +16,7 @@ beforeMount<HooksConfig>(async ({ hooksConfig, TestBed }) => {
TestBed.configureTestingModule({
providers: [
provideRouter(routes),
{ provide: PlatformLocation, useExisting: BrowserPlatformLocation },
{
provide: APP_INITIALIZER,
multi: true,

View file

@ -9,4 +9,5 @@ test('navigate to a page by clicking a link', async ({ page, mount }) => {
await expect(component.getByRole('main')).toHaveText('Login');
await component.getByRole('link', { name: 'Dashboard' }).click();
await expect(component.getByRole('main')).toHaveText('Dashboard');
await expect(page).toHaveURL('/dashboard');
});