Skip to content

Commit

Permalink
UICIRC-1064: Fix that Save & close button is missing in the circulati…
Browse files Browse the repository at this point in the history
…on forms
  • Loading branch information
Dmitriy-Litvinenko committed Mar 13, 2024
1 parent 44a1f8e commit ef4cb1d
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/settings/FinePolicy/FinePolicyForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('FinePolicyForm', () => {
const policyForTest = new FinePolicy(mockedInitialValues);
const defaultProps = {
stripes: mockedStripes,
pristine: false,
pristine: true,
submitting: false,
initialValues: mockedInitialValues,
handleSubmit: mockedHandleSubmit,
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('FinePolicyForm', () => {

it('should execute "FooterPane" with passed props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: false,
isSaveButtonDisabled: true,
onCancel: mockedOnCancel,
}, {});
});
Expand Down Expand Up @@ -173,11 +173,11 @@ describe('FinePolicyForm', () => {
});
});

describe('when initialValues are passed ', () => {
describe('when form value was changed', () => {
const defaultTestProps = {
...defaultProps,
pristine: true,
submitting: true,
pristine: false,
submitting: false,
};

beforeEach(() => {
Expand All @@ -190,7 +190,7 @@ describe('FinePolicyForm', () => {

it('should render FooterPane with correct props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: true,
isSaveButtonDisabled: false,
onCancel: mockedOnCancel,
}, {});
});
Expand Down
23 changes: 23 additions & 0 deletions src/settings/LoanPolicy/LoanPolicyForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,27 @@ describe('LoanPolicyForm', () => {
schedulesTest(testIds.renewalsSection);
});
});

describe('when form value was changed', () => {
const defaultTestProps = {
...defaultProps,
pristine: false,
submitting: false,
};

beforeEach(() => {
render(
<LoanPolicyForm
{...defaultTestProps}
/>
);
});

it('should render FooterPane with correct props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: false,
onCancel: mockedOnCancel,
}, {});
});
});
});
23 changes: 23 additions & 0 deletions src/settings/LostItemFeePolicy/LostItemFeePolicyForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,27 @@ describe('LostItemFeePolicyForm', () => {
}), {});
});
});

describe('when form value was changed', () => {
const defaultTestProps = {
...defaultProps,
pristine: false,
submitting: false,
};

beforeEach(() => {
render(
<LostItemFeePolicyForm
{...defaultTestProps}
/>
);
});

it('should render FooterPane with correct props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: false,
onCancel: mockedOnCancel,
}, {});
});
});
});
23 changes: 23 additions & 0 deletions src/settings/NoticePolicy/NoticePolicyForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,27 @@ describe('NoticePolicyForm', () => {
expect(screen.getByText(labelIds.createEntryLabel)).toBeInTheDocument();
});
});

describe('when form value was changed', () => {
const defaultTestProps = {
...defaultProps,
pristine: false,
submitting: false,
};

beforeEach(() => {
render(
<NoticePolicyForm
{...defaultTestProps}
/>
);
});

it('should render FooterPane with correct props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: false,
onCancel: mockedOnCancel,
}, {});
});
});
});
43 changes: 27 additions & 16 deletions src/settings/PatronNotices/PatronNoticeForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('PatronNoticeForm', () => {
values: {}
};
});
const testPristineValue = false;
const testPristineValue = true;
const testSubmittingValue = false;
const testHandleSubmit = jest.fn();
const testOnCancel = jest.fn();
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('PatronNoticeForm', () => {

it('should render FooterPane with correct props', () => {
componentPropsCheck(FooterPane, testIds.patronNoticeFooterPane, {
isSaveButtonDisabled: false,
isSaveButtonDisabled: true,
onCancel: testOnCancel,
});
});
Expand Down Expand Up @@ -201,15 +201,9 @@ describe('PatronNoticeForm', () => {
};

beforeEach(() => {
const defaultProps = {
...defaultTestProps,
pristine: true,
submitting: true,
};

render(
<PatronNoticeForm
{...defaultProps}
{...defaultTestProps}
initialValues={initialValues}
stripes={testStripes}
location={{
Expand All @@ -235,13 +229,6 @@ describe('PatronNoticeForm', () => {
metadata: initialValues.metadata,
}), {});
});

it('should render FooterPane with correct props', () => {
componentPropsCheck(FooterPane, testIds.patronNoticeFooterPane, {
isSaveButtonDisabled: true,
onCancel: testOnCancel,
});
});
});

describe('print only', () => {
Expand All @@ -260,6 +247,7 @@ describe('PatronNoticeForm', () => {
}
};
});

render(
<PatronNoticeForm
{...defaultTestProps}
Expand Down Expand Up @@ -292,4 +280,27 @@ describe('PatronNoticeForm', () => {
expect(screen.queryByTestId(testIds.form)).not.toBeInTheDocument();
});
});

describe('when form value was changed', () => {
const defaultProps = {
...defaultTestProps,
pristine: false,
submitting: false,
};

beforeEach(() => {
render(
<PatronNoticeForm
{...defaultProps}
/>
);
});

it('should render FooterPane with correct props', () => {
componentPropsCheck(FooterPane, testIds.patronNoticeFooterPane, {
isSaveButtonDisabled: false,
onCancel: testOnCancel,
});
});
});
});
10 changes: 5 additions & 5 deletions src/settings/RequestPolicy/RequestPolicyForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('RequestPolicyForm', () => {
const pathname = '/policyId/test';
const defaultProps = {
okapi,
pristine: false,
pristine: true,
stripes,
submitting: false,
onCancel,
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('RequestPolicyForm', () => {

it('should executed FooterPane with correct props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: false,
isSaveButtonDisabled: true,
onCancel,
}, {});
});
Expand Down Expand Up @@ -212,8 +212,8 @@ describe('RequestPolicyForm', () => {
};
const defaultTestProps = {
...defaultProps,
pristine: true,
submitting: true,
pristine: false,
submitting: false,
};
const testPolicy = new RequestPolicy(initialValues);

Expand Down Expand Up @@ -259,7 +259,7 @@ describe('RequestPolicyForm', () => {

it('should executed FooterPane with correct props', () => {
expect(FooterPane).toHaveBeenCalledWith({
isSaveButtonDisabled: true,
isSaveButtonDisabled: false,
onCancel,
}, {});
});
Expand Down

0 comments on commit ef4cb1d

Please sign in to comment.