feat: add end-to-end tests for Agents, Chat, Navigation, and Settings screens

This commit is contained in:
Jonathan Atta
2026-03-03 14:47:44 +01:00
parent 41c7634b75
commit a213b1593a
11 changed files with 363 additions and 6 deletions

109
app/e2e/agents.e2e.js Normal file
View File

@@ -0,0 +1,109 @@
/**
* e2e/agents.e2e.js
*
* Verifies the Agents screen:
* - screen renders correctly
* - new agent can be created
* - created agent appears in the list
* - agent editor can be reopened (edit flow)
* - agent can be deleted via the delete button
*/
const { navigatePastSplash, tapTab } = require('./helpers');
const TEST_AGENT_NAME = 'E2E Test Agent';
const TEST_AGENT_ID = 'E2E-Test-Agent'; // name with spaces replaced by dashes
describe('Agents Screen', () => {
beforeAll(async () => {
await device.launchApp({ newInstance: true });
await navigatePastSplash();
await tapTab('Agents');
// Use testID to avoid matching the bottom tab bar "Agents" label
await waitFor(element(by.id('agents-screen-title')))
.toBeVisible()
.withTimeout(5000);
});
// ─── Render ──────────────────────────────────────────────────────────────
it('shows the Agents screen header', async () => {
await expect(element(by.id('agents-screen-title'))).toBeVisible();
});
it('shows the Nouvel agent button', async () => {
await expect(element(by.id('new-agent-btn'))).toBeVisible();
});
// ─── Create agent ─────────────────────────────────────────────────────────
it('opens the agent editor when tapping Nouvel agent', async () => {
await element(by.id('new-agent-btn')).tap();
await waitFor(element(by.text("Nom de l'agent")))
.toBeVisible()
.withTimeout(4000);
});
it('shows the name input in the editor', async () => {
await expect(element(by.id('agent-name-input'))).toBeVisible();
});
it('shows the Créer save button for a new agent', async () => {
await expect(element(by.id('agent-save-btn'))).toBeVisible();
await expect(element(by.text('Créer'))).toBeVisible();
});
it('fills in the agent name and saves', async () => {
await element(by.id('agent-name-input')).clearText();
await element(by.id('agent-name-input')).typeText(TEST_AGENT_NAME);
await element(by.id('agent-save-btn')).tap();
// Editor should close after save
await waitFor(element(by.text("Nom de l'agent")))
.not.toBeVisible()
.withTimeout(5000);
});
it('shows the newly created agent in the list', async () => {
await waitFor(element(by.text(TEST_AGENT_NAME)))
.toBeVisible()
.withTimeout(5000);
});
// ─── Edit agent ───────────────────────────────────────────────────────────
it('opens the editor when tapping on an existing agent card', async () => {
await element(by.text(TEST_AGENT_NAME)).tap();
await waitFor(element(by.text("Nom de l'agent")))
.toBeVisible()
.withTimeout(4000);
});
it('shows "Mettre à jour" button when editing an existing agent', async () => {
await expect(element(by.text('Mettre à jour'))).toBeVisible();
});
it('closes the editor without saving when tapping Annuler', async () => {
await element(by.text('Annuler')).tap();
await waitFor(element(by.text("Nom de l'agent")))
.not.toBeVisible()
.withTimeout(4000);
// Agent name still visible in the list
await expect(element(by.text(TEST_AGENT_NAME))).toBeVisible();
});
// ─── Delete agent ─────────────────────────────────────────────────────────
it('shows the delete confirmation alert when tapping the delete button', async () => {
await element(by.id(`delete-agent-${TEST_AGENT_ID}`)).tap();
await waitFor(element(by.text('Supprimer')))
.toBeVisible()
.withTimeout(4000);
});
it('removes the agent after confirming deletion', async () => {
// Tap the destructive "Supprimer" action in the Alert
await element(by.text('Supprimer')).tap();
await waitFor(element(by.text(TEST_AGENT_NAME)))
.not.toBeVisible()
.withTimeout(5000);
});
});