-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathtwo_billion_rows.test.js
More file actions
220 lines (201 loc) · 8.15 KB
/
two_billion_rows.test.js
File metadata and controls
220 lines (201 loc) · 8.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/******************************************************************************
*
* Copyright (c) 2020, the Regular Table Authors.
*
* This file is part of the Regular Table library, distributed under the terms
* of the Apache License 2.0. The full license can be found in the LICENSE
* file.
*
*/
describe("two_billion_rows.html", () => {
beforeAll(async () => {
await page.setViewport({ width: 200, height: 100 });
});
describe("creates a `<table>` body when attached to `document`", () => {
beforeAll(async () => {
await page.goto(
"http://localhost:8081/dist/examples/two_billion_rows.html",
);
await page.waitForSelector("regular-table table tbody tr td");
});
test("with the correct # of rows", async () => {
const tbody = await page.$("regular-table tbody");
const num_rows = await page.evaluate(
(tbody) => tbody.children.length,
tbody,
);
expect(num_rows).toEqual(5);
});
test("with the correct # of columns", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const num_cells = await page.evaluate(
(first_tr) => first_tr.children.length,
first_tr,
);
expect(num_cells).toEqual(4);
});
test("with the first row's cell test correct", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const cell_values = await page.evaluate(
(first_tr) =>
Array.from(first_tr.children).map((x) => x.textContent),
first_tr,
);
expect(cell_values).toEqual(["Group 0", "Row 0", "0", "1"]);
});
});
describe("scrolls down", () => {
beforeAll(async () => {
await page.goto(
"http://localhost:8081/dist/examples/two_billion_rows.html",
);
await page.waitForSelector("regular-table table tbody tr td");
const table = await page.$("regular-table");
await page.evaluate(async (table) => {
table.scrollTop = 1000;
await table._draw_flush();
}, table);
});
test("with the correct # of rows", async () => {
const tbody = await page.$("regular-table tbody");
const num_rows = await page.evaluate(
(tbody) => tbody.children.length,
tbody,
);
expect(num_rows).toEqual(4);
});
test("with the first row's cell test correct", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const cell_values = await page.evaluate(
(first_tr) =>
Array.from(first_tr.children).map((x) => x.textContent),
first_tr,
);
expect(cell_values).toEqual([
"Group 200,000",
"Row 200,001",
"200,001",
"200,002",
"200,003",
]);
});
});
describe("scrolls right", () => {
beforeAll(async () => {
await page.goto(
"http://localhost:8081/dist/examples/two_billion_rows.html",
);
await page.waitForSelector("regular-table table tbody tr td");
const table = await page.$("regular-table");
await page.evaluate(async (table) => {
table.scrollLeft = 1000;
await table._draw_flush();
}, table);
});
test("with the correct # of columns", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const num_cells = await page.evaluate(
(first_tr) => first_tr.children.length,
first_tr,
);
expect(num_cells).toEqual(4);
});
test("with the first row's cell test correct", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const cell_values = await page.evaluate(
(first_tr) =>
Array.from(first_tr.children).map((x) => x.textContent),
first_tr,
);
expect(cell_values).toEqual(["Group 0", "Row 0", "16", "17"]);
});
});
describe("scrolls via scrollToCell() method", () => {
beforeAll(async () => {
await page.goto(
"http://localhost:8081/dist/examples/two_billion_rows.html",
);
await page.waitForSelector("regular-table table tbody tr td");
});
test.skip("https://github.com/finos/regular-table/issues/15", async () => {
const table = await page.$("regular-table");
await page.evaluate(async (table) => {
table.scrollToCell(0, 250500, 1000, 2000000000);
await table.draw({ invalid_viewport: true });
}, table);
const first_tr = await page.$("regular-table tbody tr:first-child");
const cell_values = await page.evaluate(
(first_tr) =>
Array.from(first_tr.children).map((x) => x.textContent),
first_tr,
);
expect(cell_values).toEqual(["250,501", "250,502", "250,503"]);
});
});
describe("scrolls down beyond bottom threshold", () => {
beforeAll(async () => {
await page.goto(
"http://localhost:8081/dist/examples/two_billion_rows.html",
);
await page.waitForSelector("regular-table table tbody tr td");
const table = await page.$("regular-table");
await page.evaluate(async (table) => {
table.scrollTop = table.scrollHeight + 100000;
await table._draw_flush();
}, table);
});
test("with the correct # of rows", async () => {
const tbody = await page.$("regular-table tbody");
const num_rows = await page.evaluate(
(tbody) => tbody.children.length,
tbody,
);
expect(num_rows).toEqual(3);
});
test("with the first row's cell test correct", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const cell_values = await page.evaluate(
(first_tr) =>
Array.from(first_tr.children).map((x) => x.textContent),
first_tr,
);
expect(cell_values).toEqual([
"Group 1,999,999,990",
"Row 1,999,999,997",
"1,999,999,997",
"1,999,999,998",
"1,999,999,999",
]);
});
});
describe("scrolls rights beyond right border threshold", () => {
beforeAll(async () => {
await page.goto(
"http://localhost:8081/dist/examples/two_billion_rows.html",
);
await page.waitForSelector("regular-table table tbody tr td");
const table = await page.$("regular-table");
await page.evaluate(async (table) => {
table.scrollLeft = table.scrollWidth + 100000;
await table._draw_flush();
}, table);
});
test("with the correct # of columns", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const num_cells = await page.evaluate(
(first_tr) => first_tr.children.length,
first_tr,
);
expect(num_cells).toEqual(4);
});
test("with the first row's cell test correct", async () => {
const first_tr = await page.$("regular-table tbody tr:first-child");
const cell_values = await page.evaluate(
(first_tr) =>
Array.from(first_tr.children).map((x) => x.textContent),
first_tr,
);
expect(cell_values).toEqual(["Group 0", "Row 0", "998", "999"]);
});
});
});