This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/
create_event_test.js
257 lines (242 loc) · 8.06 KB
/
create_event_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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
'use strict';
var Calendar = require('./lib/calendar'),
assert = require('chai').assert;
marionette('creating events', function() {
var app;
var client = marionette.client({
profile: {
prefs: {
// we need to disable the keyboard to avoid intermittent failures on
// Travis (transitions might take longer to run and block UI)
'dom.mozInputMethod.enabled': false,
// Do not require the B2G-desktop app window to have focus (as per the
// system window manager) in order for it to do focus-related things.
'focusmanager.testmode': true,
}
}
});
var startDate = new Date('Sep 08 1991 12:34:56'),
startDateNextHour = new Date(startDate),
startDateNextDay = new Date(startDate),
scenarios;
startDateNextHour.setHours(startDate.getHours() + 1);
startDateNextDay.setDate(startDate.getDate() + 1);
scenarios = [
{
name: 'one day',
allDay: false,
startDate: startDate,
endDate: startDateNextHour,
reminders: ['5 minutes before'],
verifyMonthView: function() {
var event = app.monthDay.events[0];
assert.equal(event.startTime, '12:34 PM', 'start time');
assert.equal(event.endTime, '1:34 PM', 'end time');
},
verifyReadEventView: function() {
var readEvent = app.readEvent;
assert.equal(
readEvent.durationTime,
'Sunday, September 08, 1991\n' +
'from 12:34 PM to 1:34 PM',
'duration time'
);
assert.equal(
readEvent.reminders[0].text(),
'5 minutes before',
'reminder'
);
}
},
{
name: 'multiple day',
allDay: false,
startDate: startDate,
endDate: startDateNextDay,
reminders: ['5 minutes before'],
verifyMonthView: function() {
var month = app.month;
assert.lengthOf(month.squareDots(month.daySquares[7]), 1);
assert.lengthOf(month.squareDots(month.daySquares[8]), 1);
assert.equal(month.busyDots.length, 2, '2 busy dots');
var event = app.monthDay.events[0];
assert.equal(event.startTime, '12:34 PM', 'start time');
assert.equal(event.endTime, '12:34 PM', 'end time');
},
verifyReadEventView: function() {
var readEvent = app.readEvent;
assert.equal(
readEvent.durationTime,
'From 12:34 PM Sunday, September 08, 1991\n' +
'to 12:34 PM Monday, September 09, 1991',
'duration time'
);
assert.equal(
readEvent.reminders[0].text(),
'5 minutes before',
'reminder'
);
}
},
{
name: 'one all day',
allDay: true,
startDate: startDate,
endDate: startDateNextHour,
reminders: ['On day of event'],
verifyMonthView: function() {
var event = app.monthDay.events[0];
assert.equal(event.allDay, 'All Day', 'event hour');
},
verifyReadEventView: function() {
var readEvent = app.readEvent;
assert.equal(
readEvent.durationTime,
'All day\n' +
'Sunday, September 08, 1991',
'duration time'
);
assert.equal(
readEvent.reminders[0].text(),
'On day of event',
'reminder'
);
}
},
{
name: 'multiple all day',
allDay: true,
startDate: startDate,
endDate: startDateNextDay,
reminders: ['On day of event'],
verifyMonthView: function() {
var month = app.month;
assert.lengthOf(month.squareDots(month.daySquares[7]), 1);
assert.lengthOf(month.squareDots(month.daySquares[8]), 1);
assert.equal(month.busyDots.length, 2, '2 busy dots');
assert.equal(
app.monthDay.events[0].allDay,
'All Day',
'event hour'
);
},
verifyReadEventView: function() {
var readEvent = app.readEvent;
assert.equal(
readEvent.durationTime,
'All day from Sunday, September 08, 1991\n' +
'to Monday, September 09, 1991',
'duration time'
);
assert.equal(
readEvent.reminders[0].text(),
'On day of event',
'reminder'
);
}
},
{
name: '24 hour format',
allDay: false,
startDate: startDate,
endDate: startDateNextHour,
reminders: ['5 minutes before'],
verifyMonthView: function() {
app.switch24HourTimeFormat();
var event = app.monthDay.events[0];
assert.equal(event.startTime, '12:34', 'start time');
assert.equal(event.endTime, '13:34', 'end time');
},
verifyReadEventView: function() {
app.switch24HourTimeFormat();
var readEvent = app.readEvent;
assert.equal(
readEvent.durationTime,
'Sunday, September 08, 1991\n' +
'from 12:34 to 13:34',
'duration time'
);
assert.equal(
readEvent.reminders[0].text(),
'5 minutes before',
'reminder'
);
}
}
];
setup(function() {
app = new Calendar(client);
app.launch();
});
scenarios.forEach(function(scenario) {
suite('creating ' + scenario.name + ' event', function() {
setup(function() {
// we use default title/description/location to avoid duplication but
// allow overriding if needed
scenario.title = scenario.title ||
'Puppy Bowl dogefortlongtextfotestloremipsumdolorsitamet';
scenario.description = scenario.description ||
'lorem ipsum dolor sit amet maecennas ullamcor';
scenario.location = scenario.location ||
'Animal Planet reallylongwordthatshouldnotoverflowbecausewewrap';
app.createEvent(scenario);
app.month.waitForDisplay();
});
test('should display the created event in months day', function() {
var event = app.monthDay.events[0];
assert.equal(event.title, scenario.title, 'event title');
assert.equal(event.address, scenario.location, 'event location');
scenario.verifyMonthView();
});
suite('opening event in read view', function() {
setup(function() {
var event = app.monthDay.events[0];
// Scroll so that the first one is in view and click it.
app.monthDay.scrollToEvent(event);
event.click();
// Wait until the read view is displayed.
app.readEvent.waitForDisplay();
});
test('should display the created event in read view', function() {
var readEvent = app.readEvent;
assert.equal(readEvent.title, scenario.title, 'event title');
assert.equal(
readEvent.description,
scenario.description,
'event description'
);
assert.equal(readEvent.location, scenario.location, 'location');
assert.equal(readEvent.calendar, 'Offline calendar');
assert.equal(readEvent.calendarColor, 'rgb(249, 124, 23)');
scenario.verifyReadEventView();
});
test('should not overflow title, location, or description',
function() {
var readEvent = app.readEvent;
app.checkOverflow(readEvent.titleContainer, 'title');
app.checkOverflow(readEvent.descriptionContainer, 'description');
app.checkOverflow(readEvent.locationContainer, 'location');
});
});
});
});
test('only enable save button if title or location are set', function() {
app.openModifyEventView();
var editEvent = app.editEvent;
client.waitFor(function() {
return editEvent.saveButton.getAttribute('disabled') === 'true';
});
editEvent.title = 'foo';
client.waitFor(function() {
return editEvent.saveButton.getAttribute('disabled') === 'false';
});
editEvent.title = '';
client.waitFor(function() {
return editEvent.saveButton.getAttribute('disabled') === 'true';
});
editEvent.location = 'bar';
client.waitFor(function() {
return editEvent.saveButton.getAttribute('disabled') === 'false';
});
});
});