Convert 20 files from fake assertions (console.log with ✓/✗) to real
expect() assertions. This completes the conversion started in the
previous session — zero console.log calls remain in the E2E suite.
Files converted (by batch):
Batch 1: 16-forms-validation (38→0), 13-workflows (18→0), 14-edge-cases (8→0)
Batch 2: 15-routes-coverage (8→0), 20-network-errors (5→0), 04-tracks (4→0),
32-deep-pages (4→0), 19-responsive (3→0), 11-accessibility-ethics (3→0)
Batch 3: 25-profile (2→0), 12-api (2→0), 29-chat-functional (2→0),
30-marketplace-checkout (1→0), 22-performance (1→0),
31-auth-sessions (1→0), 26-smoke (1→0), 02-navigation (1→0)
Batch 4: 24-cross-browser (0 fakes, 12 info→0), 34-workflows-empty (0→0),
33-visual-bugs (0→0)
Total: 139 fake assertions → real expect(), 159 informational logs removed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
198 lines
6.4 KiB
TypeScript
198 lines
6.4 KiB
TypeScript
import { test, expect } from '@chromatic-com/playwright';
|
|
import { loginViaAPI, CONFIG, navigateTo, fillForm } from './helpers';
|
|
|
|
/**
|
|
* Smoke Tests @smoke @critical
|
|
*
|
|
* Combined from smoke-post-deploy.spec.ts and smoke.spec.ts.
|
|
* Quick checks to verify the application is functional.
|
|
*/
|
|
|
|
test.describe('SMOKE TESTS @smoke @critical', () => {
|
|
test.describe('Post-deploy smoke checks', () => {
|
|
test('homepage loads', async ({ page }) => {
|
|
const response = await page.goto('/', {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: 15000,
|
|
});
|
|
expect(response?.status()).toBeLessThan(500);
|
|
});
|
|
|
|
test('login page loads', async ({ page }) => {
|
|
const response = await page.goto('/login', {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: 15000,
|
|
});
|
|
expect(response?.status()).toBeLessThan(500);
|
|
});
|
|
|
|
test('API health check', async ({ request }) => {
|
|
const baseURL = CONFIG.apiURL;
|
|
const apiUrl = `${baseURL}/api/v1/health`;
|
|
const response = await request.get(apiUrl, { timeout: 10000 });
|
|
expect(response.status()).toBeLessThan(500);
|
|
});
|
|
});
|
|
|
|
test.describe('Critical User Flows', () => {
|
|
test('complete user journey: Login -> Dashboard -> Navigation', async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(90000);
|
|
|
|
// Step 1: Login
|
|
await loginViaAPI(
|
|
page,
|
|
CONFIG.users.listener.email,
|
|
CONFIG.users.listener.password,
|
|
);
|
|
|
|
// Verify user is authenticated — after login, URL should not be /login
|
|
await page.waitForURL((url) => !url.pathname.includes('/login'), { timeout: 15000 }).catch(() => {});
|
|
expect(page.url()).not.toContain('/login');
|
|
await expect(
|
|
page.locator('nav[role="navigation"], aside[role="navigation"]'),
|
|
).toBeVisible({ timeout: 10000 });
|
|
|
|
const isAuthenticated = await page.evaluate(() => {
|
|
try {
|
|
const authStorage = localStorage.getItem('auth-storage');
|
|
if (authStorage) {
|
|
const parsed = JSON.parse(authStorage);
|
|
return parsed.state?.isAuthenticated === true;
|
|
}
|
|
} catch {
|
|
return false;
|
|
}
|
|
return false;
|
|
});
|
|
expect(isAuthenticated).toBe(true);
|
|
|
|
// Step 2: Navigate to playlists
|
|
await navigateTo(page, '/playlists');
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Verify page loaded
|
|
const body = page.locator('body');
|
|
const bodyText = (await body.textContent()) || '';
|
|
expect(bodyText.length).toBeGreaterThan(50);
|
|
});
|
|
|
|
test('Login -> Create Playlist (no upload)', async ({ page }) => {
|
|
test.setTimeout(90000);
|
|
|
|
await loginViaAPI(
|
|
page,
|
|
CONFIG.users.listener.email,
|
|
CONFIG.users.listener.password,
|
|
);
|
|
|
|
await page.waitForURL((url) => !url.pathname.includes('/login'), { timeout: 15000 }).catch(() => {});
|
|
await page.waitForTimeout(1_000);
|
|
if (page.url().includes('/login')) {
|
|
test.skip(true, 'Login failed — cannot test playlist creation');
|
|
return;
|
|
}
|
|
|
|
// Navigate to playlists
|
|
await navigateTo(page, '/playlists');
|
|
|
|
// Try to find and click create button — scope to main content to avoid sidebar matches
|
|
const mainContent = page.locator('main').first();
|
|
const mainVisible = await mainContent.isVisible({ timeout: 5_000 }).catch(() => false);
|
|
const searchScope = mainVisible ? mainContent : page;
|
|
|
|
const createButton = searchScope
|
|
.locator(
|
|
'button:has-text("Create"), button:has-text("Créer"), button:has-text("Nouvelle"), button:has-text("New")',
|
|
)
|
|
.first();
|
|
const isCreateVisible = await createButton
|
|
.isVisible({ timeout: 10_000 })
|
|
.catch(() => false);
|
|
|
|
if (!isCreateVisible) {
|
|
test.skip(true, 'Create button not visible — cannot test playlist creation');
|
|
return;
|
|
}
|
|
|
|
await createButton.click({ force: true, timeout: 10_000 });
|
|
await page.waitForTimeout(500);
|
|
|
|
// Fill playlist form if modal appeared
|
|
const titleInput = page
|
|
.locator('input[id="title"], input[name="title"]')
|
|
.first();
|
|
const isTitleVisible = await titleInput
|
|
.isVisible({ timeout: 3000 })
|
|
.catch(() => false);
|
|
|
|
if (isTitleVisible) {
|
|
await titleInput.fill('Quick Test Playlist');
|
|
|
|
// Scope to the dialog to avoid clicking the sidebar button behind the modal overlay
|
|
const dialog = page.locator('[role="dialog"]').first();
|
|
const dialogVisible = await dialog.isVisible({ timeout: 3000 }).catch(() => false);
|
|
const submitScope = dialogVisible ? dialog : page;
|
|
const submitBtn = submitScope
|
|
.locator(
|
|
'button:has-text("Créer"), button:has-text("Create"), button[type="submit"]',
|
|
)
|
|
.first();
|
|
if (await submitBtn.isVisible({ timeout: 3000 }).catch(() => false)) {
|
|
await submitBtn.click();
|
|
await page.waitForTimeout(2000);
|
|
}
|
|
}
|
|
|
|
// Verify page is still functional
|
|
const body = page.locator('body');
|
|
await expect(body).toBeVisible();
|
|
});
|
|
|
|
test('Login -> Upload Track (no playlist)', async ({ page }) => {
|
|
test.setTimeout(120000);
|
|
|
|
await loginViaAPI(
|
|
page,
|
|
CONFIG.users.listener.email,
|
|
CONFIG.users.listener.password,
|
|
);
|
|
|
|
await page.waitForURL((url) => !url.pathname.includes('/login'), { timeout: 15000 }).catch(() => {});
|
|
await page.waitForTimeout(1_000);
|
|
if (page.url().includes('/login')) {
|
|
test.skip(true, 'Login failed — cannot test upload');
|
|
return;
|
|
}
|
|
|
|
// Navigate to library
|
|
await navigateTo(page, '/library');
|
|
|
|
// Try to find upload button
|
|
const uploadButton = page
|
|
.locator(
|
|
'button:has-text("Upload"), button:has-text("Envoyer"), button:has-text("Importer")',
|
|
)
|
|
.first();
|
|
const isUploadVisible = await uploadButton
|
|
.isVisible({ timeout: 5000 })
|
|
.catch(() => false);
|
|
|
|
if (isUploadVisible) {
|
|
await uploadButton.click();
|
|
await page.waitForTimeout(500);
|
|
|
|
// Check for file input
|
|
const fileInputLocator = page.locator('input[type="file"][accept*="audio"]');
|
|
const fileInputCount = await fileInputLocator.count();
|
|
|
|
expect(fileInputCount).toBeGreaterThan(0);
|
|
}
|
|
|
|
// Verify page is still functional
|
|
const body = page.locator('body');
|
|
await expect(body).toBeVisible();
|
|
});
|
|
});
|
|
});
|