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

ENT-7820 Learner Credit table sorting #373

Merged
merged 2 commits into from
Jan 18, 2024
Merged

Conversation

jono-booth
Copy link
Contributor

There were a couple issues with the sortDataTableData method.

  1. It wasn't returning the result of the ternary, so needed to set the result to a var and return the var
  2. lodash.snakecase was stripping out the - which is used for sorting in reverse. Moved the snakecase call before the - was prepended.

Added some test for asc and desc sorting.

Copy link
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

Running the PR locally, it is sorting as expected 👍🏽 but noticed some failing tests. Will run the CI on this for now while it gets corrected.

renderWithRouter(<DashboardDatatableWrapper />);
const tableHeader = screen.getByText('Start date');

fireEvent.click(tableHeader);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of fireEvent the repo is leaning towards userEvent in testing. See

it('renders policy type and selects AssignedLearnerCreditAccessPolicy', async () => {
const updatedInitialState = {
...initialStateValue,
multipleFunds: false,
formData: {
...initialStateValue.formData,
policies: INITIAL_POLICIES.singlePolicy,
},
};
renderWithRouter(
<ProvisioningFormPolicyContainerWrapper
value={updatedInitialState}
sampleCatalogQuery={INITIAL_POLICIES.singlePolicy}
/>,
);
expect(screen.getByText(POLICY_TYPE.TITLE)).toBeTruthy();
expect(screen.getByText(POLICY_TYPE.LABEL)).toBeTruthy();
userEvent.click(screen.getByTestId(POLICY_TYPE.OPTIONS.ADMIN_SELECTS.DESCRIPTION));
await waitFor(() => {
expect(screen.getByTestId(POLICY_TYPE.OPTIONS.ADMIN_SELECTS.DESCRIPTION).checked).toBeTruthy();
});
});
for an example of its usage

import userEvent from '@testing-library/user-event';

const tableHeader = screen.getByText('Start date');

    userEvent.click(tableHeader);

if (sortByObject.id === 'isActive') {
return sortByObject.desc ? '-expirationDatetime' : 'expirationDatetime';
let sortString = sortByObject.id;
if ( sortString === 'isActive') {
Copy link
Member

Choose a reason for hiding this comment

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

Noticed some linting errors on this PR. Running the script npm run lint should point out where those linting errors exists and how to correct them.

Screenshot 2024-01-05 at 11 41 32 AM

@jono-booth
Copy link
Contributor Author

Running the PR locally, it is sorting as expected 👍🏽 but noticed some failing tests. Will run the CI on this for now while it gets corrected.

Thanks for the feedback. Sorted the linting issues out and using userEvent instead of fireEvent in the test.

@jono-booth jono-booth requested a review from brobro10000 January 8, 2024 07:04
Copy link
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏽 Great job

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f00e83f) 88.09% compared to head (bc01aa4) 88.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
+ Coverage   88.09%   88.10%   +0.01%     
==========================================
  Files         162      162              
  Lines        3377     3380       +3     
  Branches      837      836       -1     
==========================================
+ Hits         2975     2978       +3     
  Misses        398      398              
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brobro10000 brobro10000 merged commit e973eb5 into openedx:master Jan 18, 2024
5 of 6 checks passed
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.

2 participants