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

fix(uaa-parity): Fix consecutive version events issue #3828

Merged
merged 7 commits into from
Jan 10, 2025

Conversation

JChan106
Copy link
Contributor

@JChan106 JChan106 commented Jan 7, 2025

Handle UAA consecutive version events in a range. Also replaces enzyme with RTL in corresponding test.

@JChan106 JChan106 requested review from a team as code owners January 7, 2025 05:06
Comment on lines 39 to 55
let actionMessage = '';
if (action === ACTION_TYPE_CREATED) {
actionMessage = ACTION_MESSAGE_UPLOAD;
} else if (action === ACTION_TYPE_RESTORED) {
actionMessage = ACTION_MESSAGE_RESTORE;
} else if (action === ACTION_TYPE_TRASHED) {
actionMessage = ACTION_MESSAGE_TRASH;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use a switch statement for extendability and readability?

Comment on lines +31 to +35
action !== 'upload' &&
action !== ACTION_TYPE_RESTORED &&
action !== ACTION_TYPE_TRASHED &&
action !== ACTION_TYPE_CREATED
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like a switch here with a default to null would read better as well or invert this gate and default to returning null.

Comment on lines 58 to 67
const collaborator = action_by ? action_by[0] : collaborators[collaboratorIDs[0]];

Copy link
Contributor

Choose a reason for hiding this comment

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

is action_by always going to have an element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should, I added some optional chaining to the new code regardless. I also passed in the FF to make it easier to understand the logic.

Comment on lines +69 to 86
test.each`
actionType | actionText
${ACTION_TYPE_RESTORED} | ${'restored v'}
${ACTION_TYPE_TRASHED} | ${'deleted v'}
${ACTION_TYPE_CREATED} | ${'uploaded v'}
`('should correctly render when shouldUseUAA is true with actionType $actionType', ({ actionType, actionText }) => {
renderComponent({
shouldUseUAA: true,
action_type: actionType,
action_by: [{ name: 'John Doe', id: 3 }],
version_start: 2,
version_end: 4,
});

expect(screen.getByText('John Doe')).toBeInTheDocument();
expect(screen.getByText(actionText)).toBeInTheDocument();
expect(screen.getByText('2 - 4')).toBeInTheDocument();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for converting this!

@JChan106 JChan106 requested a review from mickr January 8, 2025 19:01
Comment on lines +8 to +10
jest.mock('react-intl', () => ({
...jest.requireActual('react-intl'),
}));
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 import render and screen from test-utils/testing-library, you won't need to mock this or import IntlProvider separately in this file. there should be some examples in this repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests not passing when I do that for some reason . Given this change is a little time-sensitive, I will leave as is.

Copy link
Contributor

@patlm patlm left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@JChan106 JChan106 removed the request for review from mickr January 10, 2025 00:02
@mergify mergify bot merged commit 0041134 into box:master Jan 10, 2025
6 checks passed
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