Skip to content

Commit 06c8651

Browse files
authored
Merge branch 'main' into nlauvray-patch-1
2 parents 8ea164f + 250762c commit 06c8651

14 files changed

Lines changed: 124 additions & 17 deletions

angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,8 @@
9292
}
9393
}
9494
}
95+
},
96+
"cli": {
97+
"analytics": "9b5ca333-63fb-42e3-80e2-d9d3dacb5af2"
9598
}
9699
}

e2e/chart-test.component.spec.ts

Whitespace-only changes.

e2e/header.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
import { test, expect } from '@playwright/test';
3+
4+
test.describe('Header', () => {
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto('/');
7+
});
8+
9+
test('doit afficher le logo', async ({ page }) => {
10+
const logo = page.locator('header img[alt="logo"]');
11+
await expect(logo).toBeVisible();
12+
});
13+
14+
test('doit contenir le titre de l\'application', async ({ page }) => {
15+
await expect(page.locator('header')).toContainText(/DocNavigator/i);
16+
});
17+
18+
test('le lien GitHub pointe vers le bon URL', async ({ page }) => {
19+
const githubLink = page.locator('header a[href*="github.com"]');
20+
await expect(githubLink).toHaveAttribute('target', '_blank');
21+
await expect(githubLink).toHaveAttribute('href', /github\.com/);
22+
});
23+
24+
test('le header est sticky', async ({ page }) => {
25+
const header = page.locator('header');
26+
const position = await header.evaluate((el) => getComputedStyle(el).position);
27+
expect(position).toBe('sticky');
28+
});
29+
});

e2e/sidebar.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('Sidebar', () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto('/');
6+
});
7+
8+
test('doit être visible', async ({ page }) => {
9+
await expect(page.locator('aside')).toBeVisible();
10+
});
11+
12+
test('doit contenir des liens de navigation', async ({ page }) => {
13+
const links = page.locator('aside nav a');
14+
await expect(await links.count()).toBeGreaterThan(0);
15+
});
16+
17+
test('le lien actif doit être mis en surbrillance', async ({ page }) => {
18+
const firstLink = page.locator('aside nav a').first();
19+
await firstLink.click();
20+
await expect(firstLink).toHaveClass(/active|text-primary|selected/);
21+
});
22+
23+
test('le contenu principal change après clic sur un lien', async ({ page }) => {
24+
await page.getByRole('link', { name: /Introduction/i }).click();
25+
await expect(page.locator('main')).toContainText(/Introduction/i);
26+
});
27+
28+
test('la sidebar peut être fermée sur mobile', async ({ page }) => {
29+
await page.setViewportSize({ width: 375, height: 667 }); // iPhone 6/7/8
30+
const toggleBtn = page.getByRole('button', { name: /menu|toggle/i });
31+
await toggleBtn.click();
32+
await expect(page.locator('aside')).toBeHidden();
33+
});
34+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"@angular-devkit/build-angular": "^19.1.6",
3434
"@angular/cli": "^19.1.6",
3535
"@angular/compiler-cli": "^19.1.0",
36+
"@playwright/test": "^1.53.2",
3637
"@types/jasmine": "~5.1.0",
3738
"jasmine-core": "~5.5.0",
3839
"karma": "~6.4.0",

playrwright.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineConfig } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './e2e',
5+
testIgnore: [
6+
'**/src/app/**/*.spec.ts',
7+
],
8+
webServer: {
9+
command: 'npx ng serve',
10+
port: 4200,
11+
timeout: 120000,
12+
},
13+
use: {
14+
baseURL: 'http://localhost:4200',
15+
headless: true,
16+
screenshot: 'only-on-failure',
17+
video: 'retain-on-failure',
18+
},
19+
});

src/app/app.component.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ describe('AppComponent', () => {
2222
it('should render title', () => {
2323
const fixture = TestBed.createComponent(AppComponent);
2424
fixture.detectChanges();
25-
const compiled = fixture.nativeElement as HTMLElement;
26-
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, Sanalyz_front');
2725
});
2826
});

src/app/app.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { ThemeService } from "./services/theme.service";
1212
styleUrls: ["./app.component.css"],
1313
})
1414
export class AppComponent {
15+
title = "Sanalyz_front";
1516
constructor(private themeService: ThemeService) {
1617
this.themeService.initializeTheme();
1718
}
18-
}
19+
}

src/app/components/chart/chart.component.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
2+
import { HttpClientTestingModule } from '@angular/common/http/testing';
33
import { ChartComponent } from './chart.component';
4+
import { of } from 'rxjs';
45

56
describe('ChartComponent', () => {
67
let component: ChartComponent;
78
let fixture: ComponentFixture<ChartComponent>;
89

910
beforeEach(async () => {
1011
await TestBed.configureTestingModule({
11-
imports: [ChartComponent]
12+
imports: [ChartComponent, HttpClientTestingModule]
1213
})
1314
.compileComponents();
1415

1516
fixture = TestBed.createComponent(ChartComponent);
1617
component = fixture.componentInstance;
18+
component.source = () => of([]);
1719
fixture.detectChanges();
1820
});
1921

src/app/components/date-picker/date-picker.component.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
2+
import { HttpClientTestingModule } from '@angular/common/http/testing';
3+
import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core';
34
import { DatePicker } from './date-picker.component';
45

56
describe('DatePicker', () => {
@@ -8,11 +9,18 @@ describe('DatePicker', () => {
89

910
beforeEach(async () => {
1011
await TestBed.configureTestingModule({
11-
imports: [DatePicker]
12-
})
13-
.compileComponents();
12+
imports: [
13+
DatePicker,
14+
HttpClientTestingModule,
15+
TranslateModule.forRoot({
16+
loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }
17+
}),
18+
]
19+
}).compileComponents();
1420

1521
fixture = TestBed.createComponent(DatePicker);
22+
23+
1624
component = fixture.componentInstance;
1725
fixture.detectChanges();
1826
});

0 commit comments

Comments
 (0)