Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const reimbursableZero = {
};

const salariedFullTimeMock: PdsGoalCalculationMock = {
formType: DesignationSupportFormType.Detailed,
salaryOrHourly: DesignationSupportSalaryType.Salaried,
payRate: 60000,
hoursWorkedPerWeek: null,
Expand Down Expand Up @@ -260,4 +261,39 @@ describe('PdsSummaryTable', () => {
getByRole('gridcell', { name: '403b Contributions' }),
).toBeInTheDocument();
});

describe('Line column labels', () => {
it('shows alphabetical sub-item labels and numbered labels 1–5', async () => {
const { findByRole, getByRole } = render(
<PdsGoalCalculatorTestWrapper calculationMock={salariedFullTimeMock}>
<PdsSummaryTable supportRaised={0} />
</PdsGoalCalculatorTestWrapper>,
);

await findByRole('gridcell', { name: 'Salary Subtotal' });

['1A', '1B', '2A', '2B', '2C', '1', '2', '3', '4', '5'].forEach((label) =>
expect(getByRole('gridcell', { name: label })).toBeInTheDocument(),
);
});

it('shows only 2A for Other Subtotal sub items when formType is Simple', async () => {
const { findByRole, getByRole, queryByRole } = render(
<PdsGoalCalculatorTestWrapper
calculationMock={{
...salariedFullTimeMock,
formType: DesignationSupportFormType.Simple,
}}
>
<PdsSummaryTable supportRaised={0} />
</PdsGoalCalculatorTestWrapper>,
);

await findByRole('gridcell', { name: 'Benefits' });

expect(getByRole('gridcell', { name: '2A' })).toBeInTheDocument();
expect(queryByRole('gridcell', { name: '2B' })).not.toBeInTheDocument();
expect(queryByRole('gridcell', { name: '2C' })).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const PdsSummaryTable: React.FC<PdsSummaryTableProps> = ({
...(isPartTime
? [
{
line: '2C',
line: isSimple ? '2A' : '2C',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] `isSimple ? '2A' : '2C'` is identical on lines 128 and 137. A local variable would remove the duplication:
const singleSubItemLine = isSimple ? '2A' : '2C';

Not blocking — readability note only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the current impl more readable, however, >= 3 occurrences I would definitely do this.

category: t('Work Comp'),
amount: otherTotals.workComp,
},
Expand All @@ -134,7 +134,7 @@ export const PdsSummaryTable: React.FC<PdsSummaryTableProps> = ({
...(isFullTime
? [
{
line: '2C',
line: isSimple ? '2A' : '2C',
category: t('Benefits'),
amount: otherTotals.benefits,
},
Expand Down Expand Up @@ -197,7 +197,7 @@ export const PdsSummaryTable: React.FC<PdsSummaryTableProps> = ({
sortable: false,
hideable: false,
renderCell: (params) =>
/^[1-5]$/.test(params.row.line) ? params.value : '',
/^[1-5][A-C]?$/.test(params.row.line) ? params.value : '',
},
{
field: 'category',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('StaffExpenseReport', () => {
expect(getByRole('button', { name: 'Next Month' })).toBeInTheDocument();
}, 10000);

it('shows filter date range title and hides month navigation when date filters are applied', async () => {
it('hides month navigation when date filters are applied', async () => {
Settings.now = () => new Date(2020, 0, 20).valueOf();

const { getByRole, findByRole, getByLabelText, queryByRole } = render(
Expand All @@ -309,17 +309,7 @@ describe('StaffExpenseReport', () => {
userEvent.click(getByLabelText('Select Date Range'));
userEvent.click(getByRole('option', { name: 'Month to Date' }));

await waitFor(() =>
expect(getByRole('button', { name: 'Apply Filters' })).not.toBeDisabled(),
);
userEvent.click(getByRole('button', { name: 'Apply Filters' }));

expect(
await findByRole('heading', {
level: 6,
name: 'January 1, 2020 - January 20, 2020',
}),
).toBeInTheDocument();
userEvent.click(await findByRole('button', { name: 'Apply Filters' }));

expect(
queryByRole('button', { name: 'Previous Month' }),
Expand Down
Loading