Skip to content

Commit

Permalink
Use the same test sequence for NumberInput and BigNumberInput
Browse files Browse the repository at this point in the history
Signed-off-by: George <bulakh.96@gmail.com>
  • Loading branch information
Karakatiza666 committed May 22, 2024
1 parent c620e98 commit 55024c5
Showing 1 changed file with 7 additions and 40 deletions.
47 changes: 7 additions & 40 deletions web-console/src/lib/components/input/NumberInput.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { BigNumberInput } from '$lib/components/input/BigNumberInput'
import { NumberInput } from '$lib/components/input/NumberInput'

import { expect, test } from '@playwright/experimental-ct-react'
import { expect, MountResult, test } from '@playwright/experimental-ct-react'

test('NumberInput: Test key strokes', async ({ mount }) => {
const input = await mount(<NumberInput min={100} max={10000} sx={{ width: 200 }}></NumberInput>)
const testKeyStrokes = async (input: MountResult) => {
await input.click()
await input.pressSequentially('10')
await expect(input).toHaveScreenshot('1-1.png')
Expand Down Expand Up @@ -41,44 +40,12 @@ test('NumberInput: Test key strokes', async ({ mount }) => {
await input.press('Home')
await input.press('6')
await expect(input).toHaveScreenshot('1-12.png')
}

test('NumberInput: Test key strokes', async ({ mount }) => {
await testKeyStrokes(await mount(<NumberInput min={100} max={10000} sx={{ width: 200 }}></NumberInput>))
})

test('BigNumberInput: Test key strokes', async ({ mount }) => {
const input = await mount(<BigNumberInput min={100} max={10000} sx={{ width: 200 }}></BigNumberInput>)
await input.click()
await input.pressSequentially('10')
await expect(input).toHaveScreenshot('1-1.png')
await input.pressSequentially('0')
await expect(input).toHaveScreenshot('1-2.png')
await input.pressSequentially('00')
await expect(input).toHaveScreenshot('1-3.png')
await input.press('Backspace')
await input.press('Delete')
await input.press('ArrowLeft')
await input.press('Delete')
await expect(input).toHaveScreenshot('1-4.png')
await input.press('Control+A')
await input.press('Delete')
await input.pressSequentially('98')
await expect(input).toHaveScreenshot('1-5.png')
await input.press('Shift+ArrowLeft')
await input.press('Control+X')
await expect(input).toHaveScreenshot('1-6.png')
await input.press('Period')
await input.press('Period')
await expect(input).toHaveScreenshot('1-7.png')
await input.press('Control+V')
await input.press('Period')
await expect(input).toHaveScreenshot('1-8.png')
await input.press('4')
await expect(input).toHaveScreenshot('1-9.png')
await input.press('ArrowLeft')
await input.press('Control+V')
await expect(input).toHaveScreenshot('1-10.png')
await input.press('ArrowLeft')
await input.press('7')
await expect(input).toHaveScreenshot('1-11.png')
await input.press('Home')
await input.press('6')
await expect(input).toHaveScreenshot('1-12.png')
await testKeyStrokes(await mount(<BigNumberInput min={100} max={10000} sx={{ width: 200 }}></BigNumberInput>))
})

0 comments on commit 55024c5

Please sign in to comment.