Skip to content

Commit c66d9e1

Browse files
committed
Tests - Improve VueUiParallelCoordinatePlot component test
1 parent 0d9a972 commit c66d9e1

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/atoms/Shape.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const d = computed(() => {
8484
<template>
8585
<g data-cy="atom-shape">
8686
<circle
87+
class="legend-shape-circle"
8788
v-if="config && config.points === 1"
8889
:cx="plot.x"
8990
:cy="plot.y"
@@ -96,6 +97,7 @@ const d = computed(() => {
9697
@click="emit('click')"
9798
/>
9899
<path
100+
class="legend-shape-polygon"
99101
v-if="config && config.points >= limit"
100102
:d="d"
101103
:fill="color"
@@ -106,6 +108,7 @@ const d = computed(() => {
106108
@click="emit('click')"
107109
/>
108110
<polygon
111+
class="legend-shape-star"
109112
v-if="starPoints"
110113
:points="starPoints"
111114
:fill="color"

src/components/vue-ui-parallel-coordinate-plot.cy.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,36 @@ describe('<VueUiParallelCoordinatePlot />', () => {
4646
cy.get('[data-cy="datapoint-line"]').should('exist').and('be.visible').and('have.length', dataset.flatMap(d => d.series).length);
4747
});
4848
});
49+
50+
it('emits', () => {
51+
cy.mount(VueUiParallelCoordinatePlot, {
52+
props: {
53+
dataset,
54+
config
55+
}
56+
}).then(({ wrapper }) => {
57+
cy.log('@selectLegend');
58+
cy.get('[data-cy="legend-item"]').first().click({ force: true }).then(() => {
59+
expect(wrapper.emitted('selectLegend')).to.exist;
60+
});
61+
62+
cy.log('@selectDatapoint');
63+
cy.get('.legend-shape-circle').first().click({ force: true }).then(() => {
64+
expect(wrapper.emitted('selectDatapoint')).to.exist;
65+
expect(wrapper.emitted('selectDatapoint')[0][0]).to.have.keys(
66+
'axisIndex',
67+
'comment',
68+
'datapointIndex',
69+
'name',
70+
'seriesIndex',
71+
'seriesName',
72+
'value',
73+
'x',
74+
'y'
75+
);
76+
expect(wrapper.emitted('selectDatapoint')[0][0].axisIndex).to.equal(0);
77+
expect(wrapper.emitted('selectDatapoint')[0][0].seriesIndex).to.equal(0);
78+
});
79+
});
80+
});
4981
});

src/components/vue-ui-parallel-coordinate-plot.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ defineExpose({
744744
<g v-for="(serieSet, i) in serie.series">
745745
<!-- PLOTS -->
746746
<g v-if="FINAL_CONFIG.style.chart.plots.show">
747-
<Shape
747+
<Shape
748748
v-for="dp in serieSet.datapoints"
749749
:plot="{ x: dp.x, y: dp.y }"
750750
:color="serie.color"
@@ -880,7 +880,7 @@ defineExpose({
880880
@clickMarker="({ legend }) => { segregate(legend.id); selectLegend(legend) }"
881881
>
882882
<template #item="{ legend, index }">
883-
<div :data-cy="`legend-item-${index}`" @click="legend.segregate(); selectLegend(legend)" :style="`opacity:${segregated.includes(legend.id) ? 0.5 : 1}`">
883+
<div data-cy="legend-item" @click="legend.segregate(); selectLegend(legend)" :style="`opacity:${segregated.includes(legend.id) ? 0.5 : 1}`">
884884
{{ legend.name }}
885885
</div>
886886
</template>

0 commit comments

Comments
 (0)