-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix: custom sounds pagination action buttons when the amount exceeds the specified limit #40113
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
Open
nazabucciarelli
wants to merge
5
commits into
develop
Choose a base branch
from
fix/custom-sounds-pagination
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f94676
fix custom sounds pagination
nazabucciarelli f87d50d
add changeset
nazabucciarelli ed36571
add snapshot testing
nazabucciarelli fcf38ae
decrease amount of mocked sounds to improve efficiency
nazabucciarelli 578abd6
Merge branch 'develop' into fix/custom-sounds-pagination
dougfabris 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes inability to use custom sounds pagination action buttons when the amount exceeds the specified limit |
42 changes: 42 additions & 0 deletions
42
apps/meteor/client/views/admin/customSounds/CustomSoundsTable/CustomSoundsTable.spec.tsx
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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { composeStories } from '@storybook/react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
|
|
||
| import * as stories from './CustomSoundsTable.stories'; | ||
|
|
||
| const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]); | ||
|
|
||
| const mockSounds = Array.from({ length: 25 }, (_, i) => ({ | ||
| _id: `sound-${i}`, | ||
| name: `Custom Sound ${i + 1}`, | ||
| extension: 'mp3', | ||
| })); | ||
|
|
||
| const getMockedAppRoot = () => | ||
| mockAppRoot().withEndpoint('GET', '/v1/custom-sounds.list', () => ({ | ||
| sounds: mockSounds, | ||
| total: 50, | ||
| count: 25, | ||
| offset: 0, | ||
| })); | ||
|
|
||
| test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => { | ||
| const { baseElement } = render(<Story />, { wrapper: getMockedAppRoot().build() }); | ||
| expect(baseElement).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('should enable pagination when data.total exceeds itemsPerPage', async () => { | ||
| const { Default } = composeStories(stories); | ||
| const { container } = render(<Default />, { wrapper: getMockedAppRoot().build() }); | ||
|
|
||
| const firstSound = await screen.findByText('Custom Sound 1'); | ||
| expect(firstSound).toBeInTheDocument(); | ||
|
|
||
| // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access | ||
| const forwardButton = container.querySelector('.rcx-pagination__forward'); | ||
| expect(forwardButton).toBeInTheDocument(); | ||
| expect(forwardButton).not.toBeDisabled(); | ||
|
|
||
| const pageTwoButton = screen.getByRole('button', { name: '2' }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here you should update the button name to |
||
| expect(pageTwoButton).toBeInTheDocument(); | ||
| }); | ||
27 changes: 27 additions & 0 deletions
27
apps/meteor/client/views/admin/customSounds/CustomSoundsTable/CustomSoundsTable.stories.tsx
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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Margins } from '@rocket.chat/fuselage'; | ||
| import { PageContent } from '@rocket.chat/ui-client'; | ||
| import type { Meta, StoryFn } from '@storybook/react'; | ||
| import { useRef } from 'react'; | ||
|
|
||
| import CustomSoundsTable from './CustomSoundsTable'; | ||
|
|
||
| export default { | ||
| component: CustomSoundsTable, | ||
| decorators: [ | ||
| (fn) => ( | ||
| <PageContent mb='neg-x8'> | ||
| <Margins block={8}>{fn()}</Margins> | ||
| </PageContent> | ||
| ), | ||
| ], | ||
| } satisfies Meta<typeof CustomSoundsTable>; | ||
|
|
||
| const Template: StoryFn<typeof CustomSoundsTable> = (args) => { | ||
| const reloadRef = useRef(() => undefined); | ||
| return <CustomSoundsTable {...args} reload={reloadRef} />; | ||
| }; | ||
|
|
||
| export const Default = Template.bind({}); | ||
| Default.args = { | ||
| onClick: (soundId: string) => () => console.log('Clicked sound', soundId), | ||
| }; |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewers: added this comment to suppress the warning of using node access instead of name access, since it's the only way to locate the element currently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the unit tests action failing output, you can find the button by its role
buttonand name"Next page"