-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathcomments-auth.js
More file actions
executable file
·133 lines (124 loc) · 4.01 KB
/
Copy pathcomments-auth.js
File metadata and controls
executable file
·133 lines (124 loc) · 4.01 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
"use strict";
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const intern = require("intern").default;
const { assert } = intern.getPlugin("chai");
const { registerSuite } = intern.getInterface("object");
const FunctionalHelpers = require("./lib/helpers.js");
var url = (path) => intern.config.functionalBaseUrl + path;
registerSuite("Comments (auth)", {
before() {
return FunctionalHelpers.login(this);
},
after() {
return FunctionalHelpers.logout(this);
},
tests: {
"Comments form visible when logged in"() {
return (
FunctionalHelpers.openPage(this, url("issues/100"), ".js-Issue")
// Comment form visible for logged in users.
.findDisplayedByCssSelector(".js-Comment-form")
.end()
);
},
"Comments form not visible when the issue is locked"() {
return (
FunctionalHelpers.openPage(this, url("issues/23"), ".js-Issue")
// Comment form should not be visible for locked issues.
.findByCssSelector(".js-issue-comment-submit")
.getAttribute("class")
.then((className) => {
assert.include(className, "is-hidden");
})
.end()
);
},
"Posting a comment"() {
var originalCommentsLength;
var allCommentsLength;
return (
FunctionalHelpers.openPage(this, url("issues/100"), ".js-image-upload")
.findAllByCssSelector(".js-Issue-comment")
.then((elms) => {
originalCommentsLength = elms.length;
})
.end()
.findByCssSelector("textarea")
.type("Today's date is " + new Date().toDateString())
.end()
// click the comment button
.findByCssSelector(".js-Issue-comment-button")
.click()
.end()
.sleep(1000)
.findAllByCssSelector(".js-Issue-comment")
.then((elms) => {
allCommentsLength = elms.length;
assert(
originalCommentsLength < allCommentsLength,
"Comment was successfully left.",
);
})
);
},
"Posting an empty comment fails"() {
var originalCommentsLength;
var allCommentsLength;
return FunctionalHelpers.openPage(this, url("issues/100"), ".js-Issue")
.findAllByCssSelector(".js-Issue-comment")
.then((elms) => {
originalCommentsLength = elms.length;
})
.end()
.execute(() => {
// click the comment button
document.querySelector(".js-Issue-comment-button").click();
})
.end()
.sleep(2000)
.findAllByCssSelector(".js-Issue-comment")
.then((elms) => {
allCommentsLength = elms.length;
assert(
originalCommentsLength === allCommentsLength,
"Comment was not successfully left.",
);
});
},
"Pressing 'g' inside of comment textarea *doesn't* go to github issue"() {
return FunctionalHelpers.openPage(
this,
url("issues/100"),
".js-Comment-text",
)
.findByCssSelector(".js-Comment-text")
.type("g")
.end()
.setFindTimeout(2000)
.findByCssSelector(".repo-container .issues-listing")
.then(assert.fail, (err) => {
assert.isTrue(/NoSuchElement/.test(String(err)));
})
.end();
},
"Pressing 'l' inside of comment textarea *doesn't* open the label editor box"() {
return FunctionalHelpers.openPage(
this,
url("issues/100"),
".js-Comment-text",
)
.findByCssSelector(".js-Comment-text")
.type("l")
.end()
.setFindTimeout(2000)
.findByCssSelector(".js-LabelEditorLauncher")
.getAttribute("class")
.then((className) => {
assert.notInclude(className, "is-active");
})
.end();
},
},
});