|
| 1 | +/* eslint-disable no-restricted-syntax */ |
| 2 | +import { createScreenshotsComparer } from 'devextreme-screenshot-comparer'; |
| 3 | +import Guid from 'devextreme/core/guid'; |
| 4 | +import { Selector } from 'testcafe'; |
| 5 | +import { testScreenshot } from '../../helpers/themeUtils'; |
| 6 | +import url from '../../helpers/getPageUrl'; |
| 7 | +import { createWidget } from '../../helpers/createWidget'; |
| 8 | +import { appendElementTo } from '../../helpers/domUtils'; |
| 9 | + |
| 10 | +const TOOLBAR_ITEM_BUTTON = '.dx-button'; |
| 11 | + |
| 12 | +fixture.disablePageReloads`Gantt` |
| 13 | + .page(url(__dirname, '../container.html')); |
| 14 | + |
| 15 | +const data = { |
| 16 | + tasks: [{ |
| 17 | + id: 1, |
| 18 | + parentId: 0, |
| 19 | + title: 'Software Development', |
| 20 | + start: new Date('2019-02-21T05:00:00.000Z'), |
| 21 | + end: new Date('2019-07-04T12:00:00.000Z'), |
| 22 | + progress: 31, |
| 23 | + color: 'red', |
| 24 | + }, { |
| 25 | + id: 2, |
| 26 | + parentId: 1, |
| 27 | + title: 'Scope', |
| 28 | + start: new Date('2019-02-21T05:00:00.000Z'), |
| 29 | + end: new Date('2019-02-26T09:00:00.000Z'), |
| 30 | + progress: 60, |
| 31 | + }, { |
| 32 | + id: 3, |
| 33 | + parentId: 2, |
| 34 | + title: 'Determine project scope', |
| 35 | + start: new Date('2019-02-21T05:00:00.000Z'), |
| 36 | + end: new Date('2019-02-21T09:00:00.000Z'), |
| 37 | + progress: 100, |
| 38 | + }, { |
| 39 | + id: 4, |
| 40 | + parentId: 2, |
| 41 | + title: 'Secure project sponsorship', |
| 42 | + start: new Date('2019-02-21T10:00:00.000Z'), |
| 43 | + end: new Date('2019-02-22T09:00:00.000Z'), |
| 44 | + progress: 100, |
| 45 | + }, { |
| 46 | + id: 5, |
| 47 | + parentId: 2, |
| 48 | + title: 'Define preliminary resources', |
| 49 | + start: new Date('2019-02-22T10:00:00.000Z'), |
| 50 | + end: new Date('2019-02-25T09:00:00.000Z'), |
| 51 | + progress: 60, |
| 52 | + }, { |
| 53 | + id: 6, |
| 54 | + parentId: 2, |
| 55 | + title: 'Secure core resources', |
| 56 | + start: new Date('2019-02-25T10:00:00.000Z'), |
| 57 | + end: new Date('2019-02-26T09:00:00.000Z'), |
| 58 | + progress: 0, |
| 59 | + }, { |
| 60 | + id: 7, |
| 61 | + parentId: 2, |
| 62 | + title: 'Scope complete', |
| 63 | + start: new Date('2019-02-26T09:00:00.000Z'), |
| 64 | + end: new Date('2019-02-26T09:00:00.000Z'), |
| 65 | + progress: 0, |
| 66 | + }], |
| 67 | + |
| 68 | + dependencies: [{ |
| 69 | + id: 0, |
| 70 | + predecessorId: 1, |
| 71 | + successorId: 2, |
| 72 | + type: 0, |
| 73 | + }, { |
| 74 | + id: 1, |
| 75 | + predecessorId: 2, |
| 76 | + successorId: 3, |
| 77 | + type: 0, |
| 78 | + }, { |
| 79 | + id: 2, |
| 80 | + predecessorId: 3, |
| 81 | + successorId: 4, |
| 82 | + type: 0, |
| 83 | + }, { |
| 84 | + id: 3, |
| 85 | + predecessorId: 4, |
| 86 | + successorId: 5, |
| 87 | + type: 0, |
| 88 | + }, { |
| 89 | + id: 4, |
| 90 | + predecessorId: 5, |
| 91 | + successorId: 6, |
| 92 | + type: 0, |
| 93 | + }, { |
| 94 | + id: 5, |
| 95 | + predecessorId: 6, |
| 96 | + successorId: 7, |
| 97 | + type: 0, |
| 98 | + }], |
| 99 | + |
| 100 | + resources: [{ |
| 101 | + id: 1, text: 'Management', |
| 102 | + }, { |
| 103 | + id: 2, text: 'Project Manager', |
| 104 | + }, { |
| 105 | + id: 3, text: 'Deployment Team', |
| 106 | + }], |
| 107 | + |
| 108 | + resourceAssignments: [{ |
| 109 | + id: 0, taskId: 3, resourceId: 1, |
| 110 | + }, { |
| 111 | + id: 1, taskId: 4, resourceId: 1, |
| 112 | + }, { |
| 113 | + id: 2, taskId: 5, resourceId: 2, |
| 114 | + }, { |
| 115 | + id: 3, taskId: 6, resourceId: 2, |
| 116 | + }, { |
| 117 | + id: 4, taskId: 6, resourceId: 3, |
| 118 | + }], |
| 119 | +}; |
| 120 | + |
| 121 | +test('Gantt - show resources button should not have focus state (T1264485)', async (t) => { |
| 122 | + const { takeScreenshot, compareResults } = createScreenshotsComparer(t); |
| 123 | + await t |
| 124 | + .click(Selector(TOOLBAR_ITEM_BUTTON)); |
| 125 | + await testScreenshot(t, takeScreenshot, 'Gantt show resourced.png', { element: '#container' }); |
| 126 | + await t |
| 127 | + .expect(compareResults.isValid()) |
| 128 | + .ok(compareResults.errorMessages()); |
| 129 | +}).before(async () => { |
| 130 | + const id = `${new Guid()}`; |
| 131 | + await appendElementTo('#container', 'div', id, {}); |
| 132 | + await createWidget('dxGantt', { |
| 133 | + tasks: { dataSource: data.tasks }, |
| 134 | + toolbar: { items: ['showResources'] }, |
| 135 | + dependencies: { dataSource: data.dependencies }, |
| 136 | + resources: { dataSource: data.resources }, |
| 137 | + resourceAssignments: { dataSource: data.resourceAssignments }, |
| 138 | + }, `#${id}`); |
| 139 | +}); |
| 140 | + |
| 141 | +test('Gantt - show dependencies button should not have focus state (T1264485)', async (t) => { |
| 142 | + const { takeScreenshot, compareResults } = createScreenshotsComparer(t); |
| 143 | + await t |
| 144 | + .click(Selector(TOOLBAR_ITEM_BUTTON)); |
| 145 | + await testScreenshot(t, takeScreenshot, 'Gantt show dependencies.png', { element: '#container' }); |
| 146 | + await t |
| 147 | + .expect(compareResults.isValid()) |
| 148 | + .ok(compareResults.errorMessages()); |
| 149 | +}).before(async () => { |
| 150 | + const id = `${new Guid()}`; |
| 151 | + await appendElementTo('#container', 'div', id, {}); |
| 152 | + await createWidget('dxGantt', { |
| 153 | + tasks: { dataSource: data.tasks }, |
| 154 | + toolbar: { items: ['showDependencies'] }, |
| 155 | + dependencies: { dataSource: data.dependencies }, |
| 156 | + resources: { dataSource: data.resources }, |
| 157 | + resourceAssignments: { dataSource: data.resourceAssignments }, |
| 158 | + }, `#${id}`); |
| 159 | +}); |
0 commit comments