-
Notifications
You must be signed in to change notification settings - Fork 41
Migrate Rank.Threshold to User Preferences
#6844
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
Draft
grantfitzsimmons
wants to merge
38
commits into
main
Choose a base branch
from
issue-6843
base: main
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.
+269
−120
Draft
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
5dea652
Add renderer for taxon tree def items
grantfitzsimmons 444b04f
Add threshold rank preference
grantfitzsimmons 3c25958
Update preferences.ts
grantfitzsimmons c6e17cc
Merge branch 'issue-6841' into issue-6843
grantfitzsimmons cc2fbe6
Update Renderers.tsx
grantfitzsimmons 4bb52d5
Merge branch 'issue-6843' of https://github.com/specify/specify7 into…
grantfitzsimmons 2ae8497
Update remotePrefs.test.ts.snap
grantfitzsimmons 8806806
Update renderer to be generic across tree tables
grantfitzsimmons c760d44
Use user preference instead of remotePref
grantfitzsimmons 25217bf
Remove unused imports
grantfitzsimmons 30c35c6
Update Renderers.tsx
grantfitzsimmons e80d3b7
Lint code with ESLint and Prettier
grantfitzsimmons 68a187d
Correct description
grantfitzsimmons 95c7c50
Merge branch 'issue-6843' of https://github.com/specify/specify7 into…
grantfitzsimmons d18394c
Lint code with ESLint and Prettier
grantfitzsimmons 539027d
Remove unused function
grantfitzsimmons 430e743
Update specifyweb/frontend/js_src/lib/components/Preferences/Renderer…
grantfitzsimmons e7c7afe
Remove 'none' option
grantfitzsimmons fa71563
Update preferences.ts
grantfitzsimmons bbd714b
Revert "Remove 'none' option"
grantfitzsimmons f7357dd
Merge branch 'issue-6843' of https://github.com/specify/specify7 into…
grantfitzsimmons 098d361
Update preferences.ts
grantfitzsimmons 74ff3cb
Merge branch 'issue-6841' into issue-6843
grantfitzsimmons 48314b3
Use RA<>
grantfitzsimmons 86a8e33
Order ranks
grantfitzsimmons 4f08ce2
Lint code with ESLint and Prettier
grantfitzsimmons 77bf41a
Merge branch 'main' into issue-6843
grantfitzsimmons 5d91e20
Merge branch 'main' into issue-6843
melton-jason 7a2eff4
Lint code with ESLint and Prettier
melton-jason d7632f6
Merge branch 'main' into issue-6843
grantfitzsimmons c81eafc
Lint code with ESLint and Prettier
grantfitzsimmons 6dcc0f9
Restrict tree rank preference options to the active definition
Gitesh307 a995792
installed ts-node devDependancy
Gitesh307 b239180
installed required dependancy
Gitesh307 9e574a6
Filter tree rank preference options
Gitesh307 f79c6c0
Lint code with ESLint and Prettier
Gitesh307 e908ed4
Merge branch 'main' into issue-6843
Gitesh307 f454e18
Lint code with ESLint and Prettier
Gitesh307 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
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
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
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
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
64 changes: 64 additions & 0 deletions
64
specifyweb/frontend/js_src/lib/components/Preferences/__tests__/ThresholdRank.test.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,64 @@ | ||
| import { render, screen, waitFor } from '@testing-library/react'; | ||
| import React from 'react'; | ||
|
|
||
| import { preferencesText } from '../../../localization/preferences'; | ||
| import { overrideAjax } from '../../../tests/ajax'; | ||
| import { requireContext } from '../../../tests/helpers'; | ||
| import * as treeRanks from '../../InitialContext/treeRanks'; | ||
| import { ThresholdRank } from '../Renderers'; | ||
| import type { PreferenceItem } from '../types'; | ||
|
|
||
| overrideAjax('/context/schema_localization.json', {}); | ||
| requireContext(); | ||
|
|
||
| const mockedGetTreeDefinitions = jest.spyOn( | ||
| treeRanks, | ||
| 'getTreeDefinitions' | ||
| ); | ||
|
|
||
| describe('ThresholdRank', () => { | ||
| beforeEach(() => { | ||
| mockedGetTreeDefinitions.mockReset(); | ||
| }); | ||
|
|
||
| test('only renders ranks from the active tree definition', async () => { | ||
| mockedGetTreeDefinitions.mockReturnValue([ | ||
| { | ||
| definition: { id: 1 } as any, | ||
| ranks: [ | ||
| { rankId: 50, name: 'Active Rank B' }, | ||
| { rankId: 10, name: 'Active Rank A' }, | ||
| ] as any, | ||
| }, | ||
| { | ||
| definition: { id: 2 } as any, | ||
| ranks: [{ rankId: 5, name: 'Inactive Rank' }] as any, | ||
| }, | ||
| ]); | ||
|
|
||
| const definition: PreferenceItem<number> = { | ||
| title: preferencesText.rankThreshold(), | ||
| requiresReload: false, | ||
| visible: true, | ||
| defaultValue: 0, | ||
| values: [], | ||
| }; | ||
| render( | ||
| <ThresholdRank | ||
| category="tree" | ||
| definition={definition} | ||
| item="rankThreshold" | ||
| subcategory="geography" | ||
| tableName="Geography" | ||
| value={50} | ||
| onChange={jest.fn()} | ||
| /> | ||
| ); | ||
|
|
||
| await waitFor(() => expect(screen.getAllByRole('option')).toHaveLength(3)); | ||
|
|
||
| const labels = screen.getAllByRole('option').map((option) => option.textContent); | ||
| expect(labels).toEqual(['None', 'Active Rank A', 'Active Rank B']); | ||
| expect(screen.queryByText('Inactive Rank')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
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.
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.