(core) Fix for ReferenceList conversion during table rename

Summary:
Renaming table after converting Ref column to RefList didn't work. During table rename, all Refs columns
are converted briefly to Int columns which treats values stored in RefList columns as errors, and stores its
`repr` strings. This could be recovered back if the value stored in RefList column was a plain list, but if we had there
a RecordList object, the RefList column didn't know how to parse that.

Test Plan: Added test

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4233
This commit is contained in:
Jarosław Sadziński
2024-04-24 11:15:23 +02:00
parent bd07e9c026
commit 34c85757f1
4 changed files with 79 additions and 10 deletions

View File

@@ -13,7 +13,40 @@ describe('ReferenceList', function() {
});
describe('other', function() {
it('allows to delete document with self reference', async function() {
it('fix: doesnt break when table is renamed', async function() {
// There was a bug in this scenario:
// 1. Create a Ref column that targets itself
// 2. Fill it up
// 3. Change it to RefList
// 4. Rename the table
// Previously, this would cause an error, cells were displaying Errors instead of values.
// Create a table with a Ref column that targets itself.
await session.tempNewDoc(cleanup);
await gu.sendActions([
['ModifyColumn', 'Table1', 'B', {type: 'Ref:Table1'}],
['AddRecord', 'Table1', null, {A: 'a', B: 1}],
['AddRecord', 'Table1', null, {A: 'b', B: 2}],
['AddRecord', 'Table1', null, {A: 'c', B: 3}],
]);
await gu.openColumnPanel();
await gu.getCell('B', 1).doClick();
await gu.setRefShowColumn('A');
// Now convert it to RefList.
await gu.setType('Reference List', {apply: true});
// Make sure we see the values.
assert.deepEqual(await gu.getVisibleGridCells('B', [1, 2, 3]), ['a', 'b', 'c']);
// Rename the table using widget in the section.
await gu.renameTable('Table1', 'Table2');
// Make sure we still see the values.
assert.deepEqual(await gu.getVisibleGridCells('B', [1, 2, 3]), ['a', 'b', 'c']);
});
it('fix: allows to delete document with self reference', async function() {
const docId = await session.tempNewDoc(cleanup);
await gu.sendActions([
['AddEmptyTable', 'Table2'],
@@ -39,7 +72,7 @@ describe('ReferenceList', function() {
before(async function() {
await session.tempDoc(cleanup, 'Favorite_Films.grist');
await gu.toggleSidePanel('right');
await gu.toggleSidePanel('right', 'open');
await driver.find(".test-right-tab-pagewidget").click();
await driver.find('.test-config-data').click();
});