From cfe86bef93575378616ee2a559f1b28e1c85604c Mon Sep 17 00:00:00 2001 From: Fran Lopez Date: Fri, 11 Oct 2024 12:47:07 +0200 Subject: [PATCH] test: add test to delete last character using Backspace in input component --- e2e/inline-edit/simple-inline-edit.spec.ts | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/e2e/inline-edit/simple-inline-edit.spec.ts b/e2e/inline-edit/simple-inline-edit.spec.ts index b6d47cd6..b29d1a14 100644 --- a/e2e/inline-edit/simple-inline-edit.spec.ts +++ b/e2e/inline-edit/simple-inline-edit.spec.ts @@ -27,3 +27,37 @@ test('can add input component to canvas and edit', async ({ page }) => { ); expect(textShape).toBeDefined(); }); + +test('can add and edit input, and delete last letter', async ({ page }) => { + await page.goto(''); + const component = page.getByAltText('Input', { exact: true }); + + const position = await getLocatorPosition(component); + const targetPosition = { + x: position.x + 500, + y: position.y - 240, + }; + await dragAndDrop(page, position, targetPosition); + await page.mouse.dblclick(targetPosition.x, targetPosition.y); + + const input = page.getByRole('textbox').first(); + const inputValue = await input.getAttribute('value'); + expect(inputValue).toEqual('Placeholder'); + + const textContent = 'user'; + await input.fill(textContent); + + await page.keyboard.press('Backspace'); + + const updatedInputValue = await input.inputValue(); + expect(updatedInputValue).toEqual('use'); + + await page.keyboard.press('Enter'); + + const inputShape = (await getByShapeType(page, 'input')) as Group; + expect(inputShape).toBeDefined(); + const textShape = inputShape.children.find( + child => child.attrs.text === 'use' + ); + expect(textShape).toBeDefined(); +});