fixes a number of issues

This commit is contained in:
2026-05-26 23:20:31 -07:00
parent 78bd1d92e0
commit 4fca49bff0
6 changed files with 199 additions and 63 deletions

View File

@@ -234,7 +234,7 @@ test.describe('Bulk Code Transactions - Happy Path', () => {
await openBulkCodeModal(page);
// Should show all transactions
await expect(page.locator('text=Bulk editing 5 transactions')).toBeVisible();
await expect(page.locator('text=Bulk editing 6 transactions')).toBeVisible();
// Add account at 100%
await addNewAccount(page);
@@ -263,6 +263,61 @@ test.describe('Bulk Code Transactions - Validation', () => {
await expect(page.locator('#modal-holder[x-show="open"]')).toBeVisible();
});
test('should preserve vendor and status on validation error', async ({ page }) => {
await navigateToTransactions(page);
await selectTransactionByIndex(page, 0);
await openBulkCodeModal(page);
// Select vendor
const testInfo = await getTestInfo(page);
const vendorId = testInfo.accounts.vendor;
const vendorContainer = page.locator('div[hx-post*="vendor-changed"]').first();
const vendorHidden = vendorContainer.locator('input[type="hidden"]').first();
await vendorHidden.evaluate((el: HTMLInputElement, value: string) => {
const newInput = document.createElement('input');
newInput.type = 'hidden';
newInput.name = el.name;
newInput.value = value;
el.parentNode.replaceChild(newInput, el);
}, vendorId.toString());
await vendorContainer.evaluate((el: HTMLElement) => {
el.dispatchEvent(new Event('change', { bubbles: true }));
});
await page.waitForResponse(response => response.url().includes('/vendor-changed') && response.status() === 200);
await page.waitForTimeout(500);
// Select approval status
const statusSelect = page.locator('select[name="step-params[approval-status]"]').first();
await statusSelect.selectOption('approved');
// Vendor selection pre-populated a default account row at 100%.
// Modify its percentage to 50% (invalid - doesn't total 100%).
await setAccountPercentage(page, 0, '50');
await submitBulkCodeForm(page);
await page.waitForTimeout(1000);
// Modal should still be open
await expect(page.locator('#modal-holder[x-show="open"]')).toBeVisible();
// Vendor should still be selected
const vendorHiddenAfter = page.locator('input[type="hidden"][name="step-params[vendor]"]').first();
const vendorValueAfter = await vendorHiddenAfter.inputValue();
expect(vendorValueAfter).toBe(vendorId.toString());
// Status should still be selected
const statusValueAfter = await statusSelect.inputValue();
expect(statusValueAfter).toBe('approved');
// Should show validation error
const errorText = await getModalErrorText(page);
expect(errorText).toContain('does not equal 100%');
});
test('should reject when account percentages total less than 100%', async ({ page }) => {
await navigateToTransactions(page);
await selectTransactionByIndex(page, 0);
@@ -447,7 +502,7 @@ test.describe('Bulk Code Transactions - Vendor Pre-population', () => {
await page.waitForSelector('table tbody tr');
});
test('should NOT pre-populate default account when user has multiple clients', async ({ page }) => {
test('should pre-populate non-clientized default account when user has multiple clients', async ({ page }) => {
// Switch to multi-client mode
await page.request.get('/test-set-client-mode?mode=multi-client');
@@ -480,13 +535,15 @@ test.describe('Bulk Code Transactions - Vendor Pre-population', () => {
await page.waitForResponse(response => response.url().includes('/vendor-changed') && response.status() === 200);
await page.waitForTimeout(500);
// Should NOT have pre-populated account rows - only the "New account" button row
const accountRows = page.locator('#account-entries tbody tr');
const rowCount = await accountRows.count();
// With multi-client, no pre-population should happen, so only 1 row (the "New account" button)
expect(rowCount).toBe(1);
// Should pre-populate the vendor's default account (non-clientized) plus the "New account" row
const accountInputs = page.locator('#account-entries input[type="hidden"][name*="[account]"]');
const accountInputCount = await accountInputs.count();
expect(accountInputCount).toBe(1);
// The pre-populated account should be the vendor's raw default account (test-account)
const accountValue = await accountInputs.first().inputValue();
expect(accountValue).toBe(testInfo.accounts['test-account'].toString());
// Switch back to single-client mode for other tests
await page.request.get('/test-set-client-mode?mode=single-client');
});