|
10 | 10 | // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ |
11 | 11 | // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ |
12 | 12 |
|
13 | | -import { test } from "@finos/perspective-test"; |
| 13 | +import { shadow_type, test } from "@finos/perspective-test"; |
14 | 14 | import { |
15 | 15 | compareContentsToSnapshot, |
16 | 16 | run_standard_tests, |
@@ -120,6 +120,91 @@ test.describe("Datagrid with superstore data set", () => { |
120 | 120 | "a-filtered-to-empty-dataset-with-group-by-and-split-by-does-not-error-internally.txt" |
121 | 121 | ); |
122 | 122 | }); |
| 123 | + |
| 124 | + test("An editable datagrid is editable through mouse interaction", async ({ |
| 125 | + page, |
| 126 | + }) => { |
| 127 | + await page.goto("/tools/perspective-test/src/html/basic-test.html"); |
| 128 | + await page.evaluate(async () => { |
| 129 | + while (!window["__TEST_PERSPECTIVE_READY__"]) { |
| 130 | + await new Promise((x) => setTimeout(x, 10)); |
| 131 | + } |
| 132 | + }); |
| 133 | + |
| 134 | + await page.evaluate(async () => { |
| 135 | + await document.querySelector("perspective-viewer").restore({ |
| 136 | + plugin: "Datagrid", |
| 137 | + plugin_config: { |
| 138 | + edit_mode: "EDIT", |
| 139 | + }, |
| 140 | + columns: ["State", "City", "Customer ID"], |
| 141 | + }); |
| 142 | + }); |
| 143 | + |
| 144 | + await shadow_type( |
| 145 | + page, |
| 146 | + "Test", |
| 147 | + false, |
| 148 | + "perspective-viewer-datagrid", |
| 149 | + "table", |
| 150 | + "tbody", |
| 151 | + "tr", |
| 152 | + "td" |
| 153 | + ); |
| 154 | + |
| 155 | + const result = await page.evaluate(async () => { |
| 156 | + const view = await document |
| 157 | + .querySelector("perspective-viewer") |
| 158 | + .getView(); |
| 159 | + const json = await view.to_json_string({ end_row: 4 }); |
| 160 | + return json; |
| 161 | + }); |
| 162 | + |
| 163 | + test.expect(result).toEqual( |
| 164 | + '[{"State":"Test","City":"Henderson","Customer ID":"CG-12520"},{"State":"Kentucky","City":"Henderson","Customer ID":"CG-12520"},{"State":"California","City":"Los Angeles","Customer ID":"DV-13045"},{"State":"Florida","City":"Fort Lauderdale","Customer ID":"SO-20335"}]' |
| 165 | + ); |
| 166 | + }); |
| 167 | + |
| 168 | + test("An editable datagrid gets contenteditable focus when a cell is clicked", async ({ |
| 169 | + page, |
| 170 | + }) => { |
| 171 | + await page.goto("/tools/perspective-test/src/html/basic-test.html"); |
| 172 | + await page.evaluate(async () => { |
| 173 | + while (!window["__TEST_PERSPECTIVE_READY__"]) { |
| 174 | + await new Promise((x) => setTimeout(x, 10)); |
| 175 | + } |
| 176 | + }); |
| 177 | + |
| 178 | + const td = await page.evaluateHandle(async () => { |
| 179 | + await document.querySelector("perspective-viewer").restore({ |
| 180 | + plugin: "Datagrid", |
| 181 | + plugin_config: { |
| 182 | + edit_mode: "EDIT", |
| 183 | + }, |
| 184 | + columns: ["State", "City", "Customer ID"], |
| 185 | + }); |
| 186 | + |
| 187 | + return document |
| 188 | + .querySelector("perspective-viewer-datagrid") |
| 189 | + .shadowRoot.querySelector("table tbody tr td"); |
| 190 | + }); |
| 191 | + |
| 192 | + await td.click(); |
| 193 | + await td.asElement().fill("Test"); |
| 194 | + await page.evaluate(() => document.activeElement.blur()); |
| 195 | + |
| 196 | + const result = await page.evaluate(async () => { |
| 197 | + const view = await document |
| 198 | + .querySelector("perspective-viewer") |
| 199 | + .getView(); |
| 200 | + const json = await view.to_json_string({ end_row: 4 }); |
| 201 | + return json; |
| 202 | + }); |
| 203 | + |
| 204 | + test.expect(result).toEqual( |
| 205 | + '[{"State":"Test","City":"Henderson","Customer ID":"CG-12520"},{"State":"Kentucky","City":"Henderson","Customer ID":"CG-12520"},{"State":"California","City":"Los Angeles","Customer ID":"DV-13045"},{"State":"Florida","City":"Fort Lauderdale","Customer ID":"SO-20335"}]' |
| 206 | + ); |
| 207 | + }); |
123 | 208 | }); |
124 | 209 |
|
125 | 210 | test.describe("Datagrid with superstore arrow data set", () => { |
|
0 commit comments