2023-02-10 11:41:36 +00:00
|
|
|
import { UserAPIImpl } from 'app/common/UserAPI';
|
2023-02-06 17:19:16 +00:00
|
|
|
import { assert, driver } from 'mocha-webdriver';
|
|
|
|
import * as gu from 'test/nbrowser/gristUtils';
|
|
|
|
import { setupTestSuite } from 'test/nbrowser/testUtils';
|
|
|
|
|
2023-02-10 11:41:36 +00:00
|
|
|
async function addColumnDescription(api: UserAPIImpl, docId: string, columnName: string) {
|
|
|
|
await api.applyUserActions(docId, [
|
|
|
|
[ 'ModifyColumn', 'Table1', columnName, {
|
2023-02-15 15:41:58 +00:00
|
|
|
description: 'This is the column description\nIt is in two lines'
|
2023-02-10 11:41:36 +00:00
|
|
|
} ],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-02-06 17:19:16 +00:00
|
|
|
function getDescriptionInput() {
|
2023-02-06 17:24:35 +00:00
|
|
|
return driver.find('.test-right-panel .test-column-description');
|
2023-02-06 17:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('DescriptionColumn', function() {
|
|
|
|
this.timeout(20000);
|
|
|
|
const cleanup = setupTestSuite();
|
|
|
|
|
|
|
|
it('should support basic edition', async () => {
|
|
|
|
const mainSession = await gu.session().teamSite.login();
|
|
|
|
const api = mainSession.createHomeApi();
|
2023-02-10 11:41:36 +00:00
|
|
|
const doc = await mainSession.tempDoc(cleanup, "CardView.grist", { load: true });
|
|
|
|
const docId = doc.id;
|
2023-02-06 17:19:16 +00:00
|
|
|
|
2023-02-13 08:24:12 +00:00
|
|
|
await addColumnDescription(api, docId, 'B');
|
2023-02-10 11:41:36 +00:00
|
|
|
|
|
|
|
// Column description editable in right panel
|
2023-02-06 17:19:16 +00:00
|
|
|
await driver.find('.test-right-opener').click();
|
2023-02-10 11:41:36 +00:00
|
|
|
|
|
|
|
await gu.getCell({ rowNum: 1, col: 'B' }).click();
|
2023-02-06 17:19:16 +00:00
|
|
|
await driver.find('.test-right-tab-field').click();
|
2023-02-15 15:41:58 +00:00
|
|
|
assert.equal(await getDescriptionInput().value(), 'This is the column description\nIt is in two lines');
|
2023-02-06 17:19:16 +00:00
|
|
|
|
2023-02-10 11:41:36 +00:00
|
|
|
await gu.getCell({ rowNum: 1, col: 'A' }).click();
|
|
|
|
assert.equal(await getDescriptionInput().value(), '');
|
2023-02-06 17:19:16 +00:00
|
|
|
|
|
|
|
// Remove the description
|
|
|
|
await api.applyUserActions(docId, [
|
2023-02-10 11:41:36 +00:00
|
|
|
[ 'ModifyColumn', 'Table1', 'B', {
|
2023-02-06 17:19:16 +00:00
|
|
|
description: ''
|
|
|
|
} ],
|
|
|
|
]);
|
|
|
|
|
2023-02-10 11:41:36 +00:00
|
|
|
await gu.getCell({ rowNum: 1, col: 'B' }).click();
|
2023-02-06 17:19:16 +00:00
|
|
|
assert.equal(await getDescriptionInput().value(), '');
|
2023-02-06 17:24:35 +00:00
|
|
|
});
|
2023-02-10 11:41:36 +00:00
|
|
|
|
|
|
|
it('should show info tooltip only if there is a description', async () => {
|
|
|
|
const mainSession = await gu.session().teamSite.login();
|
|
|
|
const api = mainSession.createHomeApi();
|
|
|
|
const doc = await mainSession.tempDoc(cleanup, "CardView.grist", { load: true });
|
|
|
|
const docId = doc.id;
|
|
|
|
|
2023-02-13 08:24:12 +00:00
|
|
|
await addColumnDescription(api, docId, 'B');
|
2023-02-10 11:41:36 +00:00
|
|
|
|
|
|
|
await gu.changeWidget('Card');
|
|
|
|
|
|
|
|
const detailUndescribedColumnFirstRow = await gu.getDetailCell('A', 1);
|
2023-02-13 08:34:50 +00:00
|
|
|
assert.isFalse(
|
|
|
|
await detailUndescribedColumnFirstRow
|
|
|
|
.findClosest(".g_record_detail_el")
|
|
|
|
.find(".test-column-info-tooltip")
|
|
|
|
.isPresent()
|
|
|
|
);
|
2023-02-10 11:41:36 +00:00
|
|
|
|
|
|
|
const detailDescribedColumnFirstRow = await gu.getDetailCell('B', 1);
|
2023-02-13 08:34:50 +00:00
|
|
|
const toggle = await detailDescribedColumnFirstRow
|
|
|
|
.findClosest(".g_record_detail_el")
|
|
|
|
.find(".test-column-info-tooltip");
|
2023-02-10 11:41:36 +00:00
|
|
|
// The toggle to show the description is present if there is a description
|
|
|
|
assert.isTrue(await toggle.isPresent());
|
|
|
|
|
|
|
|
// Open the tooltip
|
|
|
|
await toggle.click();
|
|
|
|
assert.isTrue(await driver.findWait('.test-column-info-tooltip-popup', 1000).isDisplayed());
|
|
|
|
|
|
|
|
// Check the content of the tooltip
|
2023-02-13 08:34:50 +00:00
|
|
|
const descriptionTooltip = await driver
|
|
|
|
.find('.test-column-info-tooltip-popup .test-column-info-tooltip-popup-body');
|
2023-02-15 15:41:58 +00:00
|
|
|
assert.equal(await descriptionTooltip.getText(), 'This is the column description\nIt is in two lines');
|
2023-02-10 11:41:36 +00:00
|
|
|
|
|
|
|
// Close the tooltip
|
|
|
|
await toggle.click();
|
|
|
|
assert.lengthOf(await driver.findAll('.test-column-info-tooltip-popup'), 0);
|
2023-02-13 08:34:50 +00:00
|
|
|
});
|
2023-02-06 17:24:35 +00:00
|
|
|
});
|