Skip to content

Commit

Permalink
Failing test: Jest Tests.src/plugins/vis_type_vega/public (#71834)
Browse files Browse the repository at this point in the history
* Failing test: Jest Tests.src/plugins/vis_type_vega/public

* remove workaround for vega height bug

Related to #31461

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
alexwizp and elasticmachine committed Jul 23, 2020
1 parent 6befacf commit b2a473d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 64 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions src/plugins/vis_type_vega/public/vega_view/vega_base_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,9 @@ export class VegaBaseView {
const width = Math.max(0, this._$container.width() - this._parser.paddingWidth);
const height =
Math.max(0, this._$container.height() - this._parser.paddingHeight) - heightExtraPadding;
// Somehow the `height` signal in vega becomes zero if the height is set exactly to
// an even number. This is a dirty workaround for this.
// when vega itself is updated again, it should be checked whether this is still
// necessary.
const adjustedHeight = height + 0.00000001;
if (view.width() !== width || view.height() !== adjustedHeight) {
view.width(width).height(adjustedHeight);

if (view.width() !== width || view.height() !== height) {
view.width(width).height(height);
return true;
}
return false;
Expand Down
66 changes: 11 additions & 55 deletions src/plugins/vis_type_vega/public/vega_visualization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jest.mock('./lib/vega', () => ({
}));

// FLAKY: https://github.com/elastic/kibana/issues/71713
describe.skip('VegaVisualizations', () => {
describe('VegaVisualizations', () => {
let domNode;
let VegaVisualization;
let vis;
Expand All @@ -77,17 +77,17 @@ describe.skip('VegaVisualizations', () => {
mockHeight = jest.spyOn($.prototype, 'height').mockImplementation(() => mockedHeightValue);
};

setKibanaMapFactory((...args) => new KibanaMap(...args));
setInjectedVars({
emsTileLayerId: {},
enableExternalUrls: true,
esShardTimeout: 10000,
});
setData(dataPluginStart);
setSavedObjects(coreStart.savedObjects);
setNotifications(coreStart.notifications);

beforeEach(() => {
setKibanaMapFactory((...args) => new KibanaMap(...args));
setInjectedVars({
emsTileLayerId: {},
enableExternalUrls: true,
esShardTimeout: 10000,
});
setData(dataPluginStart);
setSavedObjects(coreStart.savedObjects);
setNotifications(coreStart.notifications);

vegaVisualizationDependencies = {
core: coreMock.createSetup(),
plugins: {
Expand Down Expand Up @@ -185,49 +185,5 @@ describe.skip('VegaVisualizations', () => {
vegaVis.destroy();
}
});

test('should add a small subpixel value to the height of the canvas to avoid getting it set to 0', async () => {
let vegaVis;
try {
vegaVis = new VegaVisualization(domNode, vis);
const vegaParser = new VegaParser(
`{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"marks": [
{
"type": "text",
"encode": {
"update": {
"text": {
"value": "Test"
},
"align": {"value": "center"},
"baseline": {"value": "middle"},
"xc": {"signal": "width/2"},
"yc": {"signal": "height/2"}
fontSize: {value: "14"}
}
}
}
]
}`,
new SearchAPI({
search: dataPluginStart.search,
uiSettings: coreStart.uiSettings,
injectedMetadata: coreStart.injectedMetadata,
})
);
await vegaParser.parseAsync();

mockedWidthValue = 256;
mockedHeightValue = 256;

await vegaVis.render(vegaParser);
const vegaView = vegaVis._vegaView._view;
expect(vegaView.height()).toBe(250.00000001);
} finally {
vegaVis.destroy();
}
});
});
});

0 comments on commit b2a473d

Please sign in to comment.