-
Notifications
You must be signed in to change notification settings - Fork 665
T1308327 - DataGrid - Cell value is not restored after canceling changes in cell editing mode if repaintChangesOnly is enabled #32290
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
2
commits into
DevExpress:26_1
Choose a base branch
from
Raushen:T1308327-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.
+141
−1
Open
Changes from all commits
Commits
Show all changes
2 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
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
123 changes: 123 additions & 0 deletions
123
...extreme/js/__internal/grids/grid_core/validating/__tests__/validating.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,123 @@ | ||
| 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 '@ts/grids/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('T1308327 - DataGrid - Cell value is not restored after canceling changes in cell editing mode if repaintChangesOnly is enabled', () => { | ||
| it('should restore cell value after canceling changes with validation error', async () => { | ||
| const data = [ | ||
| { id: 1, name: 'Job 1', article: 'Article A' }, | ||
| { id: 2, name: 'Job 2', article: 'Article B' }, | ||
| ]; | ||
|
|
||
| const { instance, component } = await createDataGrid({ | ||
| dataSource: data, | ||
| keyExpr: 'id', | ||
| repaintChangesOnly: true, | ||
| editing: { | ||
| mode: 'cell', | ||
| allowUpdating: true, | ||
| }, | ||
| columns: [ | ||
| { | ||
| dataField: 'name', | ||
| showEditorAlways: true, | ||
| validationRules: [ | ||
| { type: 'required', message: 'Required field' }, | ||
| ], | ||
| }, | ||
| { | ||
| dataField: 'article', | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const firstCell = component.getDataCell(0, 0); | ||
| const firstEditor = firstCell.getEditor(); | ||
|
|
||
| firstEditor.setValue(''); | ||
| jest.runAllTimers(); | ||
|
|
||
| expect(component.getDataCell(0, 0).isValidCell).toBe(false); | ||
|
|
||
| component.getRevertButton().click(); | ||
| jest.runAllTimers(); | ||
|
|
||
| expect(instance.cellValue(0, 'name')).toBe('Job 1'); | ||
| expect(component.getDataCell(0, 0).isValidCell).toBe(true); | ||
|
|
||
| const secondCell = component.getDataCell(1, 0); | ||
| const secondEditor = secondCell.getEditor(); | ||
|
|
||
| secondEditor.setValue(''); | ||
| jest.runAllTimers(); | ||
|
|
||
| expect(component.getDataCell(1, 0).isValidCell).toBe(false); | ||
|
|
||
| component.getRevertButton().click(); | ||
| jest.runAllTimers(); | ||
|
|
||
| expect(instance.cellValue(1, 'name')).toBe('Job 2'); | ||
| expect(component.getDataCell(1, 0).isValidCell).toBe(true); | ||
| }); | ||
| }); | ||
| }); | ||
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.