Applique .gitattributes sur tous les fichiers existants. Élimine les différences fantômes entre WSL et Windows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
108 lines
3.4 KiB
TypeScript
Executable File
108 lines
3.4 KiB
TypeScript
Executable File
/**
|
|
* Tests E2E — Persistance des donnees
|
|
*
|
|
* Verifie que les donnees (nom de DD, etc.) survivent
|
|
* a la fermeture et reouverture de l'application.
|
|
*/
|
|
import { test as base, expect } from '@playwright/test';
|
|
import { _electron as electron } from '@playwright/test';
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
|
|
const MAIN_PATH = path.resolve(__dirname, '../../dist-electron/main.js');
|
|
const USER_DATA_DIR = path.resolve(__dirname, '../../.e2e-userdata-persistence');
|
|
|
|
function cleanDir(dir: string) {
|
|
try {
|
|
if (fs.existsSync(dir)) {
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
} catch {
|
|
// Ignore EPERM on Windows — le dossier sera ecrase au prochain lancement
|
|
}
|
|
}
|
|
|
|
// Fixture speciale qui permet de relancer l'app
|
|
const test = base.extend<{}>({});
|
|
|
|
test.describe('Persistance des donnees', () => {
|
|
// Nettoyer les donnees avant le test
|
|
test.beforeAll(() => {
|
|
cleanDir(USER_DATA_DIR);
|
|
});
|
|
|
|
test.afterAll(() => {
|
|
cleanDir(USER_DATA_DIR);
|
|
});
|
|
|
|
test('Le nom d\'une dragodinde persiste apres fermeture et reouverture', async () => {
|
|
// --- Session 1 : creer un enclos, nommer la DD ---
|
|
const app1 = await electron.launch({
|
|
args: [MAIN_PATH],
|
|
env: {
|
|
...process.env,
|
|
ELECTRON_USER_DATA_DIR: USER_DATA_DIR,
|
|
},
|
|
});
|
|
|
|
const page1 = await app1.firstWindow();
|
|
await page1.waitForLoadState('domcontentloaded');
|
|
await page1.waitForSelector('.app-shell', { timeout: 15000 });
|
|
|
|
// L'app demarre sans enclos — en creer un (il contient deja 1 DD)
|
|
await page1.click('#add-enclos-btn');
|
|
await page1.waitForSelector('.sb-item .sb-dot', { timeout: 5000 });
|
|
|
|
// Naviguer vers le premier enclos
|
|
const firstEnclos1 = page1.locator('.sb-item[data-view]').filter({
|
|
has: page1.locator('.sb-dot'),
|
|
}).first();
|
|
await firstEnclos1.click();
|
|
await expect(page1.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
|
|
|
// L'enclos contient deja 1 DD (creee avec l'enclos)
|
|
await expect(page1.locator('.dd-grid .dd-card')).toHaveCount(1, { timeout: 5000 });
|
|
|
|
// Renommer la DD (trouver l'input de nom dans la carte DD)
|
|
const ddNameInput = page1.locator('.dd-card .dd-name').first();
|
|
await ddNameInput.click();
|
|
await ddNameInput.fill('TestPersist42');
|
|
await ddNameInput.press('Enter');
|
|
|
|
// Attendre que la sauvegarde soit effectuee
|
|
await page1.waitForTimeout(1000);
|
|
|
|
// Fermer l'app
|
|
await app1.close();
|
|
|
|
// --- Session 2 : verifier que la DD est toujours la ---
|
|
const app2 = await electron.launch({
|
|
args: [MAIN_PATH],
|
|
env: {
|
|
...process.env,
|
|
ELECTRON_USER_DATA_DIR: USER_DATA_DIR,
|
|
},
|
|
});
|
|
|
|
const page2 = await app2.firstWindow();
|
|
await page2.waitForLoadState('domcontentloaded');
|
|
await page2.waitForSelector('.app-shell', { timeout: 15000 });
|
|
|
|
// Naviguer vers le premier enclos
|
|
const firstEnclos2 = page2.locator('.sb-item[data-view]').filter({
|
|
has: page2.locator('.sb-dot'),
|
|
}).first();
|
|
await firstEnclos2.click();
|
|
await expect(page2.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
|
|
|
// Verifier que la DD est toujours presente
|
|
await expect(page2.locator('.dd-grid .dd-card')).toHaveCount(1, { timeout: 5000 });
|
|
|
|
// Verifier que le nom persiste
|
|
const ddNameInput2 = page2.locator('.dd-card .dd-name').first();
|
|
await expect(ddNameInput2).toHaveValue('TestPersist42', { timeout: 5000 });
|
|
|
|
await app2.close();
|
|
});
|
|
});
|