diff --git a/test-runtime/index.html b/test-runtime/index.html index 456d6084b2..931e7bc2c4 100644 --- a/test-runtime/index.html +++ b/test-runtime/index.html @@ -45,15 +45,6 @@ target.dispatchEvent(type === 'wheel' ? new WheelEvent('wheel', opts) : new MouseEvent(type, opts)); } - function pureClear(id, parent, targetBrush) { - const el0 = mark(id, parent); - const [clientX, clientY] = coords(el0); - - pureMouseEvt('mousedown', el0, {clientX, clientY}); - pureMouseEvt('mouseup', window, {clientX, clientY}); - pureMouseEvt('click', el0, {clientX, clientY}); - } - function mark(id, parent) { return document.querySelector((parent ? `g.${parent} ` : '') + `g.mark-symbol.role-mark path:nth-child(${id})`); } diff --git a/test-runtime/region.test.ts b/test-runtime/region.test.ts index 3e81258a50..2ea652ed48 100644 --- a/test-runtime/region.test.ts +++ b/test-runtime/region.test.ts @@ -1,6 +1,6 @@ import {TopLevelSpec} from '../src'; import {SELECTION_ID, SelectionType} from '../src/selection'; -import {clear, embedFn, circleRegion, polygonRegion, spec, testRenderFn, hits} from './util'; +import {clearRegion, embedFn, circleRegion, polygonRegion, spec, testRenderFn, hits} from './util'; import {Page} from 'puppeteer/lib/cjs/puppeteer/common/Page'; describe('region selections at runtime in unit views', () => { @@ -60,8 +60,8 @@ describe('region selections at runtime in unit views', () => { let store = await page.evaluate(circleRegion(hit.id)); expect(store).toHaveLength(hit.count); - store = await page.evaluate(clear(hits.region.circle_clear[0].id)); - expect(store).toBeUndefined(); + store = await page.evaluate(clearRegion(hits.region.circle_clear[0].id)); + expect(store).toHaveLength(0); await testRender(`clear_0`); }); diff --git a/test-runtime/resolve.test.ts b/test-runtime/resolve.test.ts index d3873dffde..e465d341c3 100644 --- a/test-runtime/resolve.test.ts +++ b/test-runtime/resolve.test.ts @@ -3,6 +3,7 @@ import { compositeTypes, embedFn, hits as hitsMaster, + multiviewRegion, parentSelector, pt, resolutions, @@ -14,10 +15,15 @@ import { import {Page} from 'puppeteer/lib/cjs/puppeteer/common/Page'; import {TopLevelSpec} from '../src'; +const fns = { + point: pt, + interval: brush, + region: multiviewRegion +}; + for (const type of selectionTypes) { - const isInterval = type === 'interval'; const hits = hitsMaster[type]; - const fn = isInterval ? brush : pt; + const fn = fns[type]; describe(`${type} selections at runtime`, () => { let page: Page; @@ -49,7 +55,7 @@ for (const type of selectionTypes) { const selection = { type, resolve: 'global', - ...(specType === 'facet' ? {encodings: ['y']} : {}) + ...(specType === 'facet' && type !== 'region' ? {encodings: ['y']} : {}) }; for (let i = 0; i < hits[specType].length; i++) { @@ -72,7 +78,7 @@ for (const type of selectionTypes) { const selection = { type, resolve, - ...(specType === 'facet' ? {encodings: ['x']} : {}) + ...(specType === 'facet' && type !== 'region' ? {encodings: ['x']} : {}) }; /** diff --git a/test-runtime/resources/region/facet/global_0.svg b/test-runtime/resources/region/facet/global_0.svg new file mode 100644 index 0000000000..e9b60bbfb9 --- /dev/null +++ b/test-runtime/resources/region/facet/global_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/global_1.svg b/test-runtime/resources/region/facet/global_1.svg new file mode 100644 index 0000000000..9914adb83d --- /dev/null +++ b/test-runtime/resources/region/facet/global_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/global_2.svg b/test-runtime/resources/region/facet/global_2.svg new file mode 100644 index 0000000000..fc5392f14c --- /dev/null +++ b/test-runtime/resources/region/facet/global_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/global_clear_2.svg b/test-runtime/resources/region/facet/global_clear_2.svg new file mode 100644 index 0000000000..cb25b91108 --- /dev/null +++ b/test-runtime/resources/region/facet/global_clear_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_0.svg b/test-runtime/resources/region/facet/intersect_0.svg new file mode 100644 index 0000000000..eb6da9e8ef --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_1.svg b/test-runtime/resources/region/facet/intersect_1.svg new file mode 100644 index 0000000000..3312529937 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_2.svg b/test-runtime/resources/region/facet/intersect_2.svg new file mode 100644 index 0000000000..9683dc2306 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_clear_0.svg b/test-runtime/resources/region/facet/intersect_clear_0.svg new file mode 100644 index 0000000000..2884ee4b8e --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_clear_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_clear_1.svg b/test-runtime/resources/region/facet/intersect_clear_1.svg new file mode 100644 index 0000000000..be479fff92 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_clear_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_clear_2.svg b/test-runtime/resources/region/facet/intersect_clear_2.svg new file mode 100644 index 0000000000..b9bfcf6b8c --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_clear_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_0.svg b/test-runtime/resources/region/facet/union_0.svg new file mode 100644 index 0000000000..eb6da9e8ef --- /dev/null +++ b/test-runtime/resources/region/facet/union_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_1.svg b/test-runtime/resources/region/facet/union_1.svg new file mode 100644 index 0000000000..5e1dc0206c --- /dev/null +++ b/test-runtime/resources/region/facet/union_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_2.svg b/test-runtime/resources/region/facet/union_2.svg new file mode 100644 index 0000000000..c60a631590 --- /dev/null +++ b/test-runtime/resources/region/facet/union_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_clear_0.svg b/test-runtime/resources/region/facet/union_clear_0.svg new file mode 100644 index 0000000000..2884ee4b8e --- /dev/null +++ b/test-runtime/resources/region/facet/union_clear_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_clear_1.svg b/test-runtime/resources/region/facet/union_clear_1.svg new file mode 100644 index 0000000000..be479fff92 --- /dev/null +++ b/test-runtime/resources/region/facet/union_clear_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_clear_2.svg b/test-runtime/resources/region/facet/union_clear_2.svg new file mode 100644 index 0000000000..ed821edf5a --- /dev/null +++ b/test-runtime/resources/region/facet/union_clear_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_0.svg b/test-runtime/resources/region/repeat/global_0.svg new file mode 100644 index 0000000000..3aa27092c9 --- /dev/null +++ b/test-runtime/resources/region/repeat/global_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_1.svg b/test-runtime/resources/region/repeat/global_1.svg new file mode 100644 index 0000000000..79477098ba --- /dev/null +++ b/test-runtime/resources/region/repeat/global_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_2.svg b/test-runtime/resources/region/repeat/global_2.svg new file mode 100644 index 0000000000..81dd340021 --- /dev/null +++ b/test-runtime/resources/region/repeat/global_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_clear_2.svg b/test-runtime/resources/region/repeat/global_clear_2.svg new file mode 100644 index 0000000000..35d7e51bbf --- /dev/null +++ b/test-runtime/resources/region/repeat/global_clear_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_0.svg b/test-runtime/resources/region/repeat/intersect_0.svg new file mode 100644 index 0000000000..18ba0ea442 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_1.svg b/test-runtime/resources/region/repeat/intersect_1.svg new file mode 100644 index 0000000000..12d9e4d08e --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_2.svg b/test-runtime/resources/region/repeat/intersect_2.svg new file mode 100644 index 0000000000..b5ed167f3b --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_clear_0.svg b/test-runtime/resources/region/repeat/intersect_clear_0.svg new file mode 100644 index 0000000000..3574852192 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_clear_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_clear_1.svg b/test-runtime/resources/region/repeat/intersect_clear_1.svg new file mode 100644 index 0000000000..3882d40c82 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_clear_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_clear_2.svg b/test-runtime/resources/region/repeat/intersect_clear_2.svg new file mode 100644 index 0000000000..3d2e06adf7 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_clear_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_0.svg b/test-runtime/resources/region/repeat/union_0.svg new file mode 100644 index 0000000000..18ba0ea442 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_1.svg b/test-runtime/resources/region/repeat/union_1.svg new file mode 100644 index 0000000000..76b0bb9287 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_2.svg b/test-runtime/resources/region/repeat/union_2.svg new file mode 100644 index 0000000000..f01ab7a7e3 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_clear_0.svg b/test-runtime/resources/region/repeat/union_clear_0.svg new file mode 100644 index 0000000000..3574852192 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_clear_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_clear_1.svg b/test-runtime/resources/region/repeat/union_clear_1.svg new file mode 100644 index 0000000000..3882d40c82 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_clear_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_clear_2.svg b/test-runtime/resources/region/repeat/union_clear_2.svg new file mode 100644 index 0000000000..edd1fa5361 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_clear_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/unit/clear_0.svg b/test-runtime/resources/region/unit/clear_0.svg index a442a6aea6..1b119829d8 100644 --- a/test-runtime/resources/region/unit/clear_0.svg +++ b/test-runtime/resources/region/unit/clear_0.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test-runtime/util.ts b/test-runtime/util.ts index d1de67175f..6f3e2a0d81 100644 --- a/test-runtime/util.ts +++ b/test-runtime/util.ts @@ -10,7 +10,7 @@ const generate = process.env.VL_GENERATE_TESTS; const output = 'test-runtime/resources'; export type ComposeType = 'unit' | 'repeat' | 'facet'; -export const selectionTypes: SelectionType[] = ['point', 'interval']; +export const selectionTypes: SelectionType[] = ['point', 'interval', 'region']; export const compositeTypes: ComposeType[] = ['repeat', 'facet']; export const resolutions: SelectionResolution[] = ['union', 'intersect']; @@ -139,7 +139,13 @@ export const hits = { ], count: 2 } - ] + ], + + facet: [2, 4, 7], + facet_clear: [3, 5, 8], + + repeat: [5, 10, 16], + repeat_clear: [13, 14, 2] } }; @@ -294,8 +300,8 @@ export function parentSelector(compositeType: ComposeType, index: number) { return compositeType === 'facet' ? `cell > g:nth-child(${index + 1})` : `${UNIT_NAMES.repeat[index]}_group`; } -export function clear(idx: number, parent?: string, targetBrush?: boolean) { - return `pureClear(${idx}, ${stringValue(parent)}, ${!!targetBrush})`; +export function clearRegion(idx: number, parent?: string, targetBrush?: boolean) { + return `clear(${idx}, ${stringValue(parent)}, ${!!targetBrush})`; } export function circleRegion(idx: number, parent?: string, targetBrush?: boolean, radius = 40, segments = 20) { @@ -306,6 +312,12 @@ export function polygonRegion(idx: number, polygon: number[][], parent?: string, return `polygonRegion(${idx}, ${JSON.stringify(polygon)}, ${stringValue(parent)}, ${!!targetBrush})`; } +export function multiviewRegion(key: string, idx: number, parent?: string, targetBrush?: boolean) { + return key.match('_clear') + ? clearRegion(hits.region[key][idx], parent, targetBrush) + : circleRegion(hits.region[key][idx], parent, targetBrush, 10); +} + export function brush(key: string, idx: number, parent?: string, targetBrush?: boolean) { const fn = key.match('_clear') ? 'clear' : 'brush'; return `${fn}(${hits.interval[key][idx].join(', ')}, ${stringValue(parent)}, ${!!targetBrush})`;