Skip to content

Commit

Permalink
tests: add drag to reorder cells test
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreminger committed Apr 7, 2024
1 parent e625d5a commit e2c70af
Showing 1 changed file with 128 additions and 1 deletion.
129 changes: 128 additions & 1 deletion tests/test_basic.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

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);

});

0 comments on commit e2c70af

Please sign in to comment.