|
| 1 | +import DataGrid from 'devextreme-testcafe-models/dataGrid'; |
| 2 | +import url from '../../../../helpers/getPageUrl'; |
| 3 | +import { createWidget } from '../../../../helpers/createWidget'; |
| 4 | + |
| 5 | +fixture.disablePageReloads`Ai Column - Sticky columns.Functional` |
| 6 | + .page(url(__dirname, '../../../container.html')); |
| 7 | + |
| 8 | +const DATA_GRID_SELECTOR = '#container'; |
| 9 | + |
| 10 | +test('The AI column should not be fixed when the columnFixing.enabled option is true', async (t) => { |
| 11 | + // arrange, act |
| 12 | + const dataGrid = new DataGrid(DATA_GRID_SELECTOR); |
| 13 | + |
| 14 | + await t.expect(dataGrid.isReady()).ok(); |
| 15 | + |
| 16 | + const aiHeader = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(3); |
| 17 | + |
| 18 | + // assert |
| 19 | + await t.expect(aiHeader.element.textContent).eql('AI Column'); |
| 20 | + await t.expect(aiHeader.isSticky()).notOk(); |
| 21 | +}).before(async () => createWidget('dxDataGrid', { |
| 22 | + dataSource: [ |
| 23 | + { id: 1, name: 'Name 1', value: 10 }, |
| 24 | + { id: 2, name: 'Name 2', value: 20 }, |
| 25 | + { id: 3, name: 'Name 3', value: 30 }, |
| 26 | + ], |
| 27 | + width: 600, |
| 28 | + columnWidth: 200, |
| 29 | + columnFixing: { |
| 30 | + enabled: true, |
| 31 | + }, |
| 32 | + columns: [ |
| 33 | + { dataField: 'id', caption: 'ID' }, |
| 34 | + { dataField: 'name', caption: 'Name' }, |
| 35 | + { dataField: 'value', caption: 'Value' }, |
| 36 | + { |
| 37 | + type: 'ai', |
| 38 | + caption: 'AI Column', |
| 39 | + name: 'myAiColumn', |
| 40 | + }, |
| 41 | + ], |
| 42 | +})); |
| 43 | + |
| 44 | +test('The AI column should be fixed when its fixed option is true', async (t) => { |
| 45 | + // arrange, act |
| 46 | + const dataGrid = new DataGrid(DATA_GRID_SELECTOR); |
| 47 | + |
| 48 | + await t.expect(dataGrid.isReady()).ok(); |
| 49 | + |
| 50 | + const aiHeader = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(0); |
| 51 | + |
| 52 | + // assert |
| 53 | + await t.expect(aiHeader.element.textContent).eql('AI Column'); |
| 54 | + await t.expect(aiHeader.isSticky('left')).ok(); |
| 55 | +}).before(async () => createWidget('dxDataGrid', { |
| 56 | + dataSource: [ |
| 57 | + { id: 1, name: 'Name 1', value: 10 }, |
| 58 | + { id: 2, name: 'Name 2', value: 20 }, |
| 59 | + { id: 3, name: 'Name 3', value: 30 }, |
| 60 | + ], |
| 61 | + width: 600, |
| 62 | + columnWidth: 200, |
| 63 | + columns: [ |
| 64 | + { dataField: 'id', caption: 'ID' }, |
| 65 | + { dataField: 'name', caption: 'Name' }, |
| 66 | + { dataField: 'value', caption: 'Value' }, |
| 67 | + { |
| 68 | + type: 'ai', |
| 69 | + caption: 'AI Column', |
| 70 | + fixed: true, |
| 71 | + name: 'myAiColumn', |
| 72 | + }, |
| 73 | + ], |
| 74 | +})); |
| 75 | + |
| 76 | +test('The AI column should be fixed when its fixed option is true and its fixed position is set to right', async (t) => { |
| 77 | + // arrange, act |
| 78 | + const dataGrid = new DataGrid(DATA_GRID_SELECTOR); |
| 79 | + |
| 80 | + await t.expect(dataGrid.isReady()).ok(); |
| 81 | + |
| 82 | + const aiHeader = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(3); |
| 83 | + |
| 84 | + // assert |
| 85 | + await t.expect(aiHeader.element.textContent).eql('AI Column'); |
| 86 | + await t.expect(aiHeader.isSticky('right')).ok(); |
| 87 | +}).before(async () => createWidget('dxDataGrid', { |
| 88 | + dataSource: [ |
| 89 | + { id: 1, name: 'Name 1', value: 10 }, |
| 90 | + { id: 2, name: 'Name 2', value: 20 }, |
| 91 | + { id: 3, name: 'Name 3', value: 30 }, |
| 92 | + ], |
| 93 | + width: 600, |
| 94 | + columnWidth: 200, |
| 95 | + columns: [ |
| 96 | + { dataField: 'id', caption: 'ID' }, |
| 97 | + { dataField: 'name', caption: 'Name' }, |
| 98 | + { dataField: 'value', caption: 'Value' }, |
| 99 | + { |
| 100 | + type: 'ai', |
| 101 | + caption: 'AI Column', |
| 102 | + fixed: true, |
| 103 | + fixedPosition: 'right', |
| 104 | + name: 'myAiColumn', |
| 105 | + }, |
| 106 | + ], |
| 107 | +})); |
| 108 | + |
| 109 | +test('The AI column should be fixed when its fixed option is true and its fixed position is set to sticky', async (t) => { |
| 110 | + // arrange, act |
| 111 | + const dataGrid = new DataGrid(DATA_GRID_SELECTOR); |
| 112 | + |
| 113 | + await t.expect(dataGrid.isReady()).ok(); |
| 114 | + |
| 115 | + const aiHeader = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(1); |
| 116 | + |
| 117 | + // assert |
| 118 | + await t.expect(aiHeader.element.textContent).eql('AI Column'); |
| 119 | + await t.expect(aiHeader.isSticky('sticky')).ok(); |
| 120 | +}).before(async () => createWidget('dxDataGrid', { |
| 121 | + dataSource: [ |
| 122 | + { id: 1, name: 'Name 1', value: 10 }, |
| 123 | + { id: 2, name: 'Name 2', value: 20 }, |
| 124 | + { id: 3, name: 'Name 3', value: 30 }, |
| 125 | + ], |
| 126 | + width: 600, |
| 127 | + columnWidth: 200, |
| 128 | + columns: [ |
| 129 | + { dataField: 'id', caption: 'ID' }, |
| 130 | + { |
| 131 | + type: 'ai', |
| 132 | + caption: 'AI Column', |
| 133 | + fixed: true, |
| 134 | + fixedPosition: 'sticky', |
| 135 | + name: 'myAiColumn', |
| 136 | + }, |
| 137 | + { dataField: 'name', caption: 'Name' }, |
| 138 | + { dataField: 'value', caption: 'Value' }, |
| 139 | + ], |
| 140 | +})); |
| 141 | + |
| 142 | +test('Fix an AI column using the context menu', async (t) => { |
| 143 | + // arrange |
| 144 | + const dataGrid = new DataGrid(DATA_GRID_SELECTOR); |
| 145 | + const contextMenu = dataGrid.getContextMenu(); |
| 146 | + |
| 147 | + await t.expect(dataGrid.isReady()).ok(); |
| 148 | + |
| 149 | + const aiHeader = dataGrid.getHeaders().getHeaderRow(0).getHeaderCell(0); |
| 150 | + |
| 151 | + // assert |
| 152 | + await t |
| 153 | + .expect(aiHeader.element.textContent).eql('AI Column') |
| 154 | + .expect(aiHeader.isSticky('left')).notOk(); |
| 155 | + |
| 156 | + // act |
| 157 | + await t |
| 158 | + .rightClick(aiHeader.element) |
| 159 | + .click(contextMenu.getItemByText('Set Fixed Position')) |
| 160 | + .click(contextMenu.getItemByText('Left')); |
| 161 | + |
| 162 | + // assert |
| 163 | + await t.expect(aiHeader.element.textContent).eql('AI Column'); |
| 164 | + await t.expect(aiHeader.isSticky('left')).ok(); |
| 165 | +}).before(async () => createWidget('dxDataGrid', { |
| 166 | + dataSource: [ |
| 167 | + { id: 1, name: 'Name 1', value: 10 }, |
| 168 | + { id: 2, name: 'Name 2', value: 20 }, |
| 169 | + { id: 3, name: 'Name 3', value: 30 }, |
| 170 | + ], |
| 171 | + width: 600, |
| 172 | + columnWidth: 200, |
| 173 | + columnFixing: { |
| 174 | + enabled: true, |
| 175 | + }, |
| 176 | + columns: [ |
| 177 | + { |
| 178 | + type: 'ai', |
| 179 | + caption: 'AI Column', |
| 180 | + name: 'myAiColumn', |
| 181 | + }, |
| 182 | + { dataField: 'id', caption: 'ID' }, |
| 183 | + { dataField: 'name', caption: 'Name' }, |
| 184 | + { dataField: 'value', caption: 'Value' }, |
| 185 | + ], |
| 186 | +})); |
0 commit comments