Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up majority of frontend test warnings. #1078

Merged
merged 4 commits into from
Mar 16, 2021

Conversation

devinleighsmith
Copy link
Contributor

No description provided.

@@ -66,7 +66,7 @@
"devDependencies": {
"@babel/preset-typescript": "7.8.3",
"@react-leaflet/core": "1.0.2",
"@testing-library/dom": "7.2.2",
"@testing-library/dom": "7.22.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this cleans up a warning within the tests.

const touch = getIn(touched, field);
const checked = getIn(values, field);
const error = getIn(errors, field);
const asElement: any = is || 'input';
useEffect(() => {
if (checked === true || checked === false) {
if ((checked === true || checked === false) && initialChecked !== checked) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this useeffect shouldn't be triggered on page load just because the initialvalue (and therefore the value) is not undefined.

it('renders RequestAccessPage correctly', () => {
const tree = renderer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renderer.create has a separate setup/teardown/act pattern that we aren't using, rather then implement that pattern and the pattern used by react-testing-library, just switch to using react-testing-library for snapshots consistently across the application to avoid act warnings.

<ManageAccessRequests />
</Provider>
</Router>,
<Formik initialValues={{}} onSubmit={noop}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

due to some changes in the table, any test component wrapping the table needs to include a Formik provider to avoid warnings.

@@ -66,30 +67,28 @@ const getStore = () =>
});

describe('Manage Agencies Component', () => {
beforeAll(() => {
const { getComputedStyle } = window;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this just fixes test warnings, no functional changes. see NickColley/jest-axe#147

@codecov-io
Copy link

codecov-io commented Mar 16, 2021

Codecov Report

Merging #1078 (f957cc3) into dev (1d04555) will increase coverage by 0.00%.
The diff coverage is 90.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #1078   +/-   ##
=======================================
  Coverage   65.31%   65.32%           
=======================================
  Files         787      787           
  Lines       22211    22222   +11     
  Branches     3765     3769    +4     
=======================================
+ Hits        14507    14516    +9     
- Misses       7329     7331    +2     
  Partials      375      375           
Flag Coverage Δ
unittests 65.32% <90.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rontend/src/features/projects/dispose/testUtils.ts 100.00% <ø> (ø)
...rojects/spl/forms/CloseOutFinancialSummaryForm.tsx 92.59% <75.00%> (-7.41%) ⬇️
frontend/src/components/common/form/Check.tsx 89.65% <100.00%> (+0.36%) ⬆️
...ojects/common/components/ProjectFinancialTable.tsx 100.00% <100.00%> (ø)
...ontend/src/features/projects/spl/steps/SplStep.tsx 83.33% <0.00%> (-1.52%) ⬇️
frontend/src/utils/utils.ts 76.61% <0.00%> (+0.80%) ⬆️

@@ -89,6 +88,35 @@ const getMockProject = (statusCode?: string): IProject => ({
isActive: false,
workflowCode: '',
},
marketedOn: '2020-01-01',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these financials ensure that the calculated gainBeforeSpl and netProceeds will not change when the form loads from calculations. This allows the test to proceed without having to specifically wait for those calculations to update the dom.

);
}, [market, interestComponent, salesCost, netBook, setFieldValue]);
if (gainBeforeSpl !== calculatedValue) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

one of the few code changes in this PR, don't trigger a state update unless the value has actually changed.

getNumber(salesCost),
getNumber(netBook),
),
const calculatedValue = calcGainBeforeSpl(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

due to duplicated code I had to make the same code change as the projectfinancialsTable here as well.

Copy link
Contributor

@goemen goemen left a comment

Choose a reason for hiding this comment

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

Nice work

@devinleighsmith devinleighsmith merged commit 05608fd into bcgov:dev Mar 16, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants