Skip to content

Commit fe7e02c

Browse files
committed
add parcoords jasmine tests to lock click issue reported in phx 235
1 parent 80383f9 commit fe7e02c

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

test/jasmine/tests/parcoords_test.js

+72
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ function mouseTo(x, y) {
4040
mouseEvent('mouseover', x, y);
4141
}
4242

43+
function mouseClick(x, y) {
44+
mouseTo(x, y);
45+
mouseEvent('mousedown', x, y);
46+
mouseEvent('mouseup', x, y);
47+
}
48+
4349
function mostOfDrag(x1, y1, x2, y2) {
4450
mouseTo(x1, y1);
4551
mouseEvent('mousedown', x1, y1);
@@ -1625,3 +1631,69 @@ describe('parcoords constraint interactions - with defined axis ranges', functio
16251631
.then(done);
16261632
});
16271633
});
1634+
1635+
describe('parcoords constraint click interactions - with pre-defined constraint ranges', function() {
1636+
function initialFigure() {
1637+
return {
1638+
data: [{
1639+
type: 'parcoords',
1640+
dimensions: [{
1641+
values: [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
1642+
}, {
1643+
values: [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],
1644+
tickvals: [0, 1, 2, 3, 4, 5, 6],
1645+
ticktext: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
1646+
constraintrange: [1, 2]
1647+
}]
1648+
}],
1649+
layout: {
1650+
width: 400,
1651+
height: 400,
1652+
margin: {t: 100, b: 100, l: 100, r: 100}
1653+
}
1654+
};
1655+
}
1656+
1657+
var gd;
1658+
var initialSnapDuration;
1659+
var shortenedSnapDuration = 20;
1660+
var snapDelay = 100;
1661+
beforeAll(function() {
1662+
initialSnapDuration = PC.bar.snapDuration;
1663+
PC.bar.snapDuration = shortenedSnapDuration;
1664+
});
1665+
1666+
afterAll(function() {
1667+
purgeGraphDiv();
1668+
PC.bar.snapDuration = initialSnapDuration;
1669+
});
1670+
1671+
beforeEach(function(done) {
1672+
var hasGD = !!gd;
1673+
if(!hasGD) gd = createGraphDiv();
1674+
1675+
Plotly.react(gd, initialFigure())
1676+
.catch(failTest)
1677+
.then(done);
1678+
});
1679+
1680+
it('@noCI @gl should not drop constraintrange on click', function(done) {
1681+
expect(gd._fullData[0].dimensions[1].constraintrange).toBeCloseToArray([0.75, 2.25]);
1682+
1683+
// click to add a new item to the selection
1684+
mouseClick(295, 200);
1685+
delay(snapDelay)()
1686+
.then(function() {
1687+
expect(gd._fullData[0].dimensions[1].constraintrange).toBeCloseToArray([[0.75, 2.25], [2.75, 3.25]]);
1688+
1689+
// click to deselect all
1690+
mouseClick(295, 205);
1691+
})
1692+
.then(delay(snapDelay)())
1693+
.then(function() {
1694+
expect(gd._fullData[0].dimensions[1].constraintrange).toEqual(undefined);
1695+
})
1696+
.catch(failTest)
1697+
.then(done);
1698+
});
1699+
});

0 commit comments

Comments
 (0)