test(ct-angular): test url change
This commit is contained in:
parent
fcc1635185
commit
a547da51b8
|
|
@ -4,6 +4,7 @@ import { routes } from '@/router';
|
||||||
import { APP_INITIALIZER, inject } from '@angular/core';
|
import { APP_INITIALIZER, inject } from '@angular/core';
|
||||||
import { Router, provideRouter } from '@angular/router';
|
import { Router, provideRouter } from '@angular/router';
|
||||||
import { afterMount, beforeMount } from '@playwright/experimental-ct-angular/hooks';
|
import { afterMount, beforeMount } from '@playwright/experimental-ct-angular/hooks';
|
||||||
|
import { BrowserPlatformLocation, PlatformLocation } from '@angular/common';
|
||||||
|
|
||||||
export type HooksConfig = {
|
export type HooksConfig = {
|
||||||
routing?: boolean;
|
routing?: boolean;
|
||||||
|
|
@ -15,6 +16,7 @@ beforeMount<HooksConfig>(async ({ hooksConfig, TestBed }) => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
provideRouter(routes),
|
provideRouter(routes),
|
||||||
|
{ provide: PlatformLocation, useExisting: BrowserPlatformLocation },
|
||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
multi: true,
|
multi: true,
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ test('navigate to a page by clicking a link', async ({ page, mount }) => {
|
||||||
await expect(component.getByRole('main')).toHaveText('Login');
|
await expect(component.getByRole('main')).toHaveText('Login');
|
||||||
await component.getByRole('link', { name: 'Dashboard' }).click();
|
await component.getByRole('link', { name: 'Dashboard' }).click();
|
||||||
await expect(component.getByRole('main')).toHaveText('Dashboard');
|
await expect(component.getByRole('main')).toHaveText('Dashboard');
|
||||||
|
await expect(page).toHaveURL('/dashboard');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue