I’m currently working on a charting library and have encountered an issue with a test case failing after I modified the rendering logic for an average line drawing tool. The requirement was to remove “anchor feet” from the average line tools once the drawing is set, while keeping them visible when the drawing is being drawn or hovered over.
Here’s the relevant code from average.js where I made modifications:
render(context) {
// Existing rendering logic...
// Draw the average line regardless of the highlighted state
stx.plotLine(x0, x1, y, y, color, "segment", context, panel, params);
// Conditional rendering for anchor feet
if (this.highlighted) {
stx.plotLine(x0, x0, y - 20, y + 20, color, "segment", context, panel, params);
stx.plotLine(x1, x1, y - 20, y + 20, color, "segment", context, panel, params);
}
// Existing rendering logic...
}
Test Case
The test case that is failing is defined in drawings-adv.spec.js:
it("[Drawings] should draw an average line for a study.", async () => {
// Test logic...
await compare(() =>
assert.isTrue(result.color1, "Average Line is not yellow")
);
});
Error Message
After making the changes, the test fails with the following error:
AssertionError: Average Line is not yellow: expected false to be true
What could be the reason for this test case failure?
How can I ensure that the average line is rendered correctly as yellow while still fulfilling the requirement to remove the anchor feet when the drawing is set?