diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts index bc6c32dbde6..0402e87df67 100644 --- a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts +++ b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts @@ -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'); @@ -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); + }); }); }); diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-force-string-cell-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-force-string-cell-chromium-linux.png index 1f72429710e..22f9a185e9f 100644 Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-force-string-cell-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-force-string-cell-chromium-linux.png differ diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-text-format-number-cell-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-text-format-number-cell-chromium-linux.png index a074cbd8598..faadd5d33f7 100644 Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-text-format-number-cell-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/set-text-format-number-cell-chromium-linux.png differ