test(ct-angular): fix all tests

This commit is contained in:
Younes Jaaidi 2024-02-23 01:35:47 +01:00
parent 8029022f02
commit ea9f612869
No known key found for this signature in database
GPG key ID: 3126C5717BDF3241
3 changed files with 11 additions and 16 deletions

View file

@ -12,10 +12,7 @@ export type HooksConfig = {
};
beforeMount<HooksConfig>(async ({ hooksConfig, TestBed }) => {
TestBed.configureTestingModule({
imports: [ButtonComponent],
});
if (hooksConfig?.routing)
TestBed.configureTestingModule({
providers: [provideRouter(routes)],

View file

@ -1,7 +1,9 @@
import { test, expect } from '@playwright/experimental-ct-angular';
import type { HooksConfig } from 'playwright';
import { InjectComponent } from '@/components/inject.component';
import { AppComponent } from '@/app.component';
test('navigate to a page by clicking a link', async ({ page, mount }) => {
const component = await mount<HooksConfig>(AppComponent, {
hooksConfig: { routing: true },
@ -10,5 +12,12 @@ test('navigate to a page by clicking a link', async ({ page, mount }) => {
await expect(page).toHaveURL('/');
await component.getByRole('link', { name: 'Dashboard' }).click();
await expect(component.getByRole('main')).toHaveText('Dashboard');
await expect(page).toHaveURL('/dashboard');
});
test('inject a token', async ({ page, mount }) => {
const component = await mount<HooksConfig>(InjectComponent, {
hooksConfig: { injectToken: true },
});
await expect(component).toHaveText('has been overwritten');
await expect(component).not.toHaveText('gets overwritten');
});

View file

@ -1,11 +0,0 @@
import { test, expect } from '@playwright/experimental-ct-angular';
import type { HooksConfig } from 'playwright';
import { InjectComponent } from '@/components/inject.component';
test('inject a token', async ({ page, mount }) => {
const component = await mount<HooksConfig>(InjectComponent, {
hooksConfig: { injectToken: true },
});
await expect(component).toHaveText('has been overwritten');
await expect(component).not.toHaveText('gets overwritten');
});