From e848ab7853c5e32cb7194a2f853e4984f2c1e14d Mon Sep 17 00:00:00 2001 From: web-padawan Date: Tue, 24 Sep 2024 15:43:25 +0300 Subject: [PATCH] test: extract common test setup to beforeEach block --- .../grid-pro-custom-editor.test.js | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/test/integration/grid-pro-custom-editor.test.js b/test/integration/grid-pro-custom-editor.test.js index 7d00474a92..abfc35bead 100644 --- a/test/integration/grid-pro-custom-editor.test.js +++ b/test/integration/grid-pro-custom-editor.test.js @@ -63,12 +63,16 @@ describe('grid-pro custom editor', () => { }); describe('date-picker', () => { - it('should apply the updated date to the cell when exiting on Tab', async () => { - const cell = getContainerCell(grid.$.items, 0, 2); + let cell; + + beforeEach(async () => { + cell = getContainerCell(grid.$.items, 0, 2); cell.focus(); await sendKeys({ press: 'Enter' }); + }); + it('should apply the updated date to the cell when exiting on Tab', async () => { await sendKeys({ type: '1/12/1984' }); await sendKeys({ press: 'Tab' }); @@ -76,11 +80,6 @@ describe('grid-pro custom editor', () => { }); it('should apply the updated date to the cell when exiting on Enter', async () => { - const cell = getContainerCell(grid.$.items, 0, 2); - cell.focus(); - - await sendKeys({ press: 'Enter' }); - await sendKeys({ type: '1/12/1984' }); await sendKeys({ press: 'Enter' }); @@ -88,11 +87,7 @@ describe('grid-pro custom editor', () => { }); it('should not stop editing on input click when focus is in the overlay', async () => { - const cell = getContainerCell(grid.$.items, 0, 2); - cell.focus(); - - await sendKeys({ press: 'Enter' }); - + // Open the overlay await sendKeys({ press: 'ArrowDown' }); const { x, y } = middleOfNode(cell._content.querySelector('input')); @@ -102,11 +97,6 @@ describe('grid-pro custom editor', () => { }); it('should stop editing and update value when closing on outside click', async () => { - const cell = getContainerCell(grid.$.items, 0, 2); - cell.focus(); - - await sendKeys({ press: 'Enter' }); - // Open the overlay await sendKeys({ press: 'ArrowDown' }); await waitForOverlayRender();