Skip to content

Commit

Permalink
update frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
adghayes committed Oct 13, 2023
1 parent 30b75b7 commit d7996c7
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ test('disabled shows disabled buttons and no preview', () => {
disabled
filter={{}}
groupBy={{}}
ballotCountBreakdown="none"
autoPreview={false}
/>,
{ apiMock, electionDefinition }
Expand All @@ -80,7 +79,6 @@ test('autoPreview loads preview automatically', async () => {
disabled={false}
filter={{}}
groupBy={{ groupByVotingMethod: true }}
ballotCountBreakdown="none"
autoPreview
/>,
{ apiMock, electionDefinition }
Expand All @@ -98,7 +96,6 @@ test('autoPreview = false does not load preview automatically', async () => {
disabled={false}
filter={{}}
groupBy={{}}
ballotCountBreakdown="none"
autoPreview={false}
/>,
{ apiMock, electionDefinition }
Expand All @@ -122,7 +119,6 @@ test('shows no results warning when no results', async () => {
disabled={false}
filter={{}}
groupBy={{ groupByBatch: true }}
ballotCountBreakdown="none"
autoPreview
/>,
{ apiMock, electionDefinition }
Expand Down Expand Up @@ -157,7 +153,6 @@ test('print before loading preview', async () => {
disabled={false}
filter={{}}
groupBy={{ groupByVotingMethod: true }}
ballotCountBreakdown="none"
autoPreview={false}
/>,
{ apiMock, electionDefinition }
Expand Down Expand Up @@ -198,7 +193,6 @@ test('print after preview loaded + test success logging', async () => {
disabled={false}
filter={{}}
groupBy={{ groupByVotingMethod: true }}
ballotCountBreakdown="none"
autoPreview
/>,
{ apiMock, electionDefinition, logger }
Expand Down Expand Up @@ -244,7 +238,6 @@ test('print while preview is loading', async () => {
disabled={false}
filter={{}}
groupBy={{ groupByVotingMethod: true }}
ballotCountBreakdown="none"
autoPreview={false}
/>,
{ apiMock, electionDefinition }
Expand Down Expand Up @@ -286,7 +279,6 @@ test('print failure logging', async () => {
disabled={false}
filter={{}}
groupBy={{ groupByVotingMethod: true }}
ballotCountBreakdown="none"
autoPreview
/>,
{ apiMock, electionDefinition, logger }
Expand Down Expand Up @@ -332,7 +324,6 @@ test('displays custom filter rather than specific title when necessary', async (
disabled={false}
filter={filter}
groupBy={{}}
ballotCountBreakdown="none"
autoPreview
/>,
{ apiMock, electionDefinition }
Expand Down Expand Up @@ -368,7 +359,6 @@ test('exporting report PDF', async () => {
groupBy={{
groupByVotingMethod: true,
}}
ballotCountBreakdown="none"
autoPreview={false}
/>,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ function Report({
cardCountsList,
filter,
groupBy,
ballotCountBreakdown,
generatedAtTime,
}: {
electionDefinition: ElectionDefinition;
Expand All @@ -112,7 +111,6 @@ function Report({
cardCountsList: Tabulation.GroupList<Tabulation.CardCounts>;
filter: Tabulation.Filter;
groupBy: Tabulation.GroupBy;
ballotCountBreakdown: Tabulation.BallotCountBreakdown;
generatedAtTime: Date;
}): JSX.Element {
const titleGeneration = generateTitleForReport({
Expand All @@ -137,23 +135,20 @@ function Report({
scannerBatches,
generatedAtTime,
groupBy,
ballotCountBreakdown,
cardCountsList,
});
}

export interface BallotCountReportViewerProps {
filter: Tabulation.Filter;
groupBy: Tabulation.GroupBy;
ballotCountBreakdown: Tabulation.BallotCountBreakdown;
disabled: boolean;
autoPreview: boolean;
}

export function BallotCountReportViewer({
filter,
groupBy,
ballotCountBreakdown,
disabled: disabledFromProps,
autoPreview,
}: BallotCountReportViewerProps): JSX.Element {
Expand Down Expand Up @@ -207,7 +202,6 @@ export function BallotCountReportViewer({
electionDefinition={assertDefined(electionDefinition)}
filter={filter}
groupBy={groupBy}
ballotCountBreakdown={ballotCountBreakdown}
cardCountsList={cardCountsQuery.data}
generatedAtTime={new Date(cardCountsQuery.dataUpdatedAt)}
isOfficialResults={isOfficialResults}
Expand All @@ -220,7 +214,6 @@ export function BallotCountReportViewer({
electionDefinition,
filter,
groupBy,
ballotCountBreakdown,
cardCountsQuery.data,
cardCountsQuery.dataUpdatedAt,
isOfficialResults,
Expand Down Expand Up @@ -254,7 +247,6 @@ export function BallotCountReportViewer({
electionDefinition={assertDefined(electionDefinition)}
filter={filter}
groupBy={groupBy}
ballotCountBreakdown={ballotCountBreakdown}
cardCountsList={queryResults.data}
generatedAtTime={new Date(queryResults.dataUpdatedAt)}
isOfficialResults={isOfficialResults}
Expand Down Expand Up @@ -294,7 +286,6 @@ export function BallotCountReportViewer({
electionDefinition={assertDefined(electionDefinition)}
filter={filter}
groupBy={groupBy}
ballotCountBreakdown={ballotCountBreakdown}
cardCountsList={queryResults.data}
generatedAtTime={new Date(queryResults.dataUpdatedAt)}
isOfficialResults={isOfficialResults}
Expand Down Expand Up @@ -336,7 +327,6 @@ export function BallotCountReportViewer({
<ExportBallotCountReportCsvButton
filter={filter}
groupBy={groupBy}
ballotCountBreakdown={ballotCountBreakdown}
disabled={disabled || areQueryResultsEmpty}
/>
</ExportActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ test('calls mutation in happy path', async () => {
};

renderInAppContext(
<ExportBallotCountReportCsvButton
filter={filter}
groupBy={groupBy}
ballotCountBreakdown="none"
/>,
<ExportBallotCountReportCsvButton filter={filter} groupBy={groupBy} />,
{
apiMock,
usbDriveStatus: mockUsbDriveStatus('mounted'),
Expand All @@ -50,7 +46,6 @@ test('calls mutation in happy path', async () => {
apiMock.expectExportBallotCountReportCsv({
filter,
groupBy,
ballotCountBreakdown: 'none',
path: 'test-mount-point/choctaw-county_mock-general-election-choctaw-2020_d6806afc49/reports/absentee-ballots-ballot-count-report-by-precinct__2021-01-01_00-00-00.csv',
});
userEvent.click(within(modal).getButton('Save'));
Expand All @@ -64,12 +59,7 @@ test('calls mutation in happy path', async () => {

test('disabled by disabled prop', () => {
renderInAppContext(
<ExportBallotCountReportCsvButton
disabled
filter={{}}
groupBy={{}}
ballotCountBreakdown="none"
/>,
<ExportBallotCountReportCsvButton disabled filter={{}} groupBy={{}} />,
{ apiMock }
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ import {
export function ExportBallotCountReportCsvButton({
filter,
groupBy,
ballotCountBreakdown,
disabled,
}: {
filter: Tabulation.Filter;
groupBy: Tabulation.GroupBy;
ballotCountBreakdown: Tabulation.BallotCountBreakdown;
disabled?: boolean;
}): JSX.Element {
const { electionDefinition } = useContext(AppContext);
Expand Down Expand Up @@ -77,7 +75,6 @@ export function ExportBallotCountReportCsvButton({
path: savePath,
filter,
groupBy,
ballotCountBreakdown,
})
}
saveFileResult={exportBallotCountReportCsvMutation.data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ test('happy path', async () => {

await screen.findByText('Unofficial Absentee Ballot Ballot Count Report');
expect(screen.getByTestId('footer-total')).toHaveTextContent('10');
expect(screen.queryByTestId('footer-bmd')).not.toBeInTheDocument();

// Change Report Parameters
userEvent.click(screen.getByLabelText('Remove Absentee'));
Expand All @@ -109,9 +108,6 @@ test('happy path', async () => {
within(screen.getByTestId('filter-editor')).getByText('Precinct')
);

userEvent.click(screen.getByLabelText('Select Breakdown Type'));
userEvent.click(screen.getByText('HMPB vs. BMD'));

// Refresh Preview
apiMock.expectGetCardCounts(
{
Expand All @@ -129,9 +125,7 @@ test('happy path', async () => {

await screen.findByText('Unofficial Precinct Ballot Ballot Count Report');
expect(screen.getByTestId('footer-total')).toHaveTextContent('20');
// we added the breakdown, so we should have a BMD subtotal too
expect(screen.getByTestId('footer-bmd')).toHaveTextContent('20');
// we haven't added manual counts, so there should be no manual column
expect(screen.queryByTestId('footer-manual')).not.toBeInTheDocument();

// Print Report
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Font,
H3,
Icons,
LinkButton,
P,
SearchSelect,
SelectOption,
} from '@votingworks/ui';
import { Font, H3, Icons, LinkButton, P } from '@votingworks/ui';
import { useContext, useState } from 'react';
import { assert } from '@votingworks/basics';
import {
Expand Down Expand Up @@ -43,16 +35,6 @@ const GroupByEditorContainer = styled.div`
margin-bottom: 2rem;
`;

const BreakdownSelectContainer = styled.div`
display: grid;
grid-template-columns: min-content 20%;
align-items: center;
gap: 1rem;
margin-top: 0.5rem;
margin-bottom: 2rem;
white-space: nowrap;
`;

export function BallotCountReportBuilder(): JSX.Element {
const { electionDefinition, auth } = useContext(AppContext);
assert(electionDefinition);
Expand All @@ -61,8 +43,6 @@ export function BallotCountReportBuilder(): JSX.Element {

const [filter, setFilter] = useState<Tabulation.Filter>({});
const [groupBy, setGroupBy] = useState<Tabulation.GroupBy>({});
const [breakdown, setBreakdown] =
useState<Tabulation.BallotCountBreakdown>('none');

function updateFilter(newFilter: Tabulation.Filter) {
setFilter(canonicalizeFilter(newFilter));
Expand Down Expand Up @@ -91,18 +71,6 @@ export function BallotCountReportBuilder(): JSX.Element {
allowedGroupBys.push('groupByParty');
}

const breakdownOptions: Array<SelectOption<Tabulation.BallotCountBreakdown>> =
[
{
value: 'none',
label: 'None',
},
{
value: 'marking-method',
label: 'HMPB vs. BMD',
},
];

const hasMadeSelections = !isFilterEmpty(filter) || !isGroupByEmpty(groupBy);
return (
<NavigationScreen title={SCREEN_TITLE}>
Expand Down Expand Up @@ -140,25 +108,9 @@ export function BallotCountReportBuilder(): JSX.Element {
allowedGroupings={allowedGroupBys}
/>
</GroupByEditorContainer>
<H3>Options</H3>

<BreakdownSelectContainer>
<Font>Scanned Ballot Count Breakdown:</Font>
<SearchSelect
isMulti={false}
isSearchable={false}
value={breakdown}
options={breakdownOptions}
onChange={(value) =>
setBreakdown(value as Tabulation.BallotCountBreakdown)
}
ariaLabel="Select Breakdown Type"
/>
</BreakdownSelectContainer>
<BallotCountReportViewer
filter={filter}
groupBy={groupBy}
ballotCountBreakdown={breakdown}
disabled={!hasMadeSelections}
autoPreview={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function PrecinctBallotCountReport(): JSX.Element {
groupByPrecinct: true,
groupByParty: electionDefinition.election.type === 'primary',
}}
ballotCountBreakdown="marking-method"
disabled={false}
autoPreview
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function VotingMethodBallotCountReport(): JSX.Element {
groupByVotingMethod: true,
groupByParty: electionDefinition.election.type === 'primary',
}}
ballotCountBreakdown="marking-method"
disabled={false}
autoPreview
/>
Expand Down
4 changes: 1 addition & 3 deletions apps/admin/frontend/test/helpers/mock_api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,13 @@ export function createApiMock(
path,
filter,
groupBy,
ballotCountBreakdown,
}: {
path: string;
filter?: Tabulation.Filter;
groupBy?: Tabulation.GroupBy;
ballotCountBreakdown: Tabulation.BallotCountBreakdown;
}) {
apiClient.exportBallotCountReportCsv
.expectCallWith({ path, groupBy, filter, ballotCountBreakdown })
.expectCallWith({ path, groupBy, filter })
.resolves(ok([]));
},

Expand Down

0 comments on commit d7996c7

Please sign in to comment.