|
| 1 | +// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ |
| 2 | +// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ |
| 3 | +// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ |
| 4 | +// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ |
| 5 | +// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ |
| 6 | +// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ |
| 7 | +// ┃ Copyright (c) 2017, the Perspective Authors. ┃ |
| 8 | +// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ |
| 9 | +// ┃ This file is part of the Perspective library, distributed under the terms ┃ |
| 10 | +// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ |
| 11 | +// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ |
| 12 | + |
| 13 | +import { expect, test } from "@finos/perspective-test"; |
| 14 | + |
| 15 | +test.describe("Tooltip data values with various 'Split By' configurations", () => { |
| 16 | + test("Show valid tooltip data with no 'Split By' configuration", async ({ |
| 17 | + page, |
| 18 | + }) => { |
| 19 | + await page.goto("/tools/perspective-test/src/html/basic-test.html"); |
| 20 | + await page.evaluate(async () => { |
| 21 | + while (!window["__TEST_PERSPECTIVE_READY__"]) { |
| 22 | + await new Promise((x) => setTimeout(x, 10)); |
| 23 | + } |
| 24 | + }); |
| 25 | + |
| 26 | + await page.evaluate(async () => { |
| 27 | + await document.querySelector("perspective-viewer")!.restore({ |
| 28 | + plugin: "X/Y Line", |
| 29 | + settings: true, |
| 30 | + columns: ["Row ID", "Postal Code", null], |
| 31 | + group_by: [], |
| 32 | + split_by: [], |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + await page.hover( |
| 37 | + "#container > d3fc-group > d3fc-svg.svg-plot-area.plot-area > svg > g:nth-child(2) > g > g:nth-child(1) > g > path", |
| 38 | + { |
| 39 | + force: true, |
| 40 | + } |
| 41 | + ); |
| 42 | + await page.waitForSelector("#tooltip-values > li:nth-child(1)"); |
| 43 | + |
| 44 | + let tooltip_row_id_value = await page.evaluate(async () => { |
| 45 | + return document |
| 46 | + .querySelector("perspective-viewer-d3fc-xyline") |
| 47 | + ?.shadowRoot?.querySelector( |
| 48 | + "#tooltip-values > li:nth-child(2) > b" |
| 49 | + )?.textContent; |
| 50 | + }); |
| 51 | + |
| 52 | + expect(tooltip_row_id_value).toBeTruthy(); |
| 53 | + expect(tooltip_row_id_value).toMatch(/^(?!NaN$|-$).+$/); |
| 54 | + }); |
| 55 | + test("Show valid tooltip data with one 'Split By' configuration", async ({ |
| 56 | + page, |
| 57 | + }) => { |
| 58 | + await page.goto("/tools/perspective-test/src/html/basic-test.html"); |
| 59 | + await page.evaluate(async () => { |
| 60 | + while (!window["__TEST_PERSPECTIVE_READY__"]) { |
| 61 | + await new Promise((x) => setTimeout(x, 10)); |
| 62 | + } |
| 63 | + }); |
| 64 | + |
| 65 | + await page.evaluate(async () => { |
| 66 | + await document.querySelector("perspective-viewer")!.restore({ |
| 67 | + plugin: "X/Y Line", |
| 68 | + settings: true, |
| 69 | + columns: ["Row ID", "Postal Code", null], |
| 70 | + group_by: [], |
| 71 | + split_by: ["Sub-Category"], |
| 72 | + }); |
| 73 | + }); |
| 74 | + |
| 75 | + await page.hover( |
| 76 | + "#container > d3fc-group > d3fc-svg.svg-plot-area.plot-area > svg > g:nth-child(2) > g > g:nth-child(1) > g > path", |
| 77 | + { |
| 78 | + force: true, |
| 79 | + } |
| 80 | + ); |
| 81 | + await page.waitForSelector("#tooltip-values > li:nth-child(2)"); |
| 82 | + |
| 83 | + let tooltip_row_id_value = await page.evaluate(async () => { |
| 84 | + return document |
| 85 | + .querySelector("perspective-viewer-d3fc-xyline") |
| 86 | + ?.shadowRoot?.querySelector( |
| 87 | + "#tooltip-values > li:nth-child(2) > b" |
| 88 | + )?.textContent; |
| 89 | + }); |
| 90 | + |
| 91 | + expect(tooltip_row_id_value).toBeTruthy(); |
| 92 | + expect(tooltip_row_id_value).toMatch(/^(?!NaN$|-$).+$/); |
| 93 | + }); |
| 94 | + test("Show valid tooltip data with multiple 'Split By' configuration", async ({ |
| 95 | + page, |
| 96 | + }) => { |
| 97 | + await page.goto("/tools/perspective-test/src/html/basic-test.html"); |
| 98 | + await page.evaluate(async () => { |
| 99 | + while (!window["__TEST_PERSPECTIVE_READY__"]) { |
| 100 | + await new Promise((x) => setTimeout(x, 10)); |
| 101 | + } |
| 102 | + }); |
| 103 | + |
| 104 | + await page.evaluate(async () => { |
| 105 | + await document.querySelector("perspective-viewer")!.restore({ |
| 106 | + plugin: "X/Y Line", |
| 107 | + settings: true, |
| 108 | + columns: ["Row ID", "Postal Code", null], |
| 109 | + group_by: [], |
| 110 | + split_by: ["Sub-Category", "Segment"], |
| 111 | + }); |
| 112 | + }); |
| 113 | + |
| 114 | + await page.hover( |
| 115 | + "#container > d3fc-group > d3fc-svg.svg-plot-area.plot-area > svg > g:nth-child(2) > g > g:nth-child(1) > g > path", |
| 116 | + { |
| 117 | + force: true, |
| 118 | + } |
| 119 | + ); |
| 120 | + await page.waitForSelector("#tooltip-values > li:nth-child(3)"); |
| 121 | + |
| 122 | + let tooltip_row_id_value = await page.evaluate(async () => { |
| 123 | + return document |
| 124 | + .querySelector("perspective-viewer-d3fc-xyline") |
| 125 | + ?.shadowRoot?.querySelector( |
| 126 | + "#tooltip-values > li:nth-child(2) > b" |
| 127 | + )?.textContent; |
| 128 | + }); |
| 129 | + |
| 130 | + expect(tooltip_row_id_value).toBeTruthy(); |
| 131 | + expect(tooltip_row_id_value).toMatch(/^(?!NaN$|-$).+$/); |
| 132 | + }); |
| 133 | +}); |
0 commit comments