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

UISACQCOMP-218: add "Amount must be a positive number" validation for "Set exchange rate" field. #815

Merged
merged 10 commits into from
Sep 30, 2024

Conversation

alisher-epam
Copy link
Contributor

@alisher-epam alisher-epam commented Sep 18, 2024

Purpose

UISACQCOMP-218: add "Amount must be a positive number" validation for "Set exchange rate" field.

Approach

Screen.Recording.2024-09-26.at.13.56.05.mp4

Pre-Merge Checklist

Before merging this PR, please go through the following list and take appropriate actions.

  • I've added appropriate record to the CHANGELOG.md
  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • If any API-related changes - okapi interfaces and permissions are reviewed/changed correspondingly
    • There are no breaking changes in this PR.

If there are breaking changes, please STOP and consider the following:

  • What other modules will these changes impact?
  • Do JIRAs exist to update the impacted modules?
    • If not, please create them
    • Do they contain the appropriate level of detail? Which endpoints/schemas changed, etc.
    • Do they have all they appropriate links to blocked/related issues?
  • Are the JIRAs under active development?
    • If not, contact the project's PO and make sure they're aware of the urgency.
  • Do PRs exist for these changes?
    • If so, have they been approved?

Ideally all of the PRs involved in breaking changes would be merged in the same day to avoid breaking the folio-testing environment. Communication is paramount if that is to be achieved, especially as the number of intermodule and inter-team dependencies increase.

While it's helpful for reviewers to help identify potential problems, ensuring that it's safe to merge is ultimately the responsibility of the PR assignee.

@alisher-epam alisher-epam self-assigned this Sep 18, 2024
Copy link

github-actions bot commented Sep 18, 2024

Jest Unit Test Statistics

    1 files  ±0  212 suites  ±0   4m 9s ⏱️ +18s
536 tests +2  534 ✔️ +2  2 💤 ±0  0 ±0 
539 runs  +2  537 ✔️ +2  2 💤 ±0  0 ±0 

Results for commit bcc4a6c. ± Comparison against base commit 8a6d401.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Sep 18, 2024

BigTest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit bcc4a6c. ± Comparison against base commit 8a6d401.

♻️ This comment has been updated with latest results.

@alisher-epam
Copy link
Contributor Author

@JohnC-80 after the recent update in the stripes-components here the Selection related tests are failing. Any ideas how to fix the test failures?

@JohnC-80
Copy link

JohnC-80 commented Sep 18, 2024

@alisher-epam With the change you mentioned, Selection doesn't render the list of options if the dropdown is closed. It may just need to be opened before the assertions/actions are performed. Looking at FundDistributionFieldsFinal.test.js - you can use

user.click(screen.getByRole('button', { name: 'stripes-acq-components.fundDistribution.id' })); 

to click the Selection control and open the dropdown prior to clicking the option.

@alisher-epam alisher-epam requested review from a team September 18, 2024 15:13
@OleksandrHladchenko1 OleksandrHladchenko1 requested a review from a team September 19, 2024 12:45
@@ -36,13 +36,14 @@ const renderAffiliationsSelection = (props = {}) => render(
);

describe('AffiliationsSelection', () => {
it('should render affiliation selection with provided options', () => {
it('should render affiliation selection with provided options', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not async

@@ -25,7 +24,7 @@ describe('CountryFilter component', () => {
expect(getByText('ui-organizations.filterConfig.country')).toBeDefined();
});

it('should invoke onChange callback when something is selected', async () => {
it('should invoke onChange callback when something is selected', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@@ -65,6 +65,14 @@ const CurrencyExchangeRateFields = ({
resetExchangeRate();
}, [change, resetExchangeRate, currencyFieldName]);

const validateExchangeRate = (value) => {
if (value === undefined || value === null) {
return validateRequired(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

where did you find such requirement? doing this you introduce inconsistency

@@ -32,6 +32,14 @@ const renderFieldLocationFinalContainer = (props = {}, formProps = {}) => (rende
));

describe('FieldLocationFinalContainer component', () => {
beforeEach(() => {
renderFieldLocationFinalContainer();
Copy link
Contributor

Choose a reason for hiding this comment

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

if you do it in before each, why do you keep render in tests? if you want to avoid such code duplication - update render function, it's not a place for beforeEach

import React from 'react';
import { render, cleanup, fireEvent } from '@testing-library/react';
import {
cleanup,
Copy link
Contributor

Choose a reason for hiding this comment

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

you removed function call, but not import...

@alisher-epam alisher-epam requested review from NikitaSedyx and a team September 26, 2024 09:00
@@ -146,7 +146,7 @@ const CurrencyExchangeRateFields = ({
readOnly={!isExchangeRateEnabled}
tooltipText={tooltipTextExchangeRate}
required={isExchangeRateRequired}
validate={isExchangeRateRequired ? validateRequired : undefined}
validate={isExchangeRateRequired ? validateRequiredPositiveAmount : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

is it expected to skip "positive amount" validation if the field is not required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. If the user wants to set a custom exchange rate then the required checkbox should be checked

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds strange

Copy link
Contributor

Choose a reason for hiding this comment

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

when field is not required you just need to validate when value is populated, introduce another validation method (if doesn't exist) validatePositiveAmount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen.Recording.2024-09-27.at.19.50.42.mp4

Copy link

@usavkov-epam usavkov-epam merged commit d0dde18 into master Sep 30, 2024
6 checks passed
@usavkov-epam usavkov-epam deleted the UISACQCOMP-218 branch September 30, 2024 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants