gristlabs_grist-core/test/nbrowser/DetailView.ntest.js
Paul Fitzpatrick bcbf57d590 (core) bump mocha version to allow parallel tests; move more tests to core
Summary:
This uses a newer version of mocha in grist-core so that tests can be run in parallel. That allows more tests to be moved without slowing things down overall. Tests moved are venerable browser tests; only the ones that "just work" or worked without too much trouble to are moved, in order to keep the diff from growing too large. Will wrestle with more in follow up.

Parallelism is at the file level, rather than the individual test.

The newer version of mocha isn't needed for grist-saas repo; tests are parallelized in our internal CI by other means. I've chosen to allocate files to workers in a cruder way than our internal CI, based on initial characters rather than an automated process. The automated process would need some reworking to be compatible with mocha running in parallel mode.

Test Plan: this diff was tested first on grist-core, then ported to grist-saas so saas repo history will correctly track history of moved files.

Reviewers: jarek

Reviewed By: jarek

Subscribers: jarek

Differential Revision: https://phab.getgrist.com/D3927
2023-06-27 02:55:34 -04:00

119 lines
5.1 KiB
JavaScript

import { assert } from 'mocha-webdriver';
import { $, gu, test } from 'test/nbrowser/gristUtil-nbrowser';
describe("DetailView.ntest", function () {
const cleanup = test.setupTestSuite(this);
gu.bigScreen();
before(async function() {
await gu.supportOldTimeyTestCode();
await gu.useFixtureDoc(cleanup, "Favorite_Films.grist", true);
// Open the view tab.
await gu.openSidePane('view');
// Open the 'All' view
await gu.actions.selectTabView('All');
// close the side pane
await gu.toggleSidePanel('left', 'close');
});
afterEach(function() {
return gu.checkForErrors();
});
it('should allow switching between card and detail view', async function() {
await gu.actions.viewSection('Performances detail').selectSection();
// Check that the detail cells have the correct values.
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1]), ['Tom Hanks']);
await $('.grist-single-record__menu .detail-right').click();
// rowNum is always 1 for detail cells now.
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1]), ['Tim Allen']);
// Swap to Card List view, check values.
await $('.test-right-panel button:contains(Change Widget)').click();
await $('.test-wselect-type:contains(Card List)').click();
await $('.test-wselect-addBtn').click();
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1, 2]),
['Tom Hanks', 'Tim Allen']);
// Swap back to Card view, re-check values.
await $('.test-right-panel button:contains(Change Widget)').click();
await $('.test-wselect-type:contains(Card)').click();
await $('.test-wselect-addBtn').click();
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1]), ['Tim Allen']);
await $('.grist-single-record__menu .detail-left').click();
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1]), ['Tom Hanks']);
});
it('should allow editing cells', async function() {
// Updates should be reflected in the detail floating rowModel cell.
await gu.sendKeys('Roger Federer', $.ENTER);
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1]), ['Roger Federer']);
// Undo updates should be reflected as well.
await gu.sendKeys([$.MOD, 'z']);
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1]), ['Tom Hanks']);
});
// Note: This is a test of a specific bug related to the detail rowModel being resized after
// being unset.
it('should allow row resize operations after switching section type', async function() {
// Switch to Card List view and enter a formula. This should cause the scrolly to resize all rows.
// If the detail view rowModel is wrongly resized, the action will fail.
await $('.test-right-panel button:contains(Change Widget)').click();
await $('.test-wselect-type:contains(Card List)').click();
await $('.test-wselect-addBtn').click();
await gu.waitForServer();
await gu.sendKeys('=');
await $('.test-editor-tooltip-convert').click(); // Convert to a formula
await gu.sendKeys('100', $.ENTER);
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Actor', [1, 2, 3, 4]),
['100', '100', '100', '100']);
});
it('should include an add record row', async function() {
// Should include an add record row which works in card view and detail view.
// Check that adding 'Jurassic Park' to the card view add record row adds it as a row.
// await gu.selectSectionByTitle("Performances detail");
//await gu.sendKeys([$.MOD, $.DOWN]);
await $('.g_record_detail:nth-child(14) .field_clip').eq(1).wait().click();
await gu.sendKeys('Jurassic Park', $.ENTER);
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Film', [14]), ['Jurassic Park']);
// Check that adding 'Star Wars' to the detail view add record row adds it as a row.
await $('.test-right-panel button:contains(Change Widget)').click();
await $('.test-wselect-type:contains(Card)').click();
await $('.test-wselect-addBtn').click();
await gu.waitForServer();
await $('.detail-add-btn').wait().click();
// Card view, so rowNum is now 1
await gu.getDetailCell('Film', 1).click();
await gu.sendKeys('Star Wars', $.ENTER);
await gu.waitForServer();
assert.deepEqual(await gu.getVisibleDetailCells('Film', [1]), ['Star Wars']);
// Should allow pasting into the add record row.
await gu.getDetailCell('Actor', 1).click();
await gu.sendKeys($.COPY);
await $('.detail-add-btn').click();
// Paste '100' into the last field of the row and check that it is added as its own row.
await gu.getDetailCell('Character', 1).click();
await gu.sendKeys($.PASTE);
await gu.waitForServer();
assert.deepEqual(await gu.getDetailCell('Character', 1).text(), '100');
// Should not throw errors when deleting the add record row.
await $('.detail-add-btn').click();
await gu.sendKeys([$.MOD, $.DELETE]);
// Errors will be detected in afterEach.
});
});