diff --git a/tests/test_basic.spec.mjs b/tests/test_basic.spec.mjs index db2a41dc..838ff552 100644 --- a/tests/test_basic.spec.mjs +++ b/tests/test_basic.spec.mjs @@ -1509,4 +1509,131 @@ test('Test angular frequency conversions', async () => { expect(parseLatexFloat(content)).toBeCloseTo(3/pi, precision); content = await page.textContent('#result-units-4'); expect(content).toBe('s^-1'); -}); \ No newline at end of file +}); + +test('Test cell drag to reorder', async () => { + await page.locator('#cell-0 >> math-field.editable').type("0="); + + await page.locator('#add-math-cell').click(); + await page.locator('#cell-1 >> math-field.editable').type("1="); + + await page.locator('#add-math-cell').click(); + await page.locator('#cell-2 >> math-field.editable').type("2="); + + await page.locator('#add-math-cell').click(); + await page.locator('#cell-3 >> math-field.editable').type("3="); + + await page.locator('#add-math-cell').click(); + await page.locator('#cell-4 >> math-field.editable').type("4="); + + await page.locator('#add-math-cell').click(); + await page.locator('#cell-5 >> math-field.editable').type("5="); + + await page.locator('#add-math-cell').click(); + await page.locator('#cell-6 >> math-field.editable').type("6="); + + await page.locator('#cell-container-0 >> button[title="Drag to Move Cell"]') + .dragTo(page.locator('#cell-container-6 >> button[title="Drag to Move Cell"]')); + + await page.waitForSelector('.status-footer', { state: 'detached'}); + + let content = await page.textContent('#result-value-0'); + expect(parseLatexFloat(content)).toBeCloseTo(1, precision); + + content = await page.textContent('#result-value-1'); + expect(parseLatexFloat(content)).toBeCloseTo(2, precision); + + content = await page.textContent('#result-value-2'); + expect(parseLatexFloat(content)).toBeCloseTo(3, precision); + + content = await page.textContent('#result-value-3'); + expect(parseLatexFloat(content)).toBeCloseTo(4, precision); + + content = await page.textContent('#result-value-4'); + expect(parseLatexFloat(content)).toBeCloseTo(5, precision); + + content = await page.textContent('#result-value-5'); + expect(parseLatexFloat(content)).toBeCloseTo(6, precision); + + content = await page.textContent('#result-value-6'); + expect(parseLatexFloat(content)).toBeCloseTo(0, precision); + + await page.locator('#cell-container-6 >> button[title="Drag to Move Cell"]') + .dragTo(page.locator('#cell-container-5 >> button[title="Drag to Move Cell"]')); + + await page.waitForSelector('.status-footer', { state: 'detached'}); + + content = await page.textContent('#result-value-0'); + expect(parseLatexFloat(content)).toBeCloseTo(1, precision); + + content = await page.textContent('#result-value-1'); + expect(parseLatexFloat(content)).toBeCloseTo(2, precision); + + content = await page.textContent('#result-value-2'); + expect(parseLatexFloat(content)).toBeCloseTo(3, precision); + + content = await page.textContent('#result-value-3'); + expect(parseLatexFloat(content)).toBeCloseTo(4, precision); + + content = await page.textContent('#result-value-4'); + expect(parseLatexFloat(content)).toBeCloseTo(5, precision); + + content = await page.textContent('#result-value-5'); + expect(parseLatexFloat(content)).toBeCloseTo(0, precision); + + content = await page.textContent('#result-value-6'); + expect(parseLatexFloat(content)).toBeCloseTo(6, precision); + + await page.locator('#cell-container-5 >> button[title="Drag to Move Cell"]') + .dragTo(page.locator('#cell-container-0 >> button[title="Drag to Move Cell"]')); + + await page.waitForSelector('.status-footer', { state: 'detached'}); + + content = await page.textContent('#result-value-0'); + expect(parseLatexFloat(content)).toBeCloseTo(0, precision); + + content = await page.textContent('#result-value-1'); + expect(parseLatexFloat(content)).toBeCloseTo(1, precision); + + content = await page.textContent('#result-value-2'); + expect(parseLatexFloat(content)).toBeCloseTo(2, precision); + + content = await page.textContent('#result-value-3'); + expect(parseLatexFloat(content)).toBeCloseTo(3, precision); + + content = await page.textContent('#result-value-4'); + expect(parseLatexFloat(content)).toBeCloseTo(4, precision); + + content = await page.textContent('#result-value-5'); + expect(parseLatexFloat(content)).toBeCloseTo(5, precision); + + content = await page.textContent('#result-value-6'); + expect(parseLatexFloat(content)).toBeCloseTo(6, precision); + + await page.locator('#cell-container-1 >> button[title="Drag to Move Cell"]') + .dragTo(page.locator('#cell-container-2 >> button[title="Drag to Move Cell"]')); + + await page.waitForSelector('.status-footer', { state: 'detached'}); + + content = await page.textContent('#result-value-0'); + expect(parseLatexFloat(content)).toBeCloseTo(0, precision); + + content = await page.textContent('#result-value-1'); + expect(parseLatexFloat(content)).toBeCloseTo(2, precision); + + content = await page.textContent('#result-value-2'); + expect(parseLatexFloat(content)).toBeCloseTo(1, precision); + + content = await page.textContent('#result-value-3'); + expect(parseLatexFloat(content)).toBeCloseTo(3, precision); + + content = await page.textContent('#result-value-4'); + expect(parseLatexFloat(content)).toBeCloseTo(4, precision); + + content = await page.textContent('#result-value-5'); + expect(parseLatexFloat(content)).toBeCloseTo(5, precision); + + content = await page.textContent('#result-value-6'); + expect(parseLatexFloat(content)).toBeCloseTo(6, precision); + +});