/
broadcasts-test.js
102 lines (77 loc) · 3.19 KB
/
broadcasts-test.js
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
import { test } from 'qunit';
import moduleForAcceptance from 'travis/tests/helpers/module-for-acceptance';
import dashboardPage from 'travis/tests/pages/dashboard';
import topPage from 'travis/tests/pages/top';
moduleForAcceptance('Acceptance | broadcasts', {
beforeEach() {
const currentUser = server.create('user', {
name: 'User Name',
login: 'user-login'
});
signInUser(currentUser);
// create active repo
server.create('repository', {
slug: 'org-login/repository-name'
});
}
});
test('the broadcast tower shows a warning even when an announcement exists, broadcasts are listed in reverse order, and closing a broadcast records it', (assert) => {
withFeature('broadcasts');
server.create('broadcast', {
category: 'warning',
message: 'A warning'
});
server.create('broadcast', {
category: 'announcement',
message: 'An announcement',
id: 2016
});
dashboardPage.visit();
andThen(() => {
assert.ok(topPage.broadcastTower.hasWarning, 'expected the broadcast tower to have a warning class');
assert.ok(topPage.broadcasts.isClosed, 'expected the broadcast list to be closed');
assert.equal(topPage.broadcastBadge.text, 2, 'expected the badge to show two broadcasts');
});
topPage.broadcastTower.click();
andThen(() => {
assert.ok(topPage.broadcasts.isOpen, 'expected the broadcast list to be open');
assert.equal(topPage.broadcasts.items.length, 2, 'expected there to be two broadcasts');
assert.ok(topPage.broadcasts.items[0].isAnnouncement, 'expected the first broadcast to be an announcement');
assert.equal(topPage.broadcasts.items[0].message, 'An announcement');
assert.ok(topPage.broadcasts.items[1].isWarning, 'expected the second broadcast to be a warning');
assert.equal(topPage.broadcasts.items[1].message, 'A warning');
});
percySnapshot(assert);
topPage.broadcasts.items[0].dismiss();
andThen(() => {
assert.ok(topPage.broadcasts.items.length, 1, 'expected there to be one broadcast');
assert.equal(topPage.broadcastBadge.text, 1, 'expected the badge to show one broadcast');
assert.ok(topPage.broadcasts.items[0].isWarning, 'expected the remaining broadcast to be a warning');
assert.equal(localStorage.getItem('travis.seen_broadcasts'), JSON.stringify(['2016']));
});
});
test('the broadcast tower shows an announcement', assert => {
withFeature('broadcasts');
server.create('broadcast', {
category: 'announcement',
message: 'Another announcement'
});
dashboardPage.visit();
andThen(() => {
assert.ok(topPage.broadcastTower.hasAnnouncement, 'expected the broadcast tower to have an announcement class');
});
});
test('a dismissed broadcast does not highlight the tower', assert => {
withFeature('broadcasts');
server.create('broadcast', {
category: 'announcement',
message: 'Welcome.',
id: '2016'
});
localStorage.setItem('travis.seen_broadcasts', JSON.stringify(['2016']));
dashboardPage.visit();
andThen(() => {
assert.ok(topPage.broadcastTower.hasNoAnnouncement, 'expected the broadcast tower to not have an announcement class');
assert.ok(topPage.broadcastBadge.isHidden, 'expected there to be no broadcast count');
});
});