-
Notifications
You must be signed in to change notification settings - Fork 665
T1319739 - DataGrid - Columns are misaligned after adding a column at runtime #32283
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
Raushen
wants to merge
6
commits into
DevExpress:26_1
Choose a base branch
from
Raushen:T1319739-26_1
base: 26_1
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.
+164
−1
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
747a64e
T1319739
Raushen 6beeb6f
Add deleteColumn test
Raushen 119b029
Fix test
Raushen d497df9
Merge branch '26_1' of https://github.com/DevExpress/DevExtreme into …
Raushen 25e92ac
remove lines
Raushen b48725e
Merge branch '26_1' of https://github.com/DevExpress/DevExtreme into …
Raushen 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
148 changes: 148 additions & 0 deletions
148
...ernal/grids/grid_core/columns_controller/__tests__/columns_controller.integration.test.ts
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,148 @@ | ||
| import { | ||
| afterEach, beforeEach, describe, expect, it, jest, | ||
| } from '@jest/globals'; | ||
| import type { dxElementWrapper } from '@js/core/renderer'; | ||
| import $ from '@js/core/renderer'; | ||
| import type { Properties as DataGridProperties } from '@js/ui/data_grid'; | ||
| import DataGrid from '@js/ui/data_grid'; | ||
| import errors from '@js/ui/widget/ui.errors'; | ||
|
|
||
| import { DataGridModel } from '../../../data_grid/__tests__/__mock__/model/data_grid'; | ||
|
|
||
| const SELECTORS = { | ||
| gridContainer: '#gridContainer', | ||
| }; | ||
|
|
||
| const GRID_CONTAINER_ID = 'gridContainer'; | ||
|
|
||
| const createDataGrid = async ( | ||
| options: DataGridProperties = {}, | ||
| ): Promise<{ | ||
| $container: dxElementWrapper; | ||
| component: DataGridModel; | ||
| instance: DataGrid; | ||
| }> => new Promise((resolve) => { | ||
| const $container = $('<div>') | ||
| .attr('id', GRID_CONTAINER_ID) | ||
| .appendTo(document.body); | ||
|
|
||
| const dataGridOptions: DataGridProperties = { | ||
| keyExpr: 'id', | ||
| ...options, | ||
| }; | ||
|
|
||
| const instance = new DataGrid($container.get(0) as HTMLDivElement, dataGridOptions); | ||
| const component = new DataGridModel($container.get(0) as HTMLElement); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| resolve({ | ||
| $container, | ||
| component, | ||
| instance, | ||
| }); | ||
| }); | ||
|
|
||
| const beforeTest = (): void => { | ||
| jest.useFakeTimers(); | ||
| jest.spyOn(errors, 'log').mockImplementation(jest.fn()); | ||
| jest.spyOn(errors, 'Error').mockImplementation(() => ({})); | ||
| }; | ||
|
|
||
| const afterTest = (): void => { | ||
| const $container = $(SELECTORS.gridContainer); | ||
| const dataGrid = ($container as any).dxDataGrid('instance') as DataGrid; | ||
|
|
||
| dataGrid.dispose(); | ||
| $container.remove(); | ||
| jest.clearAllMocks(); | ||
| jest.useRealTimers(); | ||
| }; | ||
|
|
||
| describe('Bugs', () => { | ||
| beforeEach(beforeTest); | ||
| afterEach(afterTest); | ||
|
|
||
| describe('T1319739 - DataGrid - Columns are misaligned after adding a column at runtime', () => { | ||
| const data = [ | ||
| { | ||
| id: 1, | ||
| field_1: 'Value 1', | ||
| field_2: 'Value 2', | ||
| }, | ||
| ]; | ||
|
|
||
| it('should add column with data cell if repaintChangesOnly=true', async () => { | ||
| const { instance, component } = await createDataGrid({ | ||
| dataSource: data, | ||
| repaintChangesOnly: true, | ||
| columns: [ | ||
| { | ||
| dataField: 'field_1', | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| let visibleColumns = instance.getVisibleColumns(); | ||
| let headerCellsArray = Array.from(component.getHeaderCells()); | ||
| let dataCellsArray = Array.from(component.getDataCells(0)); | ||
|
|
||
| expect(visibleColumns.length).toBe(1); | ||
| expect(headerCellsArray.length).toBe(1); | ||
| expect(dataCellsArray.length).toBe(1); | ||
|
|
||
| instance.addColumn({ | ||
| dataField: 'field_2', | ||
| }); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| visibleColumns = instance.getVisibleColumns(); | ||
| headerCellsArray = Array.from(component.getHeaderCells()); | ||
| dataCellsArray = Array.from(component.getDataCells(0)); | ||
|
|
||
| expect(visibleColumns.length).toBe(2); | ||
| expect(visibleColumns[0].dataField).toBe('field_1'); | ||
| expect(visibleColumns[1].dataField).toBe('field_2'); | ||
|
|
||
| expect(headerCellsArray.length).toBe(2); | ||
| expect(dataCellsArray.length).toBe(2); | ||
| }); | ||
|
|
||
| it('should remove column with data cell if repaintChangesOnly=true', async () => { | ||
| const { instance, component } = await createDataGrid({ | ||
| dataSource: data, | ||
| repaintChangesOnly: true, | ||
| columns: [ | ||
| { | ||
| dataField: 'field_1', | ||
| }, | ||
| { | ||
| dataField: 'field_2', | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| let visibleColumns = instance.getVisibleColumns(); | ||
| let headerCellsArray = Array.from(component.getHeaderCells()); | ||
| let dataCellsArray = Array.from(component.getDataCells(0)); | ||
|
|
||
| expect(visibleColumns.length).toBe(2); | ||
| expect(headerCellsArray.length).toBe(2); | ||
| expect(dataCellsArray.length).toBe(2); | ||
|
|
||
| instance.deleteColumn('field_2'); | ||
| jest.runAllTimers(); | ||
|
|
||
| visibleColumns = instance.getVisibleColumns(); | ||
| headerCellsArray = Array.from(component.getHeaderCells()); | ||
| dataCellsArray = Array.from(component.getDataCells(0)); | ||
|
|
||
| expect(visibleColumns.length).toBe(1); | ||
| expect(visibleColumns[0].dataField).toBe('field_1'); | ||
|
|
||
| expect(headerCellsArray.length).toBe(1); | ||
| expect(dataCellsArray.length).toBe(1); | ||
| }); | ||
| }); | ||
| }); |
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.
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.
Don't we have an agreement to name private methods with
_?