test(e2e): adapt export specs to 7-column schema (Scénario/Test/...)
Update AC-29.2 (Markdown) to assert | Scénario | GFM table header. Update AC-29.3 (CSV) to assert exact 7 FR column names instead of 'name'. Update AC-31.4 (empty engagement) MD to assert table absent, CSV header to assert exact 7 FR columns. Drop unused sim1/sim2 vars and makeClient import (NIT cleanup). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,16 @@ import {
|
||||
makeClient,
|
||||
type Engagement,
|
||||
} from '../fixtures/api';
|
||||
|
||||
const CSV_HEADER_COLS = [
|
||||
'Scénario',
|
||||
'Test',
|
||||
'Source de log',
|
||||
'Commentaires SOC',
|
||||
'Exécution',
|
||||
'Logs remontés au SIEM',
|
||||
'Cyber incident',
|
||||
];
|
||||
import { seedTokenInStorage } from '../fixtures/auth';
|
||||
|
||||
const ADMIN_USER = 'us29-admin';
|
||||
@@ -91,8 +101,6 @@ test.describe('US-29 — Export formats (admin + redteam)', () => {
|
||||
let adminTok: string;
|
||||
let redteamTok: string;
|
||||
let engagement: Engagement;
|
||||
let sim1: Simulation;
|
||||
let sim2: Simulation;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
await ensureUser(ADMIN_USER, PASS, 'admin');
|
||||
@@ -106,8 +114,8 @@ test.describe('US-29 — Export formats (admin + redteam)', () => {
|
||||
start_date: '2026-01-15',
|
||||
status: 'active',
|
||||
});
|
||||
sim1 = await createSimulation(adminTok, engagement.id, 'US29 Sim Alpha');
|
||||
sim2 = await createSimulation(adminTok, engagement.id, 'US29 Sim Beta');
|
||||
await createSimulation(adminTok, engagement.id, 'US29 Sim Alpha');
|
||||
await createSimulation(adminTok, engagement.id, 'US29 Sim Beta');
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
@@ -162,13 +170,14 @@ test.describe('US-29 — Export formats (admin + redteam)', () => {
|
||||
|
||||
const content = await fs.readFile(filePath!, 'utf-8');
|
||||
|
||||
// Must contain engagement name
|
||||
// Must contain engagement name and start date in the header section
|
||||
expect(content).toContain('US29 Export Engagement');
|
||||
// Must contain simulation names
|
||||
expect(content).toContain('2026-01-15');
|
||||
// Must use the 7-column GFM table layout
|
||||
expect(content).toContain('| Scénario |');
|
||||
// Simulation names appear in the Scénario column
|
||||
expect(content).toContain('US29 Sim Alpha');
|
||||
expect(content).toContain('US29 Sim Beta');
|
||||
// Must contain start date
|
||||
expect(content).toContain('2026-01-15');
|
||||
|
||||
// Suggested filename from Content-Disposition must end in .md
|
||||
const suggestedName = download.suggestedFilename();
|
||||
@@ -203,10 +212,11 @@ test.describe('US-29 — Export formats (admin + redteam)', () => {
|
||||
// 1 header + 2 simulation rows
|
||||
expect(rows.count).toBe(3);
|
||||
|
||||
// Header must mention 'name' column
|
||||
expect(rows.headerLine).toContain('name');
|
||||
// Header must be exactly the 7 FR columns
|
||||
const headerCells = rows.headerLine.split(',').map((c) => c.trim().replace(/^"|"$/g, ''));
|
||||
expect(headerCells).toEqual(CSV_HEADER_COLS);
|
||||
|
||||
// Simulation data rows must contain simulation names
|
||||
// Scénario column (index 0) contains simulation names
|
||||
expect(rows.dataText).toContain('US29 Sim Alpha');
|
||||
expect(rows.dataText).toContain('US29 Sim Beta');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user