fix(m6): remittances — totalAmount field fix, add data-testid, upgrade E2E spec

This commit is contained in:
root
2026-03-31 02:22:43 +00:00
parent 512b9ef830
commit cf369b2da6
2 changed files with 34 additions and 16 deletions

View File

@@ -7,24 +7,42 @@ test.describe('Remittances', () => {
await page.goto('/remittances');
});
test('remittances page renders', async ({ page }) => {
test('page renders with header and table', async ({ page }) => {
await expect(page.locator('h1:has-text("Remittances")')).toBeVisible();
await expect(page.locator('table')).toBeVisible();
});
test('remittances load or show empty state', async ({ page }) => {
await page.waitForTimeout(3000);
const hasRows = await page.locator('tbody tr').count();
const hasEmpty = await page.locator('text=No remittances').isVisible().catch(() => false);
test('submit remittance button exists', async ({ page }) => {
await expect(page.locator('[data-testid="btn-submit-remittance"]')).toBeVisible();
});
test('submit remittance modal opens', async ({ page }) => {
await page.click('[data-testid="btn-submit-remittance"]');
await expect(page.locator('text=Submit Remittance')).toBeVisible({ timeout: 5000 });
// Close modal
await page.locator('button:has-text("Cancel")').click();
await expect(page.locator('text=Submit Remittance')).not.toBeVisible({ timeout: 3000 });
});
test('empty state shows when no remittances', async ({ page }) => {
// Either rows exist OR empty state message shows — both are valid
const hasRows = await page.locator('[data-testid="remittance-row"]').count();
const hasEmpty = await page.locator('text=No remittances yet').isVisible().catch(() => false);
expect(hasRows > 0 || hasEmpty).toBeTruthy();
});
test('Submit Remittance button opens modal', async ({ page }) => {
const btn = page.locator('button:has-text("Submit Remittance"), button:has-text("New Remittance")').first();
if (await btn.isVisible()) {
await btn.click();
await page.waitForTimeout(300);
await expect(page.locator('text=Submit Remittance, text=Remittance').first()).toBeVisible();
test('clicking remittance row opens detail modal', async ({ page }) => {
const rows = page.locator('[data-testid="remittance-row"]');
const count = await rows.count();
if (count === 0) {
// No data — acceptable, skip
test.skip();
return;
}
await rows.first().click();
await expect(page.locator('text=Remittance Details')).toBeVisible({ timeout: 5000 });
await expect(page.locator('text=Total Amount')).toBeVisible();
await page.locator('button:has-text("Close")').click();
await expect(page.locator('text=Remittance Details')).not.toBeVisible({ timeout: 3000 });
});
});