Skip to content

Commit f085aba

Browse files
committed
Merge branch 'staging' into prettier-changes
2 parents f9b5149 + f9513b2 commit f085aba

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

apps/src/code-studio/pd/application/teacher1920/Teacher1920Application.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Section3TeachingBackground from './Section3TeachingBackground';
66
import Section4ProfessionalLearningProgramRequirements from './Section4ProfessionalLearningProgramRequirements';
77
import Section5AdditionalDemographicInformation from './Section5AdditionalDemographicInformation';
88
import Section6Submission from './Section6Submission';
9+
/* global ga */
910

1011
export default class Teacher1920Application extends FormController {
1112
static propTypes = {
@@ -48,4 +49,13 @@ export default class Teacher1920Application extends FormController {
4849
// Let the server display a confirmation page as appropriate
4950
window.location.reload(true);
5051
}
52+
53+
/**
54+
* @override
55+
*/
56+
onSetPage(newPage) {
57+
// Report a unique page view to GA.
58+
ga('set', 'page', '/pd/application/teacher/' + newPage + 1);
59+
ga('send', 'pageview');
60+
}
5161
}

apps/src/code-studio/pd/form_components/FormController.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default class FormController extends React.Component {
4747
}
4848

4949
componentWillMount() {
50+
let newPage;
5051
if (
5152
this.constructor.sessionStorageKey &&
5253
sessionStorage[this.constructor.sessionStorageKey]
@@ -55,7 +56,12 @@ export default class FormController extends React.Component {
5556
sessionStorage[this.constructor.sessionStorageKey]
5657
);
5758
this.setState(reloadedState);
59+
newPage = reloadedState.currentPage;
60+
} else {
61+
newPage = this.state.currentPage;
5862
}
63+
64+
this.onSetPage(newPage);
5965
}
6066

6167
/**
@@ -176,6 +182,13 @@ export default class FormController extends React.Component {
176182
// Intentional noop; overridden by child classes
177183
}
178184

185+
/**
186+
* Called when we set a new page.
187+
*/
188+
onSetPage(newPage) {
189+
// Intentional noop; overridden by child classes
190+
}
191+
179192
/**
180193
* Submit serialized form data to the specified API Endpoint and handle server
181194
* response
@@ -413,6 +426,8 @@ export default class FormController extends React.Component {
413426
});
414427

415428
this.saveToSessionStorage({currentPage: newPage});
429+
430+
this.onSetPage(newPage);
416431
}
417432
}
418433

dashboard/app/views/pd/application/teacher_application/submitted.html.haml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@
1212
= link_to 'https://code.org/educate', 'https://code.org/educate'
1313
for additional resources and opportunities to connect with other computer science educators.
1414
Thank you for supporting computer science for all!
15+
16+
:javascript
17+
$(document).ready(function() {
18+
// Report a unique page view to GA.
19+
ga('set', 'page', '/pd/application/teacher/submitted');
20+
ga('send', 'pageview');
21+
});

dashboard/test/ui/features/support/connect.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ def saucelabs_browser(test_run_name)
8787

8888
def get_browser(test_run_name)
8989
if ENV['TEST_LOCAL'] == 'true'
90+
headless = ENV['TEST_LOCAL_HEADLESS'] == 'true'
9091
# This drives a local installation of ChromeDriver running on port 9515, instead of Saucelabs.
91-
SeleniumBrowser.local_browser
92+
SeleniumBrowser.local_browser(headless)
9293
else
9394
saucelabs_browser test_run_name
9495
end

dashboard/test/ui/runner.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def parse_options
101101
options.csedweek_domain = 'test.csedweek.org'
102102
options.advocacy_domain = 'test-advocacy.code.org'
103103
options.local = nil
104+
options.local_headless = true
104105
options.html = nil
105106
options.maximize = nil
106107
options.auto_retry = false
@@ -140,6 +141,9 @@ def parse_options
140141
options.csedweek_domain = 'localhost.csedweek.org:3000'
141142
options.advocacy_domain = 'localhost-advocacy.code.org:3000'
142143
end
144+
opts.on("--headed", "Open visible chrome browser windows. Runs in headless mode without this flag. Only relevant when -l is specified.") do
145+
options.local_headless = false
146+
end
143147
opts.on("-p", "--pegasus Domain", String, "Specify an override domain for code.org, e.g. localhost.code.org:3000") do |p|
144148
if p == 'localhost:3000'
145149
print "WARNING: Some tests may fail using '-p localhost:3000' because cookies will not be available.\n"\
@@ -673,6 +677,7 @@ def run_feature(browser, feature, options)
673677
run_environment['CSEDWEEK_TEST_DOMAIN'] = options.csedweek_domain if options.csedweek_domain
674678
run_environment['ADVOCACY_TEST_DOMAIN'] = options.advocacy_domain if options.advocacy_domain
675679
run_environment['TEST_LOCAL'] = options.local ? "true" : "false"
680+
run_environment['TEST_LOCAL_HEADLESS'] = options.local_headless ? "true" : "false"
676681
run_environment['MAXIMIZE_LOCAL'] = options.maximize ? "true" : "false"
677682
run_environment['MOBILE'] = browser['mobile'] ? "true" : "false"
678683
run_environment['FAIL_FAST'] = options.fail_fast ? "true" : nil

dashboard/test/ui/utils/selenium_browser.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
require 'selenium/webdriver'
22

33
module SeleniumBrowser
4-
def self.local_browser
4+
def self.local_browser(headless=true)
55
ensure_chromedriver_running
66
sleep 2
7-
browser = Selenium::WebDriver.for :chrome, url: 'http://127.0.0.1:9515'
7+
options = Selenium::WebDriver::Chrome::Options.new
8+
if headless
9+
options.add_argument('--headless')
10+
end
11+
browser = Selenium::WebDriver.for :chrome, url: 'http://127.0.0.1:9515', options: options
812
if ENV['MAXIMIZE_LOCAL']
913
max_width, max_height = browser.execute_script('return [window.screen.availWidth, window.screen.availHeight];')
1014
browser.manage.window.resize_to(max_width, max_height)

0 commit comments

Comments
 (0)