Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 9, 2024
1 parent 471311f commit a3850fa
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('<DataGridPremium /> - Clipboard', () => {
getData: () => pasteText,
};

fireEvent.keyDown(cell, { key: 'v', code: 'KeyV', keyCode: 86, ctrlKey: true }); // Ctrl+V
fireEvent.keyDown(cell, { key: 'v', keyCode: 86, ctrlKey: true }); // Ctrl+V
document.activeElement!.dispatchEvent(pasteEvent);
}

Expand All @@ -196,7 +196,7 @@ describe('<DataGridPremium /> - Clipboard', () => {
apiRef.current.subscribeEvent('cellEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'v', code: 'KeyV', keyCode: 86, [key]: true }); // Ctrl+V
fireEvent.keyDown(cell, { key: 'v', keyCode: 86, [key]: true }); // Ctrl+V
expect(listener.callCount).to.equal(0);
});
});
Expand All @@ -209,7 +209,7 @@ describe('<DataGridPremium /> - Clipboard', () => {
apiRef.current.subscribeEvent('rowEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'v', code: 'KeyV', keyCode: 86, [key]: true }); // Ctrl+V
fireEvent.keyDown(cell, { key: 'v', keyCode: 86, [key]: true }); // Ctrl+V
expect(listener.callCount).to.equal(0);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ describe('<DataGridPro /> - Cell editing', () => {
apiRef.current.subscribeEvent('cellEditStart', listener);
const cell = getCell(0, 0);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'a' }); // A
fireEvent.keyDown(cell, { key: 'a', keyCode: 65 }); // A
expect(listener.callCount).to.equal(0);
});

Expand All @@ -901,7 +901,7 @@ describe('<DataGridPro /> - Cell editing', () => {
apiRef.current.subscribeEvent('cellEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'a', [key]: true }); // for example Ctrl + A, copy
fireEvent.keyDown(cell, { key: 'a', keyCode: 65, [key]: true }); // for example Ctrl + A, copy
expect(listener.callCount).to.equal(0);
});
});
Expand All @@ -912,7 +912,7 @@ describe('<DataGridPro /> - Cell editing', () => {
apiRef.current.subscribeEvent('cellEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'a', shiftKey: true }); // Print A in uppercase
fireEvent.keyDown(cell, { key: 'a', keyCode: 65, shiftKey: true }); // Print A in uppercase
expect(listener.callCount).to.equal(1);
});

Expand All @@ -922,7 +922,7 @@ describe('<DataGridPro /> - Cell editing', () => {
apiRef.current.subscribeEvent('cellEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'v', code: 'KeyV', keyCode: 86, ctrlKey: true }); // Ctrl+V
fireEvent.keyDown(cell, { key: 'v', keyCode: 86, ctrlKey: true }); // Ctrl+V
expect(listener.callCount).to.equal(1);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ describe('<DataGridPro /> - Row editing', () => {
apiRef.current.subscribeEvent('rowEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'a', [key]: true });
fireEvent.keyDown(cell, { key: 'a', keyCode: 65, [key]: true });
expect(listener.callCount).to.equal(0);
});
});
Expand All @@ -885,7 +885,7 @@ describe('<DataGridPro /> - Row editing', () => {
apiRef.current.subscribeEvent('rowEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'a', shiftKey: true });
fireEvent.keyDown(cell, { key: 'a', keyCode: 65, shiftKey: true });
expect(listener.callCount).to.equal(1);
});

Expand All @@ -905,7 +905,7 @@ describe('<DataGridPro /> - Row editing', () => {
apiRef.current.subscribeEvent('rowEditStart', listener);
const cell = getCell(0, 1);
fireUserEvent.mousePress(cell);
fireEvent.keyDown(cell, { key: 'v', code: 'KeyV', keyCode: 86, ctrlKey: true });
fireEvent.keyDown(cell, { key: 'v', keyCode: 86, ctrlKey: true });
expect(listener.callCount).to.equal(1);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ export const useGridRowSelection = (
return;
}

if (event.key === 'a' && (event.ctrlKey || event.metaKey)) {
if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
event.preventDefault();
selectRows(apiRef.current.getAllRowIds(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
// Select all sections
fireEvent.keyDown(view.getActiveSection(0), {
key: 'a',
code: 'KeyQ',
keyCode: 65,
ctrlKey: true,
});
Expand All @@ -45,7 +44,7 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
view.selectSection('month');

// Select all sections
fireEvent.keyDown(input, { key: 'a', code: 'KeyQ', keyCode: 65, ctrlKey: true });
fireEvent.keyDown(input, { key: 'a', keyCode: 65, ctrlKey: true });

fireEvent.keyDown(input, { key: 'Delete' });
expectFieldValueV6(input, 'MMMM YYYY – MMMM YYYY');
Expand All @@ -67,7 +66,6 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
// Select all sections
fireEvent.keyDown(view.getActiveSection(0), {
key: 'a',
code: 'KeyQ',
keyCode: 65,
ctrlKey: true,
});
Expand All @@ -93,7 +91,7 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
expectFieldValueV6(input, 'January YYYY – MMMM YYYY');

// Select all sections
fireEvent.keyDown(input, { key: 'a', code: 'KeyQ', keyCode: 65, ctrlKey: true });
fireEvent.keyDown(input, { key: 'a', keyCode: 65, ctrlKey: true });

fireEvent.keyDown(input, { key: 'Delete' });
expectFieldValueV6(input, 'MMMM YYYY – MMMM YYYY');
Expand All @@ -114,7 +112,6 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
// Select all sections
fireEvent.keyDown(view.getActiveSection(0), {
key: 'a',
code: 'KeyQ',
keyCode: 65,
ctrlKey: true,
});
Expand All @@ -137,7 +134,7 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
view.selectSection('month');

// Select all sections
fireEvent.keyDown(input, { key: 'a', code: 'KeyQ', keyCode: 65, ctrlKey: true });
fireEvent.keyDown(input, { key: 'a', keyCode: 65, ctrlKey: true });

fireEvent.keyDown(input, { key: 'Delete' });
expect(onChangeV6.callCount).to.equal(0);
Expand Down Expand Up @@ -279,7 +276,6 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
// Select all sections
fireEvent.keyDown(view.getActiveSection(0), {
key: 'a',
code: 'KeyQ',
keyCode: 65,
ctrlKey: true,
});
Expand All @@ -300,7 +296,7 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
view.selectSection('month');

// Select all sections
fireEvent.keyDown(input, { key: 'a', code: 'KeyQ', keyCode: 65, ctrlKey: true });
fireEvent.keyDown(input, { key: 'a', keyCode: 65, ctrlKey: true });

fireEvent.change(input, { target: { value: '' } });
expectFieldValueV6(input, 'MMMM YYYY – MMMM YYYY');
Expand All @@ -322,7 +318,6 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
// Select all sections
fireEvent.keyDown(view.getActiveSection(0), {
key: 'a',
code: 'KeyQ',
keyCode: 65,
ctrlKey: true,
});
Expand All @@ -348,7 +343,7 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
expectFieldValueV6(input, 'January YYYY – MMMM YYYY');

// Select all sections
fireEvent.keyDown(input, { key: 'a', code: 'KeyQ', keyCode: 65, ctrlKey: true });
fireEvent.keyDown(input, { key: 'a', keyCode: 65, ctrlKey: true });

fireEvent.change(input, { target: { value: '' } });
expectFieldValueV6(input, 'MMMM YYYY – MMMM YYYY');
Expand All @@ -369,7 +364,6 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
// Select all sections
fireEvent.keyDown(view.getActiveSection(0), {
key: 'a',
code: 'KeyQ',
keyCode: 65,
ctrlKey: true,
});
Expand All @@ -392,7 +386,7 @@ describe('<SingleInputDateRangeField /> - Editing', () => {
view.selectSection('month');

// Select all sections
fireEvent.keyDown(input, { key: 'a', code: 'KeyQ', keyCode: 65, ctrlKey: true });
fireEvent.keyDown(input, { key: 'a', keyCode: 65, ctrlKey: true });

fireEvent.change(input, { target: { value: 'Delete' } });
expect(onChangeV6.callCount).to.equal(0);
Expand Down
Loading

0 comments on commit a3850fa

Please sign in to comment.