-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.js
116 lines (113 loc) · 3.24 KB
/
new.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
define([
"intern!object",
"intern/chai!assert",
"require",
"tests/support/helper"
], function ( registerSuite, assert, require, testHelper ) {
var boilerplate = testHelper.getAppUrl( "boilerplate.html" );
registerSuite({
name: "New profile",
"Profile can be created.": function () {
var self = this;
return this.remote
.get( boilerplate )
.setFindTimeout( 1000 )
/** Open panel by clicking entry. */
.findById( "qunit-desktop-notifications-entry" )
.click()
.end()
/** Open new profile to edit. */
.findById( "qunit-desktop-notifications-panel" )
.findByCssSelector( "button[action=new]" )
.click()
.end()
/** Check if input was focused. */
.execute( function () {
return document.activeElement.getAttribute( "name" );
})
.then( function ( activeElementName ) {
assert.equal( activeElementName, "name" );
})
/** Assert that "Save" button is disabled when no name is typed. */
.findByCssSelector( "button[action=\"save\"]" )
.isEnabled()
.then( function ( enabled ) {
assert.notOk( enabled );
})
.end()
/** Enter profile name. */
.findByCssSelector( "input[name=\"name\"]" )
.type( "Test" )
.end()
/** Assert that "Save" button is enabled when name is typed. */
.findByCssSelector( "button[action=\"save\"]" )
.isEnabled()
.then( function ( enabled ) {
assert.ok( enabled );
})
.end()
/** Clear input. */
.findByCssSelector( "input[name=\"name\"]" )
.type( "\b\b\b\b" )
.end()
/** Assert that "Save" button is disabled again when name is cleared. */
.findByCssSelector( "button[action=\"save\"]" )
.isEnabled()
.then( function ( enabled ) {
assert.notOk( enabled );
})
.end()
/** Revert to "Test" value. */
.findByCssSelector( "input[name=\"name\"]" )
.type( "Test" )
.end()
/** Find option, and assert it's label. */
.findByCssSelector( "select option[value=\"test\"]" )
.getVisibleText()
.then( function ( text ) {
assert.equal( text, "test" );
})
.end()
/** Select two events. */
.findByCssSelector( ".events-wrapper" )
.isDisplayed()
.then( function ( visible ) {
assert.ok( visible );
})
.findByCssSelector( "[qdn-event=\"begin\"]" )
.click()
.end()
.findByCssSelector( "[qdn-event=\"done\"]" )
.click()
.end()
.end()
/** Save profile. */
.findByCssSelector( "button[action=save]" )
.click()
.end()
/** Get profiles from local storage. */
.execute( function () {
return JSON.parse( QUnitDesktopNotifications.utils.localStorage( "profiles" ) );
})
/** Assert that the profile was saved. */
.then( function ( profiles ) {
assert.deepEqual( profiles.test, {
begin: true,
done: true,
log: false,
moduleDone: false,
moduleStart: false,
testDone: false,
testStart: false
}, "Profile saved to localStorage." );
})
/** Find option again, and assert it's been keept in select. */
.findByCssSelector( "select option[name=\"test\"]" )
.getVisibleText()
.then( function ( text ) {
assert.equal( text, "test" );
})
.end()
}
});
});