Skip to content

Commit

Permalink
fix(e2e): get sheet onSteady
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Dec 3, 2024
1 parent 2097cf3 commit 4225bee
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 77 deletions.
166 changes: 89 additions & 77 deletions e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,63 +244,69 @@ test('diff set force string cell', async () => {
await page.waitForTimeout(2000);

await page.evaluate(async () => {
const activeWorkbook = window.univerAPI.getActiveWorkbook();
const activeSheet = activeWorkbook.getActiveSheet();

const sheetId = activeSheet.getSheetId();
const unitId = activeWorkbook.getId();

await window.univerAPI.executeCommand('sheet.operation.set-selections', {
selections: [
{
range: {
startRow: 0,
startColumn: 7,
endRow: 0,
endColumn: 7,
rangeType: 0,
unitId,
sheetId,
},
primary: {
actualRow: 0,
actualColumn: 7,
isMerged: false,
isMergedMainCell: false,
startRow: 0,
startColumn: 7,
endRow: 0,
endColumn: 7,
},
style: {
strokeWidth: 1,
stroke: '#274fee',
fill: 'rgba(39,79,238,0.07)',
widgets: {},
widgetSize: 6,
widgetStrokeWidth: 1,
widgetStroke: '#ffffff',
autofillSize: 6,
autofillStrokeWidth: 1,
autofillStroke: '#ffffff',
rowHeaderFill: 'rgba(39,79,238,0.07)',
rowHeaderStroke: '#274fee',
rowHeaderStrokeWidth: 1,
columnHeaderFill: 'rgba(39,79,238,0.07)',
columnHeaderStroke: '#274fee',
columnHeaderStrokeWidth: 1,
expandCornerSize: 40,
},
},
],
unitId,
subUnitId: sheetId,
type: 2,
});
return new Promise((resolve) => {
window.univerAPI.getHooks().onSteady(async () => {
const activeWorkbook = window.univerAPI.getActiveWorkbook();
const activeSheet = activeWorkbook.getActiveSheet();

const sheetId = activeSheet.getSheetId();
const unitId = activeWorkbook.getId();

await window.univerAPI.executeCommand('sheet.operation.set-selections', {
selections: [
{
range: {
startRow: 0,
startColumn: 7,
endRow: 0,
endColumn: 7,
rangeType: 0,
unitId,
sheetId,
},
primary: {
actualRow: 0,
actualColumn: 7,
isMerged: false,
isMergedMainCell: false,
startRow: 0,
startColumn: 7,
endRow: 0,
endColumn: 7,
},
style: {
strokeWidth: 1,
stroke: '#274fee',
fill: 'rgba(39,79,238,0.07)',
widgets: {},
widgetSize: 6,
widgetStrokeWidth: 1,
widgetStroke: '#ffffff',
autofillSize: 6,
autofillStrokeWidth: 1,
autofillStroke: '#ffffff',
rowHeaderFill: 'rgba(39,79,238,0.07)',
rowHeaderStroke: '#274fee',
rowHeaderStrokeWidth: 1,
columnHeaderFill: 'rgba(39,79,238,0.07)',
columnHeaderStroke: '#274fee',
columnHeaderStrokeWidth: 1,
expandCornerSize: 40,
},
},
],
unitId,
subUnitId: sheetId,
type: 2,
});

activeWorkbook.startEditing();
await window.univerAPI.getActiveDocument().appendText("'1");
activeWorkbook.endEditing(true);

activeWorkbook.startEditing();
await window.univerAPI.getActiveDocument().appendText("'1");
activeWorkbook.endEditing(true);
resolve(1);
});
});
});

const filename = generateSnapshotName('set-force-string-cell');
Expand All @@ -324,30 +330,36 @@ test('diff set text format number cell', async () => {
await page.waitForTimeout(2000);

await page.evaluate(async () => {
await window.univerAPI.executeCommand('sheet.command.numfmt.set.numfmt', {
values: [
{
row: 0,
col: 7,
pattern: '@@@',
type: 'text',
},
],
});
return new Promise((resolve) => {
window.univerAPI.getHooks().onSteady(async () => {
await window.univerAPI.executeCommand('sheet.command.numfmt.set.numfmt', {
values: [
{
row: 0,
col: 7,
pattern: '@@@',
type: 'text',
},
],
});

await window.univerAPI.getActiveWorkbook().getActiveSheet().getRange('H1').setValue(2);
await window.univerAPI.getActiveWorkbook().getActiveSheet().getRange('H1').setValue(2);

await window.univerAPI.getActiveWorkbook().getActiveSheet().getRange('I1').setValue(3);
await window.univerAPI.getActiveWorkbook().getActiveSheet().getRange('I1').setValue(3);

await window.univerAPI.executeCommand('sheet.command.numfmt.set.numfmt', {
values: [
{
row: 0,
col: 8,
pattern: '@@@',
type: 'text',
},
],
await window.univerAPI.executeCommand('sheet.command.numfmt.set.numfmt', {
values: [
{
row: 0,
col: 8,
pattern: '@@@',
type: 'text',
},
],
});

resolve(1);
});
});
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4225bee

Please sign in to comment.