@dhis2-ui/transfer 10.16.2 → 10.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -9
- package/src/__e2e__/add_remove-highlighted-options.e2e.stories.js +30 -0
- package/src/__e2e__/common/options.js +90 -0
- package/src/__e2e__/common/stateful-decorator.js +33 -0
- package/src/__e2e__/common.js +0 -0
- package/src/__e2e__/disabled-transfer-buttons.e2e.stories.js +49 -0
- package/src/__e2e__/disabled-transfer-options.e2e.stories.js +21 -0
- package/src/__e2e__/display-order.e2e.stories.js +24 -0
- package/src/__e2e__/filter-options-list.e2e.stories.js +87 -0
- package/src/__e2e__/highlight-range-of-options.e2e.stories.js +52 -0
- package/src/__e2e__/loading_lists.e2e.stories.js +26 -0
- package/src/__e2e__/notify_at_end_of_list.e2e.stories.js +116 -0
- package/src/__e2e__/reorder-with-buttons.e2e.stories.js +35 -0
- package/src/__e2e__/set_unset-highlighted-option.e2e.stories.js +30 -0
- package/src/__e2e__/transferring-items.e2e.stories.js +27 -0
- package/src/__tests__/common.test.js +131 -0
- package/src/__tests__/helper/add-all-selectable-source-options.test.js +46 -0
- package/src/__tests__/helper/add-individual-source-options.test.js +80 -0
- package/src/__tests__/helper/default-filter-callback.test.js +45 -0
- package/src/__tests__/helper/is-reorder-down-disabled.test.js +96 -0
- package/src/__tests__/helper/is-reorder-up-disabled.test.js +96 -0
- package/src/__tests__/helper/move-highlighted-picked-option-down.test.js +111 -0
- package/src/__tests__/helper/move-highlighted-picked-option-to-bottom.test.js +101 -0
- package/src/__tests__/helper/move-highlighted-picked-option-to-top.test.js +101 -0
- package/src/__tests__/helper/move-highlighted-picked-option-up.test.js +111 -0
- package/src/__tests__/helper/remove-all-picked-options.test.js +29 -0
- package/src/__tests__/helper/remove-individual-picked-options.test.js +38 -0
- package/src/__tests__/helper/use-highlighted-option/create-toggle-highlighted-option.test.js +104 -0
- package/src/__tests__/helper/use-highlighted-option/toggle-add.test.js +84 -0
- package/src/__tests__/helper/use-highlighted-option/toggle-range.test.js +150 -0
- package/src/__tests__/helper/use-highlighted-option/toggle-replace.test.js +39 -0
- package/src/__tests__/helper/use-highlighted-option.test.js +41 -0
- package/src/__tests__/reordering-actions.test.js +165 -0
- package/src/__tests__/transfer.test.js +137 -0
- package/src/actions.js +33 -0
- package/src/add-all.js +27 -0
- package/src/add-individual.js +27 -0
- package/src/common/find-option-index.js +9 -0
- package/src/common/get-mode-by-modifier-key.js +35 -0
- package/src/common/index.js +5 -0
- package/src/common/is-option.js +7 -0
- package/src/common/modes.js +11 -0
- package/src/common/remove-option.js +19 -0
- package/src/common/toggle-value.js +18 -0
- package/src/container.js +23 -0
- package/src/end-intersection-detector.js +37 -0
- package/src/features/add_remove-highlighted-options/index.js +92 -0
- package/src/features/add_remove-highlighted-options.feature +41 -0
- package/src/features/common/index.js +8 -0
- package/src/features/disabled-transfer-buttons/index.js +118 -0
- package/src/features/disabled-transfer-buttons.feature +46 -0
- package/src/features/disabled-transfer-options/index.js +182 -0
- package/src/features/disabled-transfer-options.feature +42 -0
- package/src/features/display-order/index.js +205 -0
- package/src/features/display-order.feature +30 -0
- package/src/features/filter-options-list/index.js +133 -0
- package/src/features/filter-options-list.feature +40 -0
- package/src/features/highlight-range-of-options/index.js +336 -0
- package/src/features/highlight-range-of-options.feature +70 -0
- package/src/features/loading_lists/index.js +43 -0
- package/src/features/loading_lists.feature +19 -0
- package/src/features/notify_at_end_of_list/index.js +125 -0
- package/src/features/notify_at_end_of_list.feature +64 -0
- package/src/features/reorder-with-buttons/index.js +181 -0
- package/src/features/reorder-with-buttons.feature +138 -0
- package/src/features/set_unset-highlighted-option/index.js +121 -0
- package/src/features/set_unset-highlighted-option.feature +42 -0
- package/src/features/transferring-items/index.js +375 -0
- package/src/features/transferring-items.feature +44 -0
- package/src/filter.js +38 -0
- package/src/icons.js +194 -0
- package/src/index.js +2 -0
- package/src/left-footer.js +22 -0
- package/src/left-header.js +22 -0
- package/src/left-side.js +34 -0
- package/src/locales/en/translations.json +7 -0
- package/src/locales/index.js +16 -0
- package/src/options-container.js +127 -0
- package/src/remove-all.js +27 -0
- package/src/remove-individual.js +27 -0
- package/src/reordering-actions.js +136 -0
- package/src/right-footer.js +22 -0
- package/src/right-header.js +22 -0
- package/src/right-side.js +33 -0
- package/src/transfer/add-all-selectable-source-options.js +37 -0
- package/src/transfer/add-individual-source-options.js +61 -0
- package/src/transfer/create-double-click-handlers.js +36 -0
- package/src/transfer/default-filter-callback.js +17 -0
- package/src/transfer/get-highlighted-picked-indices.js +26 -0
- package/src/transfer/get-option-click-handlers.js +19 -0
- package/src/transfer/index.js +17 -0
- package/src/transfer/is-reorder-down-disabled.js +34 -0
- package/src/transfer/is-reorder-up-disabled.js +30 -0
- package/src/transfer/move-highlighted-picked-option-down.js +54 -0
- package/src/transfer/move-highlighted-picked-option-to-bottom.js +44 -0
- package/src/transfer/move-highlighted-picked-option-to-top.js +38 -0
- package/src/transfer/move-highlighted-picked-option-up.js +47 -0
- package/src/transfer/remove-all-picked-options.js +13 -0
- package/src/transfer/remove-individual-picked-options.js +49 -0
- package/src/transfer/use-filter.js +17 -0
- package/src/transfer/use-highlighted-options/create-toggle-highlighted-option.js +64 -0
- package/src/transfer/use-highlighted-options/toggle-add.js +20 -0
- package/src/transfer/use-highlighted-options/toggle-range.js +61 -0
- package/src/transfer/use-highlighted-options/toggle-replace.js +26 -0
- package/src/transfer/use-highlighted-options.js +34 -0
- package/src/transfer/use-options-key-monitor.js +41 -0
- package/src/transfer-option.js +91 -0
- package/src/transfer.js +539 -0
- package/src/transfer.prod.stories.js +621 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
|
|
2
|
+
|
|
3
|
+
Given('reordering of items is enabled', () => {
|
|
4
|
+
// no op
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
Given('the selected list has three items', () => {
|
|
8
|
+
cy.visitStory('Transfer Reorder Buttons', 'Has Three Selected')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
Given('the selected list has some items', () => {
|
|
12
|
+
cy.visitStory('Transfer Reorder Buttons', 'Has Some Selected')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
Given('the {int}. item is highlighted', (previousPosition) => {
|
|
16
|
+
const index = previousPosition - 1
|
|
17
|
+
console.log('> index', index)
|
|
18
|
+
|
|
19
|
+
cy.get('{transfer-pickedoptions} {transferoption}')
|
|
20
|
+
.eq(index)
|
|
21
|
+
.invoke('attr', 'data-value')
|
|
22
|
+
.as('previousValue', { type: 'static' })
|
|
23
|
+
|
|
24
|
+
cy.get('{transfer-pickedoptions} {transferoption}')
|
|
25
|
+
.eq(index)
|
|
26
|
+
.as('previous')
|
|
27
|
+
.click()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
Given('no items are highlighted in the list', () => {
|
|
31
|
+
cy.get('{transfer-pickedoptions} {transferoption}.highlighted').should(
|
|
32
|
+
'not.exist'
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
Given('more than one item is highlighted in the list', () => {
|
|
37
|
+
cy.get('{transfer-pickedoptions} {transferoption}')
|
|
38
|
+
.filter((index) => index < 2)
|
|
39
|
+
.each(($option) => cy.wrap($option).clickWith('ctrl'))
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
When("the user clicks the 'move up' button", () => {
|
|
43
|
+
// force, so we click disabled buttons
|
|
44
|
+
cy.get('{transfer-reorderingactions-buttonmoveup}').click({ force: true })
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
When("the user clicks the 'move down' button", () => {
|
|
48
|
+
// force, so we click disabled buttons
|
|
49
|
+
cy.get('{transfer-reorderingactions-buttonmovedown}').click({ force: true })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
When("the user clicks the 'move to top' button", () => {
|
|
53
|
+
// force, so we click disabled buttons
|
|
54
|
+
cy.get('{transfer-reorderingactions-buttonmovetotop}').click({
|
|
55
|
+
force: true,
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
When("the user clicks the 'move to bottom' button", () => {
|
|
60
|
+
// force, so we click disabled buttons
|
|
61
|
+
cy.get('{transfer-reorderingactions-buttonmovetobottom}').click({
|
|
62
|
+
force: true,
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
Then('the highlighted item should be moved to the {int}. place', (next) => {
|
|
67
|
+
const index = next - 1
|
|
68
|
+
|
|
69
|
+
cy.get('@previousValue')
|
|
70
|
+
.then((previousValue) => cy.get(`[data-value="${previousValue}"]`))
|
|
71
|
+
.invoke('index')
|
|
72
|
+
.should('equal', index)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
Then('all four reorder buttons should be disabled', () => {
|
|
76
|
+
cy.get('{transfer-reorderingactions-buttonmovetotop}').should(
|
|
77
|
+
'have.attr',
|
|
78
|
+
'disabled'
|
|
79
|
+
)
|
|
80
|
+
cy.get('{transfer-reorderingactions-buttonmoveup}').should(
|
|
81
|
+
'have.attr',
|
|
82
|
+
'disabled'
|
|
83
|
+
)
|
|
84
|
+
cy.get('{transfer-reorderingactions-buttonmovedown}').should(
|
|
85
|
+
'have.attr',
|
|
86
|
+
'disabled'
|
|
87
|
+
)
|
|
88
|
+
cy.get('{transfer-reorderingactions-buttonmovetobottom}').should(
|
|
89
|
+
'have.attr',
|
|
90
|
+
'disabled'
|
|
91
|
+
)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// --- Multi-select ---
|
|
95
|
+
|
|
96
|
+
Given('the selected list has eight items', () => {
|
|
97
|
+
cy.visitStory('Transfer Reorder Buttons', 'Has Some Selected')
|
|
98
|
+
cy.get('{transfer-pickedoptions} {transferoption}').should('have.length', 8)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const highlightPositionWithCtrl = (position) =>
|
|
102
|
+
cy
|
|
103
|
+
.get('{transfer-pickedoptions} {transferoption}')
|
|
104
|
+
.eq(position - 1)
|
|
105
|
+
.then(($option) =>
|
|
106
|
+
cy.get('@highlightedValues').then((values) => {
|
|
107
|
+
values.push($option.attr('data-value'))
|
|
108
|
+
return $option
|
|
109
|
+
})
|
|
110
|
+
)
|
|
111
|
+
.clickWith('ctrl')
|
|
112
|
+
|
|
113
|
+
When(
|
|
114
|
+
'the user highlights the items at positions {int} and {int}',
|
|
115
|
+
(first, second) => {
|
|
116
|
+
cy.wrap([]).as('highlightedValues')
|
|
117
|
+
highlightPositionWithCtrl(first)
|
|
118
|
+
highlightPositionWithCtrl(second)
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
When('the user highlights every item in the selected list', () => {
|
|
123
|
+
cy.wrap([]).as('highlightedValues')
|
|
124
|
+
cy.get('{transfer-pickedoptions} {transferoption}').each(($option) => {
|
|
125
|
+
cy.get('@highlightedValues').then((values) => {
|
|
126
|
+
values.push($option.attr('data-value'))
|
|
127
|
+
})
|
|
128
|
+
cy.wrap($option).clickWith('ctrl')
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
Then('those items should be at positions {int} and {int}', (first, second) => {
|
|
133
|
+
cy.get('@highlightedValues').then((values) => {
|
|
134
|
+
const targetIndices = [first - 1, second - 1]
|
|
135
|
+
values.forEach((value, i) => {
|
|
136
|
+
cy.get(`[data-value="${value}"]`)
|
|
137
|
+
.invoke('index')
|
|
138
|
+
.should('equal', targetIndices[i])
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
Then('those items should still be highlighted', () => {
|
|
144
|
+
cy.get('@highlightedValues').then((values) => {
|
|
145
|
+
values.forEach((value) => {
|
|
146
|
+
cy.get(`{transfer-pickedoptions} [data-value="${value}"]`).should(
|
|
147
|
+
'have.class',
|
|
148
|
+
'highlighted'
|
|
149
|
+
)
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const reorderButtonSelectors = {
|
|
155
|
+
'move up': '{transfer-reorderingactions-buttonmoveup}',
|
|
156
|
+
'move down': '{transfer-reorderingactions-buttonmovedown}',
|
|
157
|
+
'move to top': '{transfer-reorderingactions-buttonmovetotop}',
|
|
158
|
+
'move to bottom': '{transfer-reorderingactions-buttonmovetobottom}',
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
Then(
|
|
162
|
+
'the {string} and {string} buttons should be disabled',
|
|
163
|
+
(first, second) => {
|
|
164
|
+
cy.get(reorderButtonSelectors[first]).should('have.attr', 'disabled')
|
|
165
|
+
cy.get(reorderButtonSelectors[second]).should('have.attr', 'disabled')
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
Then(
|
|
170
|
+
'the {string} and {string} buttons should not be disabled',
|
|
171
|
+
(first, second) => {
|
|
172
|
+
cy.get(reorderButtonSelectors[first]).should(
|
|
173
|
+
'not.have.attr',
|
|
174
|
+
'disabled'
|
|
175
|
+
)
|
|
176
|
+
cy.get(reorderButtonSelectors[second]).should(
|
|
177
|
+
'not.have.attr',
|
|
178
|
+
'disabled'
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
@component-transfer @reordering
|
|
2
|
+
Feature: Reorder items in the selected list using buttons
|
|
3
|
+
|
|
4
|
+
Background:
|
|
5
|
+
Given reordering of items is enabled
|
|
6
|
+
|
|
7
|
+
# I created two scenarios for up and down reordering because I wanted to
|
|
8
|
+
# incorporate a check for 'is first' or 'is last' and it seemed overly
|
|
9
|
+
# ambiguous to write this in a single scenario. Or, is it enough that I
|
|
10
|
+
# have included the 'Disable move buttons' scenarios at the bottom of this
|
|
11
|
+
# file, so that doesn't need to be handled in the basic scenarios at the
|
|
12
|
+
# top?
|
|
13
|
+
|
|
14
|
+
Scenario Outline: The user clicks the 'move up' button with a highlighted item in the selected list
|
|
15
|
+
Given the selected list has three items
|
|
16
|
+
And the <previous>. item is highlighted
|
|
17
|
+
When the user clicks the 'move up' button
|
|
18
|
+
Then the highlighted item should be moved to the <next>. place
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
| previous | next |
|
|
22
|
+
| 1 | 1 |
|
|
23
|
+
| 2 | 1 |
|
|
24
|
+
| 3 | 2 |
|
|
25
|
+
|
|
26
|
+
Scenario Outline: The user clicks the 'move down' button with a highlighted item in the selected list
|
|
27
|
+
Given the selected list has three items
|
|
28
|
+
And the <previous>. item is highlighted
|
|
29
|
+
When the user clicks the 'move down' button
|
|
30
|
+
Then the highlighted item should be moved to the <next>. place
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
| previous | next |
|
|
34
|
+
| 1 | 2 |
|
|
35
|
+
| 2 | 3 |
|
|
36
|
+
| 3 | 3 |
|
|
37
|
+
|
|
38
|
+
Scenario Outline: The user clicks the 'move to top' button with a highlighted item in the selected list
|
|
39
|
+
Given the selected list has three items
|
|
40
|
+
And the <previous>. item is highlighted
|
|
41
|
+
When the user clicks the 'move to top' button
|
|
42
|
+
Then the highlighted item should be moved to the <next>. place
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
| previous | next |
|
|
46
|
+
| 1 | 1 |
|
|
47
|
+
| 2 | 1 |
|
|
48
|
+
| 3 | 1 |
|
|
49
|
+
|
|
50
|
+
Scenario Outline: The user clicks the 'move to bottom' button with a highlighted item in the selected list
|
|
51
|
+
Given the selected list has three items
|
|
52
|
+
And the <previous>. item is highlighted
|
|
53
|
+
When the user clicks the 'move to bottom' button
|
|
54
|
+
Then the highlighted item should be moved to the <next>. place
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
| previous | next |
|
|
58
|
+
| 1 | 3 |
|
|
59
|
+
| 2 | 3 |
|
|
60
|
+
| 3 | 3 |
|
|
61
|
+
|
|
62
|
+
Scenario: Disable reorder buttons when no items are highlighted
|
|
63
|
+
Given the selected list has some items
|
|
64
|
+
And no items are highlighted in the list
|
|
65
|
+
Then all four reorder buttons should be disabled
|
|
66
|
+
|
|
67
|
+
# --- Multi-select ---
|
|
68
|
+
#
|
|
69
|
+
# All four buttons act on the highlighted picked items as a group,
|
|
70
|
+
# preserving the group's relative order. Non-contiguous selections
|
|
71
|
+
# collapse into a contiguous block before landing at the target edge.
|
|
72
|
+
|
|
73
|
+
Scenario: 'move up' shifts a contiguous block of highlighted items up by one slot
|
|
74
|
+
Given the selected list has eight items
|
|
75
|
+
When the user highlights the items at positions 3 and 4
|
|
76
|
+
And the user clicks the 'move up' button
|
|
77
|
+
Then those items should be at positions 2 and 3
|
|
78
|
+
And those items should still be highlighted
|
|
79
|
+
|
|
80
|
+
Scenario: 'move up' collapses and shifts a non-contiguous selection in one press
|
|
81
|
+
Given the selected list has eight items
|
|
82
|
+
When the user highlights the items at positions 2 and 4
|
|
83
|
+
And the user clicks the 'move up' button
|
|
84
|
+
Then those items should be at positions 1 and 2
|
|
85
|
+
|
|
86
|
+
Scenario: 'move down' shifts a contiguous block of highlighted items down by one slot
|
|
87
|
+
Given the selected list has eight items
|
|
88
|
+
When the user highlights the items at positions 2 and 3
|
|
89
|
+
And the user clicks the 'move down' button
|
|
90
|
+
Then those items should be at positions 3 and 4
|
|
91
|
+
|
|
92
|
+
Scenario: 'move down' collapses and shifts a non-contiguous selection in one press
|
|
93
|
+
Given the selected list has eight items
|
|
94
|
+
When the user highlights the items at positions 2 and 4
|
|
95
|
+
And the user clicks the 'move down' button
|
|
96
|
+
Then those items should be at positions 4 and 5
|
|
97
|
+
|
|
98
|
+
Scenario: 'move to top' collapses a non-contiguous selection flush to the top
|
|
99
|
+
Given the selected list has eight items
|
|
100
|
+
When the user highlights the items at positions 3 and 5
|
|
101
|
+
And the user clicks the 'move to top' button
|
|
102
|
+
Then those items should be at positions 1 and 2
|
|
103
|
+
|
|
104
|
+
Scenario: 'move to bottom' collapses a non-contiguous selection flush to the bottom
|
|
105
|
+
Given the selected list has eight items
|
|
106
|
+
When the user highlights the items at positions 2 and 4
|
|
107
|
+
And the user clicks the 'move to bottom' button
|
|
108
|
+
Then those items should be at positions 7 and 8
|
|
109
|
+
|
|
110
|
+
Scenario: The highlighted group stays highlighted after moving, allowing chained presses
|
|
111
|
+
Given the selected list has eight items
|
|
112
|
+
When the user highlights the items at positions 3 and 4
|
|
113
|
+
And the user clicks the 'move up' button
|
|
114
|
+
And the user clicks the 'move up' button
|
|
115
|
+
Then those items should be at positions 1 and 2
|
|
116
|
+
And those items should still be highlighted
|
|
117
|
+
|
|
118
|
+
Scenario: Both up-side buttons are disabled when the highlighted block is flush to the top
|
|
119
|
+
Given the selected list has eight items
|
|
120
|
+
When the user highlights the items at positions 1 and 2
|
|
121
|
+
Then the 'move up' and 'move to top' buttons should be disabled
|
|
122
|
+
And the 'move down' and 'move to bottom' buttons should not be disabled
|
|
123
|
+
|
|
124
|
+
Scenario: Both down-side buttons are disabled when the highlighted block is flush to the bottom
|
|
125
|
+
Given the selected list has eight items
|
|
126
|
+
When the user highlights the items at positions 7 and 8
|
|
127
|
+
Then the 'move down' and 'move to bottom' buttons should be disabled
|
|
128
|
+
And the 'move up' and 'move to top' buttons should not be disabled
|
|
129
|
+
|
|
130
|
+
Scenario: Up-side buttons remain enabled when a non-contiguous selection contains the top item
|
|
131
|
+
Given the selected list has eight items
|
|
132
|
+
When the user highlights the items at positions 1 and 3
|
|
133
|
+
Then the 'move up' and 'move to top' buttons should not be disabled
|
|
134
|
+
|
|
135
|
+
Scenario: All four reorder buttons are disabled when every picked item is highlighted
|
|
136
|
+
Given the selected list has eight items
|
|
137
|
+
When the user highlights every item in the selected list
|
|
138
|
+
Then all four reorder buttons should be disabled
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
|
|
2
|
+
import { extractOptionFromElement } from '../common/index.js'
|
|
3
|
+
|
|
4
|
+
Given('the option list has one or more items', () => {
|
|
5
|
+
cy.visitStory('Transfer set & unset higlighted options', 'Has Options')
|
|
6
|
+
cy.get('{transfer-sourceoptions}').as('list')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
Given('the selected list has one or more items', () => {
|
|
10
|
+
cy.visitStory('Transfer set & unset higlighted options', 'Has Selected')
|
|
11
|
+
cy.get('{transfer-pickedoptions}').as('list')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
Given('no item is highlighted', () => {
|
|
15
|
+
cy.get('@list').find('.highlighted').should('not.exist')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
Given('one item is highlighted', () => {
|
|
19
|
+
cy.get('@list')
|
|
20
|
+
.find('{transferoption}')
|
|
21
|
+
.first()
|
|
22
|
+
.as('initiallyHighlighted')
|
|
23
|
+
.click()
|
|
24
|
+
.should('have.class', 'highlighted')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
Given('the highlighted item is not visible due to a set filter', () => {
|
|
28
|
+
// store hidden option because dom reference will be lost
|
|
29
|
+
cy.get('@initiallyHighlighted')
|
|
30
|
+
.then(($initiallyHighlighted) =>
|
|
31
|
+
extractOptionFromElement($initiallyHighlighted)
|
|
32
|
+
)
|
|
33
|
+
.as('hiddenHighlighted')
|
|
34
|
+
|
|
35
|
+
cy.get('{transfer-filter} input').type('No result search term')
|
|
36
|
+
|
|
37
|
+
cy.get('{transfer-sourceoptions} {transferoption}').should('not.exist')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
When('the user clicks an item in the list that is not highlighted', () => {
|
|
41
|
+
cy.get('@list')
|
|
42
|
+
.find('{transferoption}')
|
|
43
|
+
.first()
|
|
44
|
+
.invoke('next')
|
|
45
|
+
.as('nextHighlighted')
|
|
46
|
+
.click()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
When('the user clicks an item in the list that is highlighted', () => {
|
|
50
|
+
cy.get('@initiallyHighlighted').wait(500).click()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
When('the user selects the visible, highlighted options', () => {
|
|
54
|
+
cy.get('{transfer-actions-addindividual}').click()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
When('the users changes the filter to include the hidden option', () => {
|
|
58
|
+
cy.get('{transfer-filter} input').clear()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
Then('the clicked item should be highlighted', () => {
|
|
62
|
+
cy.get('@nextHighlighted').should('have.class', 'highlighted')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
Then('the previously highlighted item should no longer be highlighted', () => {
|
|
66
|
+
cy.get('@initiallyHighlighted').should('have.not.class', 'highlighted')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
Then('the option is visible', () => {
|
|
70
|
+
cy.all(
|
|
71
|
+
() => cy.get('@hiddenHighlighted'),
|
|
72
|
+
() => cy.get('{transfer-sourceoptions} {transferoption}')
|
|
73
|
+
).should(([hiddenHighlighted, $options]) => {
|
|
74
|
+
const $hiddenHighlighted = $options.filter((index, optionEl) => {
|
|
75
|
+
const option = extractOptionFromElement(optionEl)
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
option.label === hiddenHighlighted.label &&
|
|
79
|
+
option.value === hiddenHighlighted.value
|
|
80
|
+
)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
expect($hiddenHighlighted).to.be.visible
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
Then('the option is highlighted', () => {
|
|
88
|
+
cy.all(
|
|
89
|
+
() => cy.get('@hiddenHighlighted'),
|
|
90
|
+
() => cy.get('{transfer-sourceoptions} {transferoption}')
|
|
91
|
+
).should(([hiddenHighlighted, $options]) => {
|
|
92
|
+
const $hiddenHighlighted = $options.filter((index, optionEl) => {
|
|
93
|
+
const option = extractOptionFromElement(optionEl)
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
option.label === hiddenHighlighted.label &&
|
|
97
|
+
option.value === hiddenHighlighted.value
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
expect($hiddenHighlighted).to.have.class('highlighted')
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
Then('the option is not highlighted', () => {
|
|
106
|
+
cy.all(
|
|
107
|
+
() => cy.get('@hiddenHighlighted'),
|
|
108
|
+
() => cy.get('{transfer-sourceoptions} {transferoption}')
|
|
109
|
+
).should(([hiddenHighlighted, $options]) => {
|
|
110
|
+
const $hiddenHighlighted = $options.filter((index, optionEl) => {
|
|
111
|
+
const option = extractOptionFromElement(optionEl)
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
option.label === hiddenHighlighted.label &&
|
|
115
|
+
option.value === hiddenHighlighted.value
|
|
116
|
+
)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
expect($hiddenHighlighted).not.to.have.class('highlighted')
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@component-transfer @highlighting
|
|
2
|
+
Feature: Set&unset the highlighted option
|
|
3
|
+
|
|
4
|
+
Scenario Outline: The user clicks an item that is not already highlighted
|
|
5
|
+
Given the <type> list has one or more items
|
|
6
|
+
And one item is highlighted
|
|
7
|
+
When the user clicks an item in the list that is not highlighted
|
|
8
|
+
Then the clicked item should be highlighted
|
|
9
|
+
And the previously highlighted item should no longer be highlighted
|
|
10
|
+
|
|
11
|
+
Examples:
|
|
12
|
+
| type |
|
|
13
|
+
| option |
|
|
14
|
+
| selected |
|
|
15
|
+
|
|
16
|
+
Scenario Outline: The user clicks a highlighted item
|
|
17
|
+
Given the <type> list has one or more items
|
|
18
|
+
And one item is highlighted
|
|
19
|
+
When the user clicks an item in the list that is highlighted
|
|
20
|
+
Then the previously highlighted item should no longer be highlighted
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
| type |
|
|
24
|
+
| option |
|
|
25
|
+
| selected |
|
|
26
|
+
|
|
27
|
+
Scenario: The user highlights an option, changes the filter to exclude that option & then changes the filter back
|
|
28
|
+
Given the option list has one or more items
|
|
29
|
+
And one item is highlighted
|
|
30
|
+
But the highlighted item is not visible due to a set filter
|
|
31
|
+
When the users changes the filter to include the hidden option
|
|
32
|
+
Then the option is visible
|
|
33
|
+
And the option is highlighted
|
|
34
|
+
|
|
35
|
+
Scenario: The user highlights an option, changes the filter to exclude that option, selects the highlighted options & then changes the filter back
|
|
36
|
+
Given the option list has one or more items
|
|
37
|
+
And one item is highlighted
|
|
38
|
+
But the highlighted item is not visible due to a set filter
|
|
39
|
+
When the user selects the visible, highlighted options
|
|
40
|
+
And the users changes the filter to include the hidden option
|
|
41
|
+
Then the option is visible
|
|
42
|
+
And the option is not highlighted
|