chart/tests/e2e/harness.test.mjs
Chris Amow 3b3c06a1f3 - Drag a selected trendline body to reposition the entire line.
- Duplicate and delete from the line context menu.
     - Copies shift ten bars right.
     - Default names are up and down; copies become up 2, down 2, etc.
     - Exact local data receipt time including seconds.
     - Deployment timestamp removed.
     - Test cleanup no longer deletes drawings created from your browser.
     - JWT password session flow.
2026-08-11 05:46:09 -05:00

50 lines
1.7 KiB
JavaScript

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { launch, openChart, withChart } from './helpers.mjs';
async function createLine(page, note) {
return page.evaluate(async label => {
const c = window.__chart;
const first = c.bars[c.bars.length - 80];
const second = c.bars[c.bars.length - 60];
const response = await fetch('/api/lines', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
tf: '1m', side: 'support',
anchor_t: first.t, anchor_p: first.l,
end_t: second.t, end_p: second.l,
note: label,
}),
});
return response.json();
}, note);
}
test('test cleanup never deletes a drawing made by another browser',
{ timeout: 180000 }, async () => {
const { browser, page } = await launch();
let external = null;
let owned = null;
try {
await openChart(page);
await withChart(async testPage => {
external = await createLine(page, 'external during test');
owned = await createLine(testPage, 'owned by test');
});
const ids = await page.evaluate(async () => {
const response = await fetch('/api/drawings');
return (await response.json()).drawings.map(drawing => drawing.id);
});
assert.ok(ids.includes(external.id), 'cleanup deleted another browser\'s drawing');
assert.ok(!ids.includes(owned.id), 'cleanup left its own drawing behind');
} finally {
if (external?.id) {
await page.evaluate(id => fetch(`/api/lines/${encodeURIComponent(id)}`, {
method: 'DELETE',
}), external.id);
}
await browser.close();
}
});