Skip to content

Commit

Permalink
feat: ApplyButton is not shown when the reporting window is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-foucault committed Sep 1, 2020
1 parent fca6986 commit 09e1292
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 69 deletions.
6 changes: 1 addition & 5 deletions app/containers/Applications/ApplyButtonContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ export const ApplyButton: React.FunctionComponent<Props> = ({
]);

if (!canOpenApplication) {
return (
<Button disabled variant="info">
The application window is closed
</Button>
);
return null;
}

if (!applicationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('The apply button', () => {
);
});

it('should render a disabled button if no applicationByApplicationId exists and the application window is closed', () => {
it('should not render anything if no applicationByApplicationId exists and the application window is closed', () => {
const r = shallow(
<ApplyButton
relay={null}
Expand All @@ -84,13 +84,10 @@ describe('The apply button', () => {
/>
);

expect(r).toMatchSnapshot();
expect(r.exists('Button')).toBe(true);
expect(r.find('Button').prop('disabled')).toBe(true);
expect(r.find('Button').text()).toBe('The application window is closed');
expect(r).toEqual({});
});

it('should render a disabled button if no applicationByApplicationId exists and query.openedReportingYear.reportingYear !== reportingYear', () => {
it('should not render anything if no applicationByApplicationId exists and query.openedReportingYear.reportingYear !== reportingYear', () => {
const r = shallow(
<ApplyButton
relay={null}
Expand All @@ -113,10 +110,7 @@ describe('The apply button', () => {
/>
);

expect(r).toMatchSnapshot();
expect(r.exists('Button')).toBe(true);
expect(r.find('Button').prop('disabled')).toBe(true);
expect(r.find('Button').text()).toBe('The application window is closed');
expect(r).toEqual({});
});

it('should render a Resume Application button if an application revision exists with draft status and the application window is open', () => {
Expand Down Expand Up @@ -155,7 +149,7 @@ describe('The apply button', () => {
expect(r.find('Button').text()).toBe('Resume CIIP application');
});

it('should render a disabled button if an application revision exists with draft status, its versionNumber is 1, and the application window is closed', () => {
it('should not render anything if an application revision exists with draft status, its versionNumber is 1, and the application window is closed', () => {
const r = shallow(
<ApplyButton
relay={null}
Expand Down Expand Up @@ -184,13 +178,10 @@ describe('The apply button', () => {
/>
);

expect(r).toMatchSnapshot();
expect(r.exists('Button')).toBe(true);
expect(r.find('Button').prop('disabled')).toBe(true);
expect(r.find('Button').text()).toBe('The application window is closed');
expect(r).toEqual({});
});

it('should render a disabled button if an application revision exists with draft status, its versionNumber is > 1, and the application window is closed', () => {
it('should not render anything if an application revision exists with draft status, its versionNumber is > 1, and the application window is closed', () => {
const r = shallow(
<ApplyButton
relay={null}
Expand Down Expand Up @@ -219,9 +210,7 @@ describe('The apply button', () => {
/>
);

expect(r).toMatchSnapshot();
expect(r.exists('Button')).toBe(true);
expect(r.find('Button').text()).toBe('Resume CIIP application');
expect(r).toEqual({});
});

it('should render a View Application button if an application revision exists with submitted status', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,51 +104,6 @@ exports[`The apply button should render a View Application button if an applicat
</Link>
`;

exports[`The apply button should render a disabled button if an application revision exists with draft status, its versionNumber is > 1, and the application window is closed 1`] = `
<Button
active={false}
disabled={false}
onClick={[Function]}
type="button"
variant="primary"
>
Resume CIIP application
</Button>
`;

exports[`The apply button should render a disabled button if an application revision exists with draft status, its versionNumber is 1, and the application window is closed 1`] = `
<Button
active={false}
disabled={true}
type="button"
variant="info"
>
The application window is closed
</Button>
`;

exports[`The apply button should render a disabled button if no applicationByApplicationId exists and query.openedReportingYear.reportingYear !== reportingYear 1`] = `
<Button
active={false}
disabled={true}
type="button"
variant="info"
>
The application window is closed
</Button>
`;

exports[`The apply button should render a disabled button if no applicationByApplicationId exists and the application window is closed 1`] = `
<Button
active={false}
disabled={true}
type="button"
variant="info"
>
The application window is closed
</Button>
`;

exports[`The apply button should render a warning modal if no swrs report exists 1`] = `
<Fragment>
<Bootstrap(Modal)
Expand Down

0 comments on commit 09e1292

Please sign in to comment.