Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(formula): move range update si #4318

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,61 @@ const TEST_WORKBOOK_DATA_DEMO = (): IWorkbookData => ({
},
name: 'Sheet2',
},
sheet3: {
id: 'sheet3',
cellData: {
0: {
0: {
v: 1,
t: 2,
},
1: {
f: '=A1',
v: 1,
t: 2,
},
},
1: {
0: {
v: 2,
t: 2,
},
1: {
f: '=A2',
si: 'W8Hdfc',
v: 2,
t: 2,
},
},
2: {
0: {
v: 3,
t: 2,
},
1: {
si: 'W8Hdfc',
v: 3,
t: 2,
},
},
3: {
0: {
v: 4,
t: 2,
},
1: {
si: 'W8Hdfc',
v: 4,
t: 2,
},
},
},
name: 'Sheet3',
},
},
locale: LocaleType.ZH_CN,
name: '',
sheetOrder: ['sheet1', 'sheet2'],
sheetOrder: ['sheet1', 'sheet2', 'sheet3'],
styles: {},
resources: [
{
Expand Down Expand Up @@ -467,6 +518,44 @@ describe('Test update formula ', () => {
expect(valuesRedo).toStrictEqual([[{}, { f: '=SUM(A19)', t: 2, v: 1 }], [{}, { f: '=SUM(A20)', si: 'id1', t: 2, v: 2 }], [{}, { si: 'id1', t: 2, v: 3 }]]);
});

it('Move range, update reference, release si', async () => {
const workbook = get(IUniverInstanceService).getUnit<Workbook>('test');
const sheet3 = workbook?.getSheetBySheetId('sheet3');
if (!sheet3) {
throw new Error('sheet3 not found');
}
workbook?.setActiveSheet(sheet3);

const params: IMoveRangeCommandParams = {
fromRange: {
startRow: 0,
startColumn: 1,
endRow: 3,
endColumn: 1,
rangeType: 0,
},
toRange: {
startRow: 2,
startColumn: 1,
endRow: 5,
endColumn: 1,
rangeType: 0,
},
};

expect(await commandService.executeCommand(MoveRangeCommand.id, params)).toBeTruthy();
const values = getValues(0, 1, 5, 1);
expect(values).toStrictEqual([[{}], [{}], [{ f: '=A1', v: 1 }], [{ f: '=A2', v: 2 }], [{ f: '=A3', v: 3 }], [{ f: '=A4', v: 4 }]]);

expect(await commandService.executeCommand(UndoCommand.id)).toBeTruthy();
const valuesUndo = getValues(0, 1, 5, 1);
expect(valuesUndo).toStrictEqual([[{ f: '=A1', v: 1 }], [{ f: '=A2', v: 2 }], [{ f: '=A3', v: 3 }], [{ f: '=A4', v: 4 }], [{}], [{}]]);

expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();
const valuesRedo = getValues(0, 1, 5, 1);
expect(valuesRedo).toStrictEqual([[{}], [{}], [{ f: '=A1', v: 1 }], [{ f: '=A2', v: 2 }], [{ f: '=A3', v: 3 }], [{ f: '=A4', v: 4 }]]);
});

it('Move rows, update reference', async () => {
const selectionManager = get(SheetsSelectionsService);

Expand Down
Loading