Skip to content

Commit 618e289

Browse files
committed
Tests - Add VueUiXyCanvas component test
1 parent 8d5e186 commit 618e289

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

cypress/fixtures/vdui-components.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,16 @@ export const components = [
15111511
type: 'line'
15121512
}
15131513
],
1514+
config: {
1515+
style: {
1516+
chart: {
1517+
title: {
1518+
text: 'Title',
1519+
subtitle: { text: 'Subtitle' }
1520+
}
1521+
}
1522+
}
1523+
},
15141524
wrapperClass: '.vue-ui-xy-canvas'
15151525
},
15161526
{

src/components/vue-ui-xy-canvas.cy.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import VueUiXyCanvas from "./vue-ui-xy-canvas.vue";
2+
import { components } from "../../cypress/fixtures/vdui-components";
3+
import { testCommonFeatures } from "../../cypress/fixtures";
4+
5+
const { dataset, config } = components.find(c => c.name === 'VueUiXyCanvas');
6+
7+
describe('<VueUiXyCanvas />', () => {
8+
9+
it('renders', () => {
10+
cy.viewport(500, 560);
11+
cy.mount(VueUiXyCanvas, {
12+
props: {
13+
dataset,
14+
config
15+
}
16+
}).then(() => {
17+
18+
testCommonFeatures({
19+
userOptions: true,
20+
title: true,
21+
subtitle: true,
22+
legend: true,
23+
dataTable: true,
24+
slicer: true,
25+
tooltipCallback: () => {
26+
cy.get('[data-cy="canvas"]').trigger('mousemove')
27+
}
28+
});
29+
30+
cy.get('[data-cy="canvas"]').then(canvas => {
31+
const c = canvas[0];
32+
const ctx = c.getContext('2d');
33+
const pixelData = ctx.getImageData(10, 10, 1, 1).data;
34+
expect(pixelData[3]).to.be.greaterThan(0);
35+
});
36+
});
37+
});
38+
});

src/components/vue-ui-xy-canvas.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,8 @@ defineExpose({
16131613
16141614
<div class="vue-ui-xy-canvas" :style="`position: relative; aspect-ratio: ${aspectRatio}`"
16151615
ref="container">
1616-
<canvas
1616+
<canvas
1617+
data-cy="canvas"
16171618
v-if="isDataset"
16181619
ref="canvas"
16191620
style="width:100%; height:100%;"

0 commit comments

Comments
 (0)