Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ const checkCellFocused = async (
}

await t
.expect(editor?.element.exists)
.ok()
.expect(editor?.element.focused)
.eql(true);
};
Expand Down Expand Up @@ -441,6 +443,8 @@ editingModes.forEach((mode) => {
const cell = dataGrid.getDataCell(0, columnInfo.columnIndex);
const editor = form ? new CellEditor(form.getItem(columnInfo.dataField)) : cell.getEditor();

await t.expect(dataGrid.isReady()).ok();

await clickCellEditor(t, mode, columnInfo, form, cell, editor);
await setEditorValue(t, mode, columnInfo, editor);

Expand Down Expand Up @@ -569,33 +573,37 @@ editingModes.forEach((mode) => {
}));

[true, false].forEach((repaintChangesOnly) => {
test.meta({ unstable: mode === 'batch' && !repaintChangesOnly })(
`Update cell value and focus next cell, mode: ${mode}, repaintChangesOnly: ${repaintChangesOnly}, useKeyboard: false`,
async (t) => {
const form = getEditForm(mode);
let modifiedCellCount = mode === 'batch' ? 1 : 0;
for (let i = 0; i < 50; i++) {
test(
`${i}: Update cell value and focus next cell, mode: ${mode}, repaintChangesOnly: ${repaintChangesOnly}, useKeyboard: false`,
async (t) => {
const form = getEditForm(mode);
let modifiedCellCount = mode === 'batch' ? 1 : 0;

for (const columnInfo of textColumnInfos) {
const cell = dataGrid.getDataCell(0, columnInfo.columnIndex);
const editor = form
? new CellEditor(form.getItem(columnInfo.dataField))
: cell.getEditor();
await t.expect(dataGrid.isReady()).ok();

await clickCellEditor(t, mode, columnInfo, form, cell, editor);
await setEditorValue(t, mode, columnInfo, editor);
for (const columnInfo of textColumnInfos) {
const cell = dataGrid.getDataCell(0, columnInfo.columnIndex);
const editor = form
? new CellEditor(form.getItem(columnInfo.dataField))
: cell.getEditor();

await focusNextCellEditor(t, mode, columnInfo);
await clickCellEditor(t, mode, columnInfo, form, cell, editor);
await setEditorValue(t, mode, columnInfo, editor);

if (mode === 'batch') {
modifiedCellCount += 1;
}
await focusNextCellEditor(t, mode, columnInfo);

await checkModifiedCell(t, mode, columnInfo, cell, editor, modifiedCellCount);
}
},
).before(createDataGrid({
mode,
repaintChangesOnly,
}));
if (mode === 'batch') {
modifiedCellCount += 1;
}

await checkModifiedCell(t, mode, columnInfo, cell, editor, modifiedCellCount);
}
},
).before(createDataGrid({
mode,
repaintChangesOnly,
}));
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -360,47 +360,61 @@ test('Async Validation(Row) - Data is not saved when a dependant cell value beco
}, 'lastName'],
})));

test('Async Validation(Cell) - Only the last cell should be switched to edit mode', async (t) => {
const dataGrid = new DataGrid('#container');
await t.expect(dataGrid.isReady()).ok();
for (let i = 0; i < 50; i++) {
test(`${i}: ` + 'Async Validation(Cell) - Only the last cell should be switched to edit mode', async (t) => {
const dataGrid = new DataGrid('#container');
const resolveValidation = ClientFunction(() => (window as any).deferred.resolve(true));

const cell0 = dataGrid.getDataCell(0, 0);
const cell1 = dataGrid.getDataCell(0, 1);
const cell2 = dataGrid.getDataCell(0, 2);
await t.expect(dataGrid.isReady()).ok();

await t
.click(cell0.element)
.expect(cell0.isValidationPending).ok()
.click(cell1.element)
.expect(cell1.isFocused)
.notOk('the second cell should not be focused')
.click(cell2.element)
.expect(cell0.isValidationPending)
.notOk('validating is completed')
.expect(cell2.hasHiddenFocusState)
.notOk()
.expect(cell2.isFocused)
.ok('the third cell should be focused');
}).before(async () => createWidget('dxDataGrid', getGridConfig({
editing: {
mode: 'cell',
allowUpdating: true,
allowAdding: true,
},
columns: [{
dataField: 'age',
validationRules: [{
type: 'async',
validationCallback(): JQueryPromise<unknown> {
const d = $.Deferred();
setTimeout(() => {
d.resolve(true);
}, 1000);
return d.promise();
const cell0 = dataGrid.getDataCell(0, 0);
const cell1 = dataGrid.getDataCell(0, 1);
const cell2 = dataGrid.getDataCell(0, 2);

await t
.click(cell0.element)
.expect(cell0.isValidationPending).ok()
.click(cell1.element)
.expect(cell1.isFocused)
.notOk('the second cell should not be focused')
.click(cell2.element);

await resolveValidation();

await t
.expect(cell0.isValidationPending)
.notOk('validating is completed')
.expect(cell2.hasHiddenFocusState)
.notOk()
.expect(cell2.isFocused)
.ok('the third cell should be focused');
}).before(async () => {
await ClientFunction(() => {
(window as any).deferred = $.Deferred();
})();

return createWidget('dxDataGrid', getGridConfig({
editing: {
mode: 'cell',
allowUpdating: true,
allowAdding: true,
},
}],
}, 'name', 'lastName'],
})));
columns: [{
dataField: 'age',
validationRules: [{
type: 'async',
validationCallback(): JQueryPromise<unknown> {
return (window as any).deferred.promise();
},
}],
}, 'name', 'lastName'],
}));
}).after(async () => {
await ClientFunction(() => {
delete (window as any).deferred;
})();
});
}

test('Async Validation(Cell) - Only valid data is saved in a new row', async (t) => {
const dataGrid = new DataGrid('#container');
Expand Down
Loading
Loading