Skip to content

Commit d7ac70d

Browse files
authored
1 parent bd139ed commit d7ac70d

28 files changed

+560
-664
lines changed

eslint.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,6 @@ export default defineConfig([
573573
name: 'react-dom',
574574
importNames: ['default'],
575575
message: 'Use named imports instead.'
576-
},
577-
{
578-
name: '@testing-library/dom',
579-
message: 'Import @testing-library/react instead.'
580576
}
581577
],
582578
'@typescript-eslint/no-shadow': 0,
@@ -702,7 +698,7 @@ export default defineConfig([
702698
'testing-library/prefer-explicit-assert': 1,
703699
'testing-library/prefer-find-by': 1,
704700
'testing-library/prefer-implicit-assert': 0,
705-
'testing-library/prefer-presence-queries': 1,
701+
'testing-library/prefer-presence-queries': 0,
706702
'testing-library/prefer-query-by-disappearance': 1,
707703
'testing-library/prefer-query-matchers': 0,
708704
'testing-library/prefer-screen-queries': 0,

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262
"@microsoft/api-extractor": "^7.50.0",
6363
"@tanstack/react-router": "^1.114.16",
6464
"@tanstack/router-plugin": "^1.114.16",
65-
"@testing-library/dom": "^10.1.0",
66-
"@testing-library/react": "^16.2.0",
67-
"@testing-library/user-event": "^14.5.2",
6865
"@types/node": "^22.13.1",
6966
"@types/react": "^19.0.8",
7067
"@types/react-dom": "^19.0.3",

test/browser/TreeDataGrid.test.tsx

Lines changed: 97 additions & 98 deletions
Large diffs are not rendered by default.

test/browser/column/cellClass.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface Row {
88

99
const rows: readonly Row[] = [{ id: 0 }, { id: 1 }];
1010

11-
test('cellClass is undefined', async () => {
11+
test('cellClass is undefined', () => {
1212
const columns: readonly Column<Row>[] = [
1313
{
1414
key: 'id',
@@ -17,11 +17,11 @@ test('cellClass is undefined', async () => {
1717
];
1818
setup({ columns, rows });
1919
const [cell1, cell2] = getCells();
20-
await expect.element(cell1).toHaveClass(cellClassname, { exact: true });
21-
await expect.element(cell2).toHaveClass(cellClassname, { exact: true });
20+
expect(cell1).toHaveClass(cellClassname, { exact: true });
21+
expect(cell2).toHaveClass(cellClassname, { exact: true });
2222
});
2323

24-
test('cellClass is a string', async () => {
24+
test('cellClass is a string', () => {
2525
const columns: readonly Column<Row>[] = [
2626
{
2727
key: 'id',
@@ -31,11 +31,11 @@ test('cellClass is a string', async () => {
3131
];
3232
setup({ columns, rows });
3333
const [cell1, cell2] = getCells();
34-
await expect.element(cell1).toHaveClass(`${cellClassname} my-cell`, { exact: true });
35-
await expect.element(cell2).toHaveClass(`${cellClassname} my-cell`, { exact: true });
34+
expect(cell1).toHaveClass(`${cellClassname} my-cell`, { exact: true });
35+
expect(cell2).toHaveClass(`${cellClassname} my-cell`, { exact: true });
3636
});
3737

38-
test('cellClass returns a string', async () => {
38+
test('cellClass returns a string', () => {
3939
const columns: readonly Column<Row>[] = [
4040
{
4141
key: 'id',
@@ -45,11 +45,11 @@ test('cellClass returns a string', async () => {
4545
];
4646
setup({ columns, rows });
4747
const [cell1, cell2] = getCells();
48-
await expect.element(cell1).toHaveClass(`${cellClassname} my-cell-0`, { exact: true });
49-
await expect.element(cell2).toHaveClass(`${cellClassname} my-cell-1`, { exact: true });
48+
expect(cell1).toHaveClass(`${cellClassname} my-cell-0`, { exact: true });
49+
expect(cell2).toHaveClass(`${cellClassname} my-cell-1`, { exact: true });
5050
});
5151

52-
test('cellClass returns undefined', async () => {
52+
test('cellClass returns undefined', () => {
5353
const columns: readonly Column<Row>[] = [
5454
{
5555
key: 'id',
@@ -59,6 +59,6 @@ test('cellClass returns undefined', async () => {
5959
];
6060
setup({ columns, rows });
6161
const [cell1, cell2] = getCells();
62-
await expect.element(cell1).toHaveClass(cellClassname, { exact: true });
63-
await expect.element(cell2).toHaveClass(cellClassname, { exact: true });
62+
expect(cell1).toHaveClass(cellClassname, { exact: true });
63+
expect(cell2).toHaveClass(cellClassname, { exact: true });
6464
});

test/browser/column/colSpan.test.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { userEvent } from '@vitest/browser/context';
22

33
import type { Column } from '../../../src';
4-
import { getCellsAtRowIndexOld, getHeaderCells, setup, validateCellPositionOld } from '../utils';
4+
import { getCellsAtRowIndex, getHeaderCells, setup, validateCellPosition } from '../utils';
55

66
describe('colSpan', () => {
77
function setupColSpanGrid(colCount = 15) {
@@ -43,7 +43,7 @@ describe('colSpan', () => {
4343
expect(getHeaderCells()).toHaveLength(13);
4444

4545
// top summary rows
46-
const topSummarryRow1 = getCellsAtRowIndexOld(0);
46+
const topSummarryRow1 = getCellsAtRowIndex(0);
4747
expect(topSummarryRow1).toHaveLength(14);
4848
// 7th-8th cells are merged
4949
expect(topSummarryRow1[7]).toHaveAttribute('aria-colindex', '8');
@@ -52,10 +52,10 @@ describe('colSpan', () => {
5252
'grid-column-start': '8',
5353
'grid-column-end': '10'
5454
});
55-
expect(getCellsAtRowIndexOld(1)).toHaveLength(15);
55+
expect(getCellsAtRowIndex(1)).toHaveLength(15);
5656

5757
// rows
58-
const row1 = getCellsAtRowIndexOld(3);
58+
const row1 = getCellsAtRowIndex(3);
5959
expect(row1).toHaveLength(14);
6060
// 7th-8th cells are merged
6161
expect(row1[6]).toHaveAttribute('aria-colindex', '7');
@@ -68,7 +68,7 @@ describe('colSpan', () => {
6868
expect(row1[7]).not.toHaveAttribute('aria-colspan');
6969

7070
// 3rd-5th, 7th-8th cells are merged
71-
const row2 = getCellsAtRowIndexOld(4);
71+
const row2 = getCellsAtRowIndex(4);
7272
expect(row2).toHaveLength(12);
7373
expect(row2[2]).toHaveAttribute('aria-colindex', '3');
7474
expect(row2[2]).toHaveStyle({
@@ -84,95 +84,95 @@ describe('colSpan', () => {
8484
});
8585
expect(row2[5]).toHaveAttribute('aria-colindex', '9');
8686

87-
expect(getCellsAtRowIndexOld(6)).toHaveLength(14); // colSpan 6 won't work as there are 5 frozen columns
88-
expect(getCellsAtRowIndexOld(7)).toHaveLength(10);
87+
expect(getCellsAtRowIndex(6)).toHaveLength(14); // colSpan 6 won't work as there are 5 frozen columns
88+
expect(getCellsAtRowIndex(7)).toHaveLength(10);
8989

9090
// bottom summary row
91-
expect(getCellsAtRowIndexOld(12)).toHaveLength(14);
92-
expect(getCellsAtRowIndexOld(13)).toHaveLength(15);
91+
expect(getCellsAtRowIndex(12)).toHaveLength(14);
92+
expect(getCellsAtRowIndex(13)).toHaveLength(15);
9393
});
9494

9595
it('should navigate between merged cells', async () => {
9696
setupColSpanGrid();
9797
// header row
9898
await userEvent.click(getHeaderCells()[7]);
99-
validateCellPositionOld(7, 0);
99+
validateCellPosition(7, 0);
100100
await userEvent.keyboard('{arrowright}');
101-
validateCellPositionOld(8, 0);
101+
validateCellPosition(8, 0);
102102
await userEvent.keyboard('{arrowright}');
103-
validateCellPositionOld(11, 0);
103+
validateCellPosition(11, 0);
104104
await userEvent.keyboard('{arrowright}');
105-
validateCellPositionOld(12, 0);
105+
validateCellPosition(12, 0);
106106
await userEvent.keyboard('{arrowleft}{arrowleft}{arrowleft}');
107-
validateCellPositionOld(7, 0);
107+
validateCellPosition(7, 0);
108108

109109
// top summary rows
110-
await userEvent.click(getCellsAtRowIndexOld(0)[6]);
111-
validateCellPositionOld(6, 1);
110+
await userEvent.click(getCellsAtRowIndex(0)[6]);
111+
validateCellPosition(6, 1);
112112
await userEvent.keyboard('{arrowright}');
113-
validateCellPositionOld(7, 1);
113+
validateCellPosition(7, 1);
114114
await userEvent.keyboard('{arrowright}');
115-
validateCellPositionOld(9, 1);
115+
validateCellPosition(9, 1);
116116
await userEvent.keyboard('{arrowright}');
117-
validateCellPositionOld(10, 1);
117+
validateCellPosition(10, 1);
118118
await userEvent.keyboard('{arrowleft}{arrowleft}{arrowleft}');
119-
validateCellPositionOld(6, 1);
119+
validateCellPosition(6, 1);
120120

121121
// viewport rows
122-
await userEvent.click(getCellsAtRowIndexOld(3)[1]);
123-
validateCellPositionOld(1, 4);
122+
await userEvent.click(getCellsAtRowIndex(3)[1]);
123+
validateCellPosition(1, 4);
124124
await userEvent.keyboard('{arrowright}');
125-
validateCellPositionOld(2, 4);
125+
validateCellPosition(2, 4);
126126
await userEvent.keyboard('{arrowright}');
127-
validateCellPositionOld(3, 4);
127+
validateCellPosition(3, 4);
128128
await userEvent.keyboard('{arrowdown}');
129-
validateCellPositionOld(2, 5);
129+
validateCellPosition(2, 5);
130130
await userEvent.keyboard('{arrowleft}');
131-
validateCellPositionOld(1, 5);
131+
validateCellPosition(1, 5);
132132
await userEvent.keyboard('{arrowright}');
133-
validateCellPositionOld(2, 5);
133+
validateCellPosition(2, 5);
134134
await userEvent.keyboard('{arrowright}');
135-
validateCellPositionOld(5, 5);
135+
validateCellPosition(5, 5);
136136
await userEvent.keyboard('{arrowleft}');
137-
validateCellPositionOld(2, 5);
137+
validateCellPosition(2, 5);
138138
await userEvent.keyboard('{arrowdown}');
139-
validateCellPositionOld(2, 6);
139+
validateCellPosition(2, 6);
140140
await userEvent.keyboard('{arrowdown}{arrowdown}');
141-
validateCellPositionOld(0, 8);
141+
validateCellPosition(0, 8);
142142
await userEvent.keyboard('{arrowLeft}');
143-
validateCellPositionOld(0, 8);
143+
validateCellPosition(0, 8);
144144
await userEvent.keyboard('{arrowright}');
145-
validateCellPositionOld(5, 8);
145+
validateCellPosition(5, 8);
146146
await userEvent.tab({ shift: true });
147147
await userEvent.tab({ shift: true });
148-
validateCellPositionOld(14, 7);
148+
validateCellPosition(14, 7);
149149
await userEvent.tab();
150-
validateCellPositionOld(0, 8);
151-
await userEvent.click(getCellsAtRowIndexOld(10)[11]);
152-
validateCellPositionOld(11, 11);
150+
validateCellPosition(0, 8);
151+
await userEvent.click(getCellsAtRowIndex(10)[11]);
152+
validateCellPosition(11, 11);
153153
await userEvent.tab();
154-
validateCellPositionOld(12, 11);
154+
validateCellPosition(12, 11);
155155
await userEvent.tab();
156-
validateCellPositionOld(0, 12);
156+
validateCellPosition(0, 12);
157157
await userEvent.tab({ shift: true });
158-
validateCellPositionOld(12, 11);
158+
validateCellPosition(12, 11);
159159

160160
// bottom summary rows
161-
await userEvent.click(getCellsAtRowIndexOld(12)[6]);
162-
validateCellPositionOld(6, 13);
161+
await userEvent.click(getCellsAtRowIndex(12)[6]);
162+
validateCellPosition(6, 13);
163163
await userEvent.keyboard('{arrowright}');
164-
validateCellPositionOld(7, 13);
164+
validateCellPosition(7, 13);
165165
await userEvent.keyboard('{arrowright}');
166-
validateCellPositionOld(9, 13);
166+
validateCellPosition(9, 13);
167167
await userEvent.keyboard('{arrowright}');
168-
validateCellPositionOld(10, 13);
168+
validateCellPosition(10, 13);
169169
await userEvent.keyboard('{arrowleft}{arrowleft}{arrowleft}');
170-
validateCellPositionOld(6, 13);
170+
validateCellPosition(6, 13);
171171
});
172172

173173
it('should scroll to the merged cell when selected', async () => {
174174
setupColSpanGrid(30);
175-
await userEvent.click(getCellsAtRowIndexOld(10)[23]); // last visible cell (1920/80)
175+
await userEvent.click(getCellsAtRowIndex(10)[23]); // last visible cell (1920/80)
176176
const spy = vi.spyOn(window.HTMLElement.prototype, 'scrollIntoView');
177177
const testScrollIntoView = () => {
178178
expect(spy).toHaveBeenCalled();
@@ -182,13 +182,13 @@ describe('colSpan', () => {
182182
testScrollIntoView();
183183
await navigate(1);
184184
testScrollIntoView(); // should bring the merged cell into view
185-
validateCellPositionOld(27, 11);
185+
validateCellPosition(27, 11);
186186
await navigate(7);
187187
testScrollIntoView();
188-
validateCellPositionOld(6, 12); // should navigate to the next row
188+
validateCellPosition(6, 12); // should navigate to the next row
189189
await navigate(7, true);
190190
testScrollIntoView();
191-
validateCellPositionOld(27, 11); // should navigate to the previous row
191+
validateCellPosition(27, 11); // should navigate to the previous row
192192
await navigate(27);
193193
testScrollIntoView();
194194
await navigate(1);

test/browser/column/draggable.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ test('draggable columns', async () => {
3030
setup({ columns, rows: [], onColumnsReorder });
3131
const [cell1, cell2, cell3, cell4] = getHeaderCells();
3232

33-
await expect.element(cell1).not.toHaveAttribute('draggable');
34-
await expect.element(cell2).toHaveAttribute('draggable');
35-
await expect.element(cell3).toHaveAttribute('draggable');
36-
await expect.element(cell4).toHaveAttribute('draggable');
33+
expect(cell1).not.toHaveAttribute('draggable');
34+
expect(cell2).toHaveAttribute('draggable');
35+
expect(cell3).toHaveAttribute('draggable');
36+
expect(cell4).toHaveAttribute('draggable');
3737

3838
expect(onColumnsReorder).not.toHaveBeenCalled();
3939

test/browser/column/frozen.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Column } from '../../../src';
22
import { cellClassname, cellFrozenClassname } from '../../../src/style/cell';
33
import { getHeaderCells, setup } from '../utils';
44

5-
test('frozen column have a specific class, and are stable-sorted before non-frozen columns', async () => {
5+
test('frozen column have a specific class, and are stable-sorted before non-frozen columns', () => {
66
const columns: readonly Column<never>[] = [
77
{
88
key: 'col1',
@@ -28,17 +28,13 @@ test('frozen column have a specific class, and are stable-sorted before non-froz
2828
setup({ columns, rows: [] });
2929
const [cell1, cell2, cell3, cell4] = getHeaderCells();
3030

31-
await expect
32-
.element(cell1)
33-
.toHaveClass(`${cellClassname} ${cellFrozenClassname}`, { exact: true });
34-
await expect
35-
.element(cell2)
36-
.toHaveClass(`${cellClassname} ${cellFrozenClassname}`, { exact: true });
37-
await expect.element(cell3).toHaveClass(cellClassname, { exact: true });
38-
await expect.element(cell4).toHaveClass(cellClassname, { exact: true });
31+
expect(cell1).toHaveClass(`${cellClassname} ${cellFrozenClassname}`, { exact: true });
32+
expect(cell2).toHaveClass(`${cellClassname} ${cellFrozenClassname}`, { exact: true });
33+
expect(cell3).toHaveClass(cellClassname, { exact: true });
34+
expect(cell4).toHaveClass(cellClassname, { exact: true });
3935

40-
await expect.element(cell1).toHaveTextContent('col1');
41-
await expect.element(cell2).toHaveTextContent('col3');
42-
await expect.element(cell3).toHaveTextContent('col2');
43-
await expect.element(cell4).toHaveTextContent('col4');
36+
expect(cell1).toHaveTextContent('col1');
37+
expect(cell2).toHaveTextContent('col3');
38+
expect(cell3).toHaveTextContent('col2');
39+
expect(cell4).toHaveTextContent('col4');
4440
});

test/browser/column/headerCellClass.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Column, ColumnGroup } from '../../../src';
22
import { cellClassname } from '../../../src/style/cell';
33
import { getHeaderCells, setup } from '../utils';
44

5-
test('headerCellClass is either nullish or a string', async () => {
5+
test('headerCellClass is either nullish or a string', () => {
66
const columns: readonly Column<never>[] = [
77
{
88
key: 'id',
@@ -17,11 +17,11 @@ test('headerCellClass is either nullish or a string', async () => {
1717

1818
setup({ columns, rows: [] });
1919
const [cell1, cell2] = getHeaderCells();
20-
await expect.element(cell1).toHaveClass(cellClassname, { exact: true });
21-
await expect.element(cell2).toHaveClass(`${cellClassname} my-header`, { exact: true });
20+
expect(cell1).toHaveClass(cellClassname, { exact: true });
21+
expect(cell2).toHaveClass(`${cellClassname} my-header`, { exact: true });
2222
});
2323

24-
test('columnGroup.headerCellClass is either nullish or a string', async () => {
24+
test('columnGroup.headerCellClass is either nullish or a string', () => {
2525
const columns: readonly ColumnGroup<never>[] = [
2626
{
2727
name: 'Group 1',
@@ -36,6 +36,6 @@ test('columnGroup.headerCellClass is either nullish or a string', async () => {
3636

3737
setup({ columns, rows: [] });
3838
const [cell1, cell2] = getHeaderCells();
39-
await expect.element(cell1).toHaveClass(cellClassname, { exact: true });
40-
await expect.element(cell2).toHaveClass(`${cellClassname} my-header`, { exact: true });
39+
expect(cell1).toHaveClass(cellClassname, { exact: true });
40+
expect(cell2).toHaveClass(`${cellClassname} my-header`, { exact: true });
4141
});

test/browser/column/name.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Column } from '../../../src';
22
import { getHeaderCells, setup } from '../utils';
33

4-
test('name is either a string or an element', async () => {
4+
test('name is either a string or an element', () => {
55
function Header() {
66
return 'Fancy';
77
}
@@ -19,6 +19,6 @@ test('name is either a string or an element', async () => {
1919

2020
setup({ columns, rows: [] });
2121
const [cell1, cell2] = getHeaderCells();
22-
await expect.element(cell1).toHaveTextContent('ID');
23-
await expect.element(cell2).toHaveTextContent('Fancy');
22+
expect(cell1).toHaveTextContent('ID');
23+
expect(cell2).toHaveTextContent('Fancy');
2424
});

0 commit comments

Comments
 (0)