-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathindex-test.js
More file actions
196 lines (159 loc) · 5.68 KB
/
index-test.js
File metadata and controls
196 lines (159 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import { module, test } from 'qunit';
import { currentURL, settled } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import page from 'dummy/tests/pages/index';
function assertListItems(list, expectedTitles, assert, message) {
const m = `${message}: items count`;
assert.strictEqual(list.items.length, expectedTitles.length, m);
// List with disabled sorting
expectedTitles.forEach((expectedTitle, i) => {
const m = `${message}: List #0 item #${i} content title`;
assert.strictEqual(list.items[i].item.content.title, expectedTitle, m);
});
}
module('Acceptance | index', function (hooks) {
setupApplicationTest(hooks);
test('visiting /index', async function (assert) {
await page.visit();
assert.strictEqual(currentURL(), '/', 'Current URL');
assertListItems(
page.simple1,
['Foo', 'Bar', 'Baz', 'Quux'],
assert,
'Simple 1',
);
assertListItems(page.simple2, ['☰ Zomg', '☰ Lol'], assert, 'Simple 2');
});
test('sorting a list', async function (assert) {
await page.visit();
await page.simple1.sort(0, 1, false);
assertListItems(
page.simple1,
['Bar', 'Foo', 'Baz', 'Quux'],
assert,
'Simple 1',
);
});
test('sorting between lists', async function (assert) {
await page.visit();
await page.simple1.move(0, page.simple2, 1, false);
assertListItems(page.simple1, ['Bar', 'Baz', 'Quux'], assert, 'Simple 1');
assertListItems(
page.simple2,
['☰ Zomg', '☰ Lol', '☰ Foo'],
assert,
'Simple 2',
);
});
test('disable sorting within a list when the determineForeignPositionAction parameter is given', async function (assert) {
await page.visit();
await page.foreign1.sort(0, 1, false);
assertListItems(
page.foreign1,
['Bar', 'Baz', 'Foo', 'Quux'],
assert,
'Foreign 1',
);
});
test('dragging into a sortable list when the sourcelist has the determineForeignPositionAction parameter', async function (assert) {
await page.visit();
await page.foreign1.move(0, page.foreign2, 0, true);
assertListItems(page.foreign1, ['Baz', 'Foo', 'Quux'], assert, 'Foreign 1');
assertListItems(page.foreign2, ['Bar', 'Zomg', 'Lol'], assert, 'Foreign 2');
});
test('sort into a list that has the determineForeignPositionAction parameter', async function (assert) {
await page.visit();
await page.foreign2.move(0, page.foreign1, 0, false);
assertListItems(
page.foreign1,
['Bar', 'Baz', 'Foo', 'Quux', 'Zomg'],
assert,
'Foreign 1',
);
assertListItems(page.foreign2, ['Lol'], assert, 'Foreign 2');
});
test('sorting from an unsortable list to a sortable list, and then back into an unsortable list, should not change the position', async function (assert) {
await page.visit();
const item0_0 = page.foreign1.items[0].item;
const item0_3 = page.foreign1.items[3].item;
const item1_0 = page.foreign2.items[0].item;
await item0_3.dragStart();
await page.foreign2.dragEnter();
await item1_0.dragOver(false);
await page.foreign1.dragEnter();
await item0_0.dragOver(false);
await item0_3.dragEnd();
await settled();
assertListItems(
page.foreign1,
['Bar', 'Baz', 'Foo', 'Quux'],
assert,
'Foreign 1',
);
assertListItems(page.foreign2, ['Zomg', 'Lol'], assert, 'Foreign 2');
});
test('sorting from an sortable list to an unsortable list should position alphabetically', async function (assert) {
await page.visit();
const item0_0 = page.foreign1.items[0].item;
let item1_0 = page.foreign2.items[0].item;
await item1_0.dragStart();
await page.foreign1.dragEnter();
await item0_0.dragOver(true);
await item1_0.dragEnd();
await settled();
assertListItems(
page.foreign1,
['Bar', 'Baz', 'Foo', 'Quux', 'Zomg'],
assert,
'Foreign 1',
);
assertListItems(page.foreign2, ['Lol'], assert, 'Foreign 2');
item1_0 = page.foreign2.items[0].item;
await item1_0.dragStart();
await page.foreign1.dragEnter();
await item0_0.dragOver(true);
await item1_0.dragEnd();
await settled();
assertListItems(
page.foreign1,
['Bar', 'Baz', 'Foo', 'Lol', 'Quux', 'Zomg'],
assert,
'Foreign 1',
);
assertListItems(page.foreign2, [], assert, 'Foreign 2');
});
test('foreign position: create a copy by dragging out', async function (assert) {
await page.visit();
await page.copies1.move(0, page.copies2, 0, false);
assertListItems(page.copies1, ['Foo', 'Bar', 'Baz'], assert, 'Copies 1');
assertListItems(page.copies2, ['Quux', 'Foo'], assert, 'Copies 2');
});
test('foreign position: remove a copy by dragging in', async function (assert) {
await page.visit();
await page.copies2.move(0, page.copies1, 0, false);
assertListItems(page.copies1, ['Foo', 'Bar', 'Baz'], assert, 'Copies 1');
assertListItems(page.copies2, [], assert, 'Copies 2');
});
test('source only: create a copy by dragging out', async function (assert) {
await page.visit();
await page.sourceOnly1.move(0, page.sourceOnly2, 0, false);
assertListItems(
page.sourceOnly1,
['Foo', 'Bar', 'Baz'],
assert,
'Source only 1',
);
assertListItems(page.sourceOnly2, ['Quux', 'Foo'], assert, 'Source only 2');
});
test('source only: does nothing when dragging in', async function (assert) {
await page.visit();
await page.sourceOnly2.move(0, page.sourceOnly1, 0, false);
assertListItems(
page.sourceOnly1,
['Foo', 'Bar', 'Baz'],
assert,
'Source only 1',
);
assertListItems(page.sourceOnly2, ['Quux'], assert, 'Source only 2');
});
});