-
Notifications
You must be signed in to change notification settings - Fork 903
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI #708
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
71dc3e3
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 f6bc68d
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 d46faa3
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 09353f7
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 550cf15
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 1e46c33
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 27a858d
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 2547d86
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 7e97064
ATLAS-5350: Atlas UI: Enhance Purge Audit Results UI
Brijesh619 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,89 @@ | ||
| /* | ||
|
Brijesh619 marked this conversation as resolved.
|
||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { renderHook } from '@testing-library/react'; | ||
| import { useVirtualization } from '../useVirtualization'; | ||
|
|
||
| describe('useVirtualization', () => { | ||
| it('should return empty values when items array is empty', () => { | ||
| const { result } = renderHook(() => | ||
| useVirtualization({ items: [], scrollTop: 0 }) | ||
| ); | ||
|
|
||
| expect(result.current).toEqual({ | ||
| visibleItems: [], | ||
| paddingTop: 0, | ||
| paddingBottom: 0, | ||
| startIndex: 0, | ||
| }); | ||
| }); | ||
|
|
||
| it('should calculate visible items and padding correctly for initial state', () => { | ||
| const items = Array.from({ length: 100 }, (_, i) => i); | ||
| const { result } = renderHook(() => | ||
| useVirtualization({ items, scrollTop: 0, itemHeight: 37, overscan: 10, visibleCount: 40 }) | ||
| ); | ||
|
|
||
| // Initial state (scrollTop = 0) | ||
| // startIndex = max(0, 0 - 10) = 0 | ||
| // endIndex = min(99, 0 + 40 + 10) = 50 | ||
| // visibleItems = items.slice(0, 51) | ||
|
|
||
| expect(result.current.startIndex).toBe(0); | ||
| expect(result.current.visibleItems.length).toBe(51); | ||
| expect(result.current.paddingTop).toBe(0); | ||
|
|
||
| // paddingBottom = (100 - 1 - 50) * 37 = 49 * 37 = 1813 | ||
| expect(result.current.paddingBottom).toBe(1813); | ||
| }); | ||
|
|
||
| it('should calculate visible items correctly when scrolled down', () => { | ||
| const items = Array.from({ length: 100 }, (_, i) => i); | ||
| // Scrolled 20 items down: 20 * 37 = 740 | ||
| const { result } = renderHook(() => | ||
| useVirtualization({ items, scrollTop: 740, itemHeight: 37, overscan: 10, visibleCount: 40 }) | ||
| ); | ||
|
|
||
| // startIndex = max(0, 20 - 10) = 10 | ||
| // endIndex = min(99, 20 + 40 + 10) = 70 | ||
|
|
||
| expect(result.current.startIndex).toBe(10); | ||
| expect(result.current.visibleItems.length).toBe(61); // 70 - 10 + 1 | ||
|
|
||
| // paddingTop = 10 * 37 = 370 | ||
| expect(result.current.paddingTop).toBe(370); | ||
|
|
||
| // paddingBottom = (100 - 1 - 70) * 37 = 29 * 37 = 1073 | ||
| expect(result.current.paddingBottom).toBe(1073); | ||
| }); | ||
|
|
||
| it('should cap end index at total items length', () => { | ||
| const items = Array.from({ length: 50 }, (_, i) => i); | ||
| // Scrolled way past the bottom | ||
| const { result } = renderHook(() => | ||
| useVirtualization({ items, scrollTop: 5000, itemHeight: 37, overscan: 10, visibleCount: 40 }) | ||
| ); | ||
|
|
||
| // startIndex = max(0, 135 - 10) = 125 | ||
| // endIndex = min(49, 135 + 40 + 10) = 49 | ||
| // Wait, if startIndex > endIndex, slice will return empty array | ||
|
|
||
| expect(result.current.startIndex).toBe(125); | ||
| expect(result.current.visibleItems.length).toBe(0); | ||
| expect(result.current.paddingBottom).toBe(0); | ||
| }); | ||
| }); | ||
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,33 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { useMemo } from 'react'; | ||
| import { virtualizeList } from '../utils/Utils'; | ||
|
|
||
| interface UseVirtualizationProps<T> { | ||
| items: T[]; | ||
| scrollTop: number; | ||
| itemHeight?: number; | ||
| overscan?: number; | ||
| visibleCount?: number; | ||
| } | ||
|
|
||
| export const useVirtualization = <T>(options: UseVirtualizationProps<T>) => { | ||
| return useMemo(() => { | ||
| return virtualizeList(options); | ||
| }, [options.items, options.scrollTop, options.itemHeight, options.overscan, options.visibleCount]); | ||
| }; |
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
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.