This repository was archived by the owner on Oct 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpitch.js
More file actions
105 lines (83 loc) · 3.54 KB
/
pitch.js
File metadata and controls
105 lines (83 loc) · 3.54 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
/**
* signup.js
* Test that a user can sign up for a campaign.
*/
var CAMPAIGN_SIGNUP_MESSAGE = "You're signed up for";
casper.test.begin("Test pitch page is rendered correctly", 2, function suite(test) {
casper.start(url);
casper.thenOpen(url + "/campaigns/test-campaign", function(){
// We expect to see the title of the campaign, "Test Campaign"
test.assertSelectorHasText("header[role='banner'].-hero .__title", "Test Campaign", "Title of campaign is printed in H1.");
// We expect to see the subtitle for the campaign, "This is a test unsponsored campaign."
test.assertSelectorHasText("header[role='banner'].-hero .__subtitle", "This is a test unsponsored campaign.", "Subtitle of campaign is printed in H2.");
});
casper.run(function() {
test.done();
});
});
casper.test.begin("Test that an unregistered user can register & sign up for a campaign.", 1, function suite(test) {
casper.start(url);
casper.thenOpen(url + "/campaigns/test-campaign", function(){
// We expect to see a sign up button, and to be able to click it to sign up.
this.waitUntilVisible("#link--campaign-signup-login", function() {
this.click("#link--campaign-signup-login");
});
this.waitUntilVisible("[data-modal]", function() {
this.click("#link--register");
});
});
casper.then(function() {
// Now, let's register with real data.
this.fill("form[id='user-register-form']", {
"field_first_name[und][0][value]": "Panda",
"field_birthdate[und][0][value][date]": "01/04/1989",
"mail": "QA_TEST_CAMPAIGN_SIGNUP_NEW@example.com",
"pass[pass1]": "QA_TEST_CAMPAIGN_SIGNUP_NEW",
"pass[pass2]": "QA_TEST_CAMPAIGN_SIGNUP_NEW",
}, true);
// Make sure the signup happened.
casper.waitForSelector('.messages.status', function() {
test.assertSelectorHasText('.messages.status', CAMPAIGN_SIGNUP_MESSAGE, 'User can register and sign up for a campaign');
});
});
casper.run(function() {
test.done();
});
});
casper.test.begin("Test that a logged-out user can log in & sign up for a campaign.", 1, function suite(test) {
casper.start(url);
casper.thenOpen(url + "/campaigns/test-campaign", function(){
// We expect to see a sign up button, and to be able to click it to sign up.
this.waitUntilVisible("#link--campaign-signup-login", function() {
this.click("#link--campaign-signup-login");
});
this.waitUntilVisible("[data-modal]", function() {
this.fill("form#user-login-form", {
name: 'QA_TEST_CAMPAIGN_SIGNUP_EXISTING@example.com',
pass: 'QA_TEST_CAMPAIGN_SIGNUP_EXISTING'
}, true);
// Make sure the signup happened.
casper.waitForSelector('.messages.status', function() {
test.assertSelectorHasText('.messages.status', CAMPAIGN_SIGNUP_MESSAGE, 'User can log in and sign up for a campaign');
});
});
});
casper.run(function() {
test.done();
});
});
casper.test.begin("Test that a logged-in user can sign up for a campaign.", 1, function suite(test) {
casper.start(url);
casper.login();
casper.thenOpen(url + "/campaigns/test-campaign", function(){
// We expect to see a sign up button, and to be able to click it to sign up.
this.click("form#dosomething-signup-form input[type='submit']");
// Make sure the signup happened.
casper.waitForSelector('.messages.status', function() {
test.assertSelectorHasText('.messages.status', CAMPAIGN_SIGNUP_MESSAGE, 'Clicking "Sign Up" signs up for a campaign');
});
});
casper.run(function() {
test.done();
});
});