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: set style should not clear p #2553

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: add test
  • Loading branch information
ybzky committed Jun 19, 2024
commit e78868c42e2da82e4fdb1aba63be2245b7a9d355
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,143 @@ describe('Test set range values commands', () => {
expect(await commandService.executeCommand(RedoCommand.id)).toBeTruthy();
expect(getValues(1, 1, 1, 4)).toStrictEqual([[{ s: 's2' }, null, null, { s: 's3' }]]);
});

it('paste value when origin cell has rich text', async () => {
function getParams() {
const richTextDemo: IDocumentData = {
id: 'd',
body: {
dataStream: 'Instructions: ①Project division - Fill in the specific division of labor after the project is disassembled: ②Responsible Person - Enter the responsible person\'s name here: ③Date-The specific execution time of the project (detailed to the date of a certain month), and the gray color block marks the planned real-time time of the division of labor of the project (for example, the specific execution time of [regional scene model arrangement and construction] is the 2 days marked in gray. \r\n',
textRuns: [
{
st: 0,
ed: 488,
ts: {
cl: {
rgb: 'rgb(92,92,92)',
},
},
},
],
paragraphs: [
{
startIndex: 489,
paragraphStyle: {
spaceAbove: 10,
lineSpacing: 1.2,
},
},
],
},
documentStyle: {
pageSize: {
width: Number.POSITIVE_INFINITY,
height: Number.POSITIVE_INFINITY,
},
marginTop: 0,
marginBottom: 0,
marginRight: 2,
marginLeft: 2,
},
};

const params: ISetRangeValuesCommandParams = {
value: {
p: richTextDemo,
v: 'a1',
t: CellValueType.STRING,
},
};

return params;
}

expect(await commandService.executeCommand(SetRangeValuesCommand.id, getParams())).toBeTruthy();
expect(getValue()).toStrictEqual(getParams().value);
expect(await commandService.executeCommand(SetRangeValuesMutation.id, {
unitId: 'test',
subUnitId: 'sheet1',
cellValue: {
0: {
0: {
v: 'hello',
s: null,
},
},
},
})).toBeTruthy();
expect(getValue()?.p).toBeFalsy();
});

it('set styles when origin cell has rich text', async () => {
function getParams() {
const richTextDemo: IDocumentData = {
id: 'd',
body: {
dataStream: 'Instructions: ①Project division - Fill in the specific division of labor after the project is disassembled: ②Responsible Person - Enter the responsible person\'s name here: ③Date-The specific execution time of the project (detailed to the date of a certain month), and the gray color block marks the planned real-time time of the division of labor of the project (for example, the specific execution time of [regional scene model arrangement and construction] is the 2 days marked in gray. \r\n',
textRuns: [
{
st: 0,
ed: 488,
ts: {
cl: {
rgb: 'rgb(92,92,92)',
},
},
},
],
paragraphs: [
{
startIndex: 489,
paragraphStyle: {
spaceAbove: 10,
lineSpacing: 1.2,
},
},
],
},
documentStyle: {
pageSize: {
width: Number.POSITIVE_INFINITY,
height: Number.POSITIVE_INFINITY,
},
marginTop: 0,
marginBottom: 0,
marginRight: 2,
marginLeft: 2,
},
};

const params: ISetRangeValuesCommandParams = {
value: {
p: richTextDemo,
v: 'a1',
t: CellValueType.STRING,
},
};

return params;
}

expect(await commandService.executeCommand(SetRangeValuesCommand.id, getParams())).toBeTruthy();
expect(getValue()).toStrictEqual(getParams().value);
expect(await commandService.executeCommand(SetRangeValuesMutation.id, {
unitId: 'test',
subUnitId: 'sheet1',
cellValue: {
0: {
0: {
s: {
bg: {
rgb: '#232323',
},
},
},
},
},
})).toBeTruthy();
expect(getValue()?.p).toBeTruthy();
});
});

describe('fault situations', () => {
Expand Down
Loading