-
Notifications
You must be signed in to change notification settings - Fork 347
feat(activity-feed-v2): tag wrapper with resin feature and bump deps #4648
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
Merged
mergify
merged 3 commits into
box:master
from
jackiejou:feat/activity-feed-v2-resin-targets
Jun 24, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 85 additions & 79 deletions
164
src/elements/content-sidebar/__tests__/SidebarFileProperties.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,99 +1,105 @@ | ||
| import set from 'lodash/set'; | ||
| import * as React from 'react'; | ||
| import { shallow, mount } from 'enzyme'; | ||
| import ItemProperties from '../../../features/item-details/ItemProperties'; | ||
| import InlineError from '../../../components/inline-error/InlineError'; | ||
| import { render, screen } from '../../../test-utils/testing-library'; | ||
|
|
||
| import SidebarFileProperties, { SidebarFilePropertiesComponent } from '../SidebarFileProperties'; | ||
| import { PLACEHOLDER_USER } from '../../../constants'; | ||
|
|
||
| describe('elements/content-sidebar/SidebarFileProperties', () => { | ||
| const getWrapper = props => shallow(<SidebarFilePropertiesComponent {...props} />); | ||
| const getMountWrapper = props => mount(<SidebarFilePropertiesComponent {...props} />); | ||
| const props = { | ||
| file: { | ||
| content_created_at: '2018-04-18T16:56:05.352Z', | ||
| content_modified_at: '2018-04-18T16:56:05.352Z', | ||
| description: 'foo', | ||
| owned_by: { | ||
| name: 'foo', | ||
| }, | ||
| created_by: { | ||
| name: 'foo', | ||
| }, | ||
| metadata: { | ||
| global: { | ||
| archivedItemTemplate: { | ||
| archiveDate: '1726832355000', | ||
| }, | ||
| }, | ||
| const baseFile = { | ||
| content_created_at: '2018-04-18T16:56:05.352Z', | ||
| content_modified_at: '2018-04-18T16:56:05.352Z', | ||
| created_by: { name: 'foo' }, | ||
| description: 'foo', | ||
| metadata: { | ||
| global: { | ||
| archivedItemTemplate: { archiveDate: '1726832355000' }, | ||
| }, | ||
| size: '1', | ||
| permissions: { | ||
| can_rename: true, | ||
| }, | ||
| uploader_display_name: 'File Request', | ||
| }, | ||
| onDescriptionChange: jest.fn(), | ||
| intl: { | ||
| locale: 'en', | ||
| }, | ||
| owned_by: { name: 'foo' }, | ||
| permissions: { can_rename: true }, | ||
| size: '1', | ||
| uploader_display_name: 'File Request', | ||
| }; | ||
|
|
||
| const retentionPolicyProps = { | ||
| file: { | ||
| size: '1', | ||
| }, | ||
| hasRetentionPolicy: true, | ||
| onRetentionPolicyExtendClick: jest.fn(), | ||
| retentionPolicy: { | ||
| dispositionTime: 1556317461, | ||
| policyName: 'test policy', | ||
| policyType: 'finite', | ||
| retentionPolicyDescription: 'test policy (1 year retention & auto-deletion', | ||
| }, | ||
| intl: { | ||
| locale: 'en', | ||
| }, | ||
| const baseProps = { | ||
| file: baseFile, | ||
| intl: { locale: 'en' }, | ||
| onDescriptionChange: jest.fn(), | ||
| }; | ||
|
|
||
| describe('render()', () => { | ||
| test('should render ItemProperties', () => { | ||
| const wrapper = getWrapper(props); | ||
| test('should render ItemProperties with file details', () => { | ||
| render(<SidebarFilePropertiesComponent {...baseProps} />); | ||
|
|
||
| expect(wrapper.find(ItemProperties)).toHaveLength(1); | ||
| expect(wrapper).toMatchSnapshot(); | ||
| }); | ||
| expect(screen.getByTestId('item-properties')).toBeVisible(); | ||
| expect(screen.getByText('Owner')).toBeVisible(); | ||
| expect(screen.getByText('Uploader')).toBeVisible(); | ||
| expect(screen.getByText('Created')).toBeVisible(); | ||
| expect(screen.getByText('Modified')).toBeVisible(); | ||
| expect(screen.getByText('Archived')).toBeVisible(); | ||
| expect(screen.getByText('Size')).toBeVisible(); | ||
| expect(screen.getAllByText('foo').length).toBeGreaterThan(0); | ||
| expect(screen.getByText('1 B')).toBeVisible(); | ||
|
|
||
| test('should render ItemProperties for anonymous uploaders', () => { | ||
| const propsHere = set({ ...props }, 'file.created_by.id', PLACEHOLDER_USER.id); | ||
| const wrapper = getWrapper(propsHere); | ||
| const description = screen.getByDisplayValue('foo'); | ||
| expect(description).toHaveAttribute('data-resin-target', 'description'); | ||
| }); | ||
|
|
||
| expect(wrapper.find(ItemProperties)).toHaveLength(1); | ||
| expect(wrapper).toMatchSnapshot(); | ||
| }); | ||
| test('should use uploader_display_name when uploader is anonymous', () => { | ||
| const props = { | ||
| ...baseProps, | ||
| file: { | ||
| ...baseFile, | ||
| created_by: { ...baseFile.created_by, id: PLACEHOLDER_USER.id }, | ||
| }, | ||
| }; | ||
|
|
||
| test('should render an error', () => { | ||
| const fakeError = { | ||
| id: 'foo', | ||
| description: 'bar', | ||
| defaultMessage: 'baz', | ||
| }; | ||
| render(<SidebarFilePropertiesComponent {...props} />); | ||
|
|
||
| expect(screen.getByText('Uploader')).toBeVisible(); | ||
| expect(screen.getByText('File Request')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('should render an inline error along with the wrapped component', () => { | ||
| const fakeError = { | ||
| defaultMessage: 'baz', | ||
| description: 'bar', | ||
| id: 'foo', | ||
| }; | ||
|
|
||
| render( | ||
| <SidebarFileProperties | ||
| file={baseFile} | ||
| inlineError={{ content: fakeError, title: fakeError }} | ||
| onDescriptionChange={jest.fn()} | ||
| />, | ||
| ); | ||
|
|
||
| const errorTitles = screen.getAllByText('baz'); | ||
| expect(errorTitles.length).toBeGreaterThan(0); | ||
| expect(screen.getByTestId('item-properties')).toBeVisible(); | ||
| }); | ||
|
|
||
| const errorProps = { | ||
| inlineError: { | ||
| title: fakeError, | ||
| content: fakeError, | ||
| }, | ||
| }; | ||
| const wrapper = shallow(<SidebarFileProperties {...errorProps} />).dive(); | ||
| test('should render retention policy information when hasRetentionPolicy is set', () => { | ||
| const onRetentionPolicyExtendClick = jest.fn(); | ||
|
|
||
| expect(wrapper.find(InlineError)).toHaveLength(1); | ||
| expect(wrapper).toMatchSnapshot(); | ||
| }); | ||
| render( | ||
| <SidebarFilePropertiesComponent | ||
| file={{ size: '1' }} | ||
| hasRetentionPolicy | ||
| intl={{ locale: 'en' }} | ||
| onRetentionPolicyExtendClick={onRetentionPolicyExtendClick} | ||
| retentionPolicy={{ | ||
| dispositionTime: 1556317461, | ||
| policyName: 'test policy', | ||
| policyType: 'finite', | ||
| retentionPolicyDescription: 'test policy (1 year retention & auto-deletion', | ||
| }} | ||
| />, | ||
| ); | ||
|
|
||
| test('should render retention policy information when given proper props and callback', () => { | ||
| const wrapper = getMountWrapper(retentionPolicyProps); | ||
| expect(wrapper).toMatchSnapshot(); | ||
| }); | ||
| expect(screen.getByText('Policy')).toBeVisible(); | ||
| expect(screen.getByText('test policy (1 year retention & auto-deletion')).toBeVisible(); | ||
| expect(screen.getByText('Policy Expiration')).toBeVisible(); | ||
| expect(screen.getByRole('button', { name: 'Extend' })).toBeVisible(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.