Skip to content

Commit 6cf7ec6

Browse files
refactored
1 parent 40aeb18 commit 6cf7ec6

1 file changed

Lines changed: 0 additions & 37 deletions

File tree

cypress/support/commands/payments/payroll.commands.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
11
import { TIMEOUTS } from '../../constants';
22

3-
// PaymentPlanPicker renders as a MUI Select (SelectInput) with options
4-
// formatted as "{code} - {name}". The picker fetches plans on
5-
// componentDidMount via Redux; if the SELECT is clicked before the RESP
6-
// action arrives and causes a re-render that closes the dropdown, we retry.
7-
//
8-
// NOTE(decision): we tried `cy.chooseMuiSelect('Payment Plan Picker', code)`
9-
// to piggy-back on the generic helper, but the listbox re-render closes the
10-
// dropdown between `.click()` and `cy.contains()` which surfaces as
11-
// intermittent timeouts in CI. The retry loop below handles that case
12-
// explicitly. If the underlying data-fetch timing ever changes, revisit.
13-
function choosePayrollPaymentPlan(code) {
14-
const openAndPick = (attempt) => {
15-
cy.contains('label', 'Payment Plan Picker')
16-
.siblings('.MuiInputBase-root')
17-
.find('[role="button"]')
18-
.click();
19-
20-
cy.get('[role="listbox"]', { timeout: 10000 }).should('exist').then(($lb) => {
21-
const match = $lb.find(`li:contains("${code}")`);
22-
if (match.length > 0) {
23-
cy.wrap(match.first()).click();
24-
} else if (attempt < 3) {
25-
cy.log(`choosePayrollPaymentPlan attempt ${attempt}: "${code}" not found. Options: ` +
26-
[...$lb.find('li')].slice(0, 10).map((li) => li.innerText.trim()).join(' | '));
27-
cy.get('body').type('{esc}');
28-
// eslint-disable-next-line cypress/no-unnecessary-waiting
29-
cy.wait(1000);
30-
openAndPick(attempt + 1);
31-
} else {
32-
cy.contains('[role="listbox"] li', code, { timeout: 10000 }).click();
33-
}
34-
});
35-
};
36-
37-
openAndPick(1);
38-
}
39-
403
export function registerPayrollCommands() {
414
Cypress.Commands.add('assertPayrollDetailFields', ({
425
name,

0 commit comments

Comments
 (0)