|
| 1 | +import CardView from 'devextreme-testcafe-models/cardView'; |
| 2 | +import url from '../../../helpers/getPageUrl'; |
| 3 | +import { createWidget } from '../../../helpers/createWidget'; |
| 4 | + |
| 5 | +fixture.disablePageReloads`CardView - Editing` |
| 6 | + .page(url(__dirname, '../../container.html')); |
| 7 | + |
| 8 | +const CARD_VIEW_SELECTOR = '#container'; |
| 9 | + |
| 10 | +const config = { |
| 11 | + columns: [ |
| 12 | + { dataField: 'id', caption: 'ID' }, |
| 13 | + { dataField: 'title', caption: 'Task Title' }, |
| 14 | + { dataField: 'status', caption: 'Status' }, |
| 15 | + ], |
| 16 | + dataSource: [], |
| 17 | + keyExpr: 'id', |
| 18 | + editing: { |
| 19 | + allowAdding: true, |
| 20 | + form: { |
| 21 | + items: ['id', 'title', 'status'], |
| 22 | + }, |
| 23 | + }, |
| 24 | + onInitNewCard(e) { |
| 25 | + e.data.id = 10; |
| 26 | + e.data.status = 'Not Started'; |
| 27 | + e.data.title = 'New Task'; |
| 28 | + }, |
| 29 | +}; |
| 30 | + |
| 31 | +test('should show default values in popup fields after onInitNewCard', async (t) => { |
| 32 | + const cardView = new CardView(CARD_VIEW_SELECTOR); |
| 33 | + await cardView.isReady(); |
| 34 | + |
| 35 | + await t.click(cardView.getToolbar().getAddButton().element); |
| 36 | + await cardView.isReady(); |
| 37 | + |
| 38 | + const popup = cardView.getEditingPopup(); |
| 39 | + |
| 40 | + const idInput = popup.find('input[name="id"]'); |
| 41 | + const titleInput = popup.find('input[name="title"]'); |
| 42 | + const statusInput = popup.find('input[name="status"]'); |
| 43 | + |
| 44 | + await t.expect(idInput.value).eql('10'); |
| 45 | + await t.expect(titleInput.value).eql('New Task'); |
| 46 | + await t.expect(statusInput.value).eql('Not Started'); |
| 47 | +}).before(async () => createWidget('dxCardView', config)); |
0 commit comments