-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c55d70
commit c62a6d1
Showing
2 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
79 changes: 74 additions & 5 deletions
79
packages/ketchup/src/components/kup-input-panel/kup-input-panel.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,85 @@ | ||
import { newE2EPage } from '@stencil/core/testing'; | ||
|
||
describe('kup-input-panel', () => { | ||
it('it runs', () => { | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
//TODO: riparti da qui | ||
it('renders', async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent('<kup-input-panel></kup-input-panel>'); | ||
const element = await page.find('kup-input-panel'); | ||
expect(element).toHaveClass('hydrated'); | ||
}); | ||
|
||
it('renders 2 text field with labels', async () => { | ||
const page = await newE2EPage(); | ||
|
||
await page.setContent('<kup-input-panel></kup-input-panel>'); | ||
const inputPanel = await page.find('kup-input-panel'); | ||
const data = { | ||
columns: [ | ||
{ | ||
name: 'NAM', | ||
title: 'Name', | ||
visible: true, | ||
}, | ||
{ | ||
name: 'SUR', | ||
title: 'Surname', | ||
visible: true, | ||
}, | ||
], | ||
rows: [ | ||
{ | ||
cells: { | ||
NAM: { | ||
value: '', | ||
editable: true, | ||
shape: 'ITX', | ||
}, | ||
SUR: { | ||
value: '', | ||
editable: true, | ||
shape: 'ITX', | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
inputPanel.setProperty('data', data); | ||
|
||
await page.waitForChanges(); | ||
|
||
const inputPanelContent = await page.find( | ||
'kup-input-panel >>> form.input-panel' | ||
); | ||
expect(inputPanelContent).not.toBeNull(); | ||
|
||
const textFields = await inputPanelContent.findAll( | ||
'.f-cell.string-cell .f-text-field' | ||
); | ||
expect(textFields).toHaveLength(data.columns.length); | ||
|
||
// TODO valutare questo for utilizzato per mantenere l'asincronicità | ||
for (const [i, textField] of textFields.entries()) { | ||
const label = await textField.find('label'); | ||
expect(label).not.toBeNull(); | ||
expect(label).toHaveClass('mdc-floating-label'); | ||
expect(label).toEqualText(data.columns[i].title); | ||
|
||
const input = await textField.find('input'); | ||
expect(label).not.toBeNull(); | ||
const value = await input.getProperty('value'); | ||
expect(value).toBe(''); | ||
|
||
await input.press('KeyS'); | ||
await input.press('KeyT'); | ||
await input.press('KeyR'); | ||
await input.press('KeyI'); | ||
await input.press('KeyN'); | ||
await input.press('KeyG'); | ||
|
||
const updatedValue = await input.getProperty('value'); | ||
expect(updatedValue).toBe('string'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters