X Tutup
Skip to content

Commit 1abdc09

Browse files
Vojta JinaIgorMinar
authored andcommitted
JSTD adapter for running e2e tests
Couple of changes into angular.scenario runner: - add autotest config (runs tests when document ready) - update ObjectModel (forwards events) - use only one ObjectModel instance for all outputters - expose error msg and line number in ObjectModel.Spec and ObjectModel.Step - fix generating spec.ids - fix 'html' output so that it does not mutate ObjectModel Couple of changes into docs / generator: - rename copy -> copyTpl - move docs/static into docs/examples (to avoid conflict with jstd proxy) Running all docs e2e tests: ======================================================== 1/ compile angular-scenario, jstd-scenario-adapter >> rake compile 2/ build docs >> rake docs 3/ start jstd server >> ./server-scenario.sh 4/ capture some browser 5/ run node server to serve static content >> node ../lib/nodeserver/server.js 6/ run tests >> ./test-scenario.sh
1 parent 9f56af9 commit 1abdc09

35 files changed

+1034
-121
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<a name="0.9.16"><a/>
22
# <angular/> 0.9.16 weather-control (in-progress) #
33

4+
### Features
5+
- we can run scenario tests with jstd (from command line and in multiple browsers)
6+
47

8+
### Breaking changes
9+
- html scenario runner requires ng:autotest option to start tests automatically
510

611

712
<a name="0.9.15"><a/>

Rakefile

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ANGULAR_SCENARIO = [
5353
'src/scenario/output/Html.js',
5454
'src/scenario/output/Json.js',
5555
'src/scenario/output/Xml.js',
56-
'src/scenario/output/Object.js',
56+
'src/scenario/output/Object.js'
5757
]
5858

5959
BUILD_DIR = 'build'
@@ -94,6 +94,30 @@ task :compile_scenario => :init do
9494
end
9595
end
9696

97+
desc 'Compile JSTD Scenario Adapter'
98+
task :compile_jstd_scenario_adapter => :init do
99+
100+
deps = [
101+
'src/jstd-scenario-adapter/angular.prefix',
102+
'src/jstd-scenario-adapter/Adapter.js',
103+
'src/jstd-scenario-adapter/angular.suffix',
104+
]
105+
106+
concat = 'cat ' + deps.flatten.join(' ')
107+
108+
File.open(path_to('jstd-scenario-adapter.js'), 'w') do |f|
109+
f.write(%x{#{concat}})
110+
end
111+
112+
# TODO(vojta) use jstd configuration when implemented
113+
# (instead of including jstd-adapter-config.js)
114+
File.open(path_to('jstd-scenario-adapter-config.js'), 'w') do |f|
115+
f.write("/**\r\n" +
116+
" * Configuration for jstd scenario adapter \n */\n" +
117+
"var jstdScenarioAdapter = {\n relativeUrlPrefix: '/build/docs/'\n};\n")
118+
end
119+
end
120+
97121

98122
desc 'Generate IE css js patch'
99123
task :generate_ie_compat => :init do
@@ -152,7 +176,7 @@ end
152176

153177

154178
desc 'Compile JavaScript'
155-
task :compile => [:init, :compile_scenario, :generate_ie_compat] do
179+
task :compile => [:init, :compile_scenario, :compile_jstd_scenario_adapter, :generate_ie_compat] do
156180

157181
deps = [
158182
'src/angular.prefix',
@@ -195,7 +219,9 @@ task :package => [:clean, :compile, :docs] do
195219
path_to('angular.js'),
196220
path_to('angular.min.js'),
197221
path_to('angular-ie-compat.js'),
198-
path_to('angular-scenario.js')
222+
path_to('angular-scenario.js'),
223+
path_to('jstd-scenario-adapter.js'),
224+
path_to('jstd-scenario-adapter-config.js'),
199225
].each do |src|
200226
dest = src.gsub(/^[^\/]+\//, '').gsub(/((\.min)?\.js)$/, "-#{version}\\1")
201227
FileUtils.cp(src, pkg_dir + '/' + dest)

docs/cookbook.deeplinking.ngdoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ In this example we have a simple app which consist of two screens:
3434

3535
The two partials are defined in the following URLs:
3636

37-
* {@link ./static/settings.html}
38-
* {@link ./static/welcome.html}
37+
* {@link ./examples/settings.html}
38+
* {@link ./examples/welcome.html}
3939

4040

4141
<doc:example>
@@ -44,8 +44,8 @@ The two partials are defined in the following URLs:
4444
AppCntl.$inject = ['$route']
4545
function AppCntl($route) {
4646
// define routes
47-
$route.when("", {template:'./static/welcome.html', controller:WelcomeCntl});
48-
$route.when("/settings", {template:'./static/settings.html', controller:SettingsCntl});
47+
$route.when("", {template:'./examples/welcome.html', controller:WelcomeCntl});
48+
$route.when("/settings", {template:'./examples/settings.html', controller:SettingsCntl});
4949
$route.parent(this);
5050

5151
// initialize the model to something useful

docs/src/gen-docs.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ var writes = callback.chain(function(){
2525
var metadata = ngdoc.metadata(docs);
2626
writer.output('docs-keywords.js', ['NG_PAGES=', JSON.stringify(metadata).replace(/{/g, '\n{'), ';'], writes.waitFor());
2727
writer.copyDir('img', writes.waitFor());
28-
writer.copyDir('static', writes.waitFor());
29-
writer.copy('index.html', writes.waitFor());
30-
writer.copy('docs.js', writes.waitFor());
31-
writer.copy('docs.css', writes.waitFor());
32-
writer.copy('doc_widgets.js', writes.waitFor());
33-
writer.copy('doc_widgets.css', writes.waitFor());
34-
writer.copy('docs-scenario.html', writes.waitFor());
28+
writer.copyDir('examples', writes.waitFor());
29+
writer.copyTpl('index.html', writes.waitFor());
30+
writer.copyTpl('docs.js', writes.waitFor());
31+
writer.copyTpl('docs.css', writes.waitFor());
32+
writer.copyTpl('doc_widgets.js', writes.waitFor());
33+
writer.copyTpl('doc_widgets.css', writes.waitFor());
34+
writer.copyTpl('docs-scenario.html', writes.waitFor());
3535
writer.output('docs-scenario.js', ngdoc.scenarios(docs), writes.waitFor());
3636
writer.output('sitemap.xml', new SiteMap(docs).render(), writes.waitFor());
3737
writer.output('robots.txt', 'Sitemap: http://docs.angularjs.org/sitemap.xml\n', writes.waitFor());
38-
writer.copy('syntaxhighlighter/shBrushJScript.js', writes.waitFor());
39-
writer.copy('syntaxhighlighter/shBrushXml.js', writes.waitFor());
40-
writer.copy('syntaxhighlighter/shCore.css', writes.waitFor());
41-
writer.copy('syntaxhighlighter/shCore.js', writes.waitFor());
42-
writer.copy('syntaxhighlighter/shThemeDefault.css', writes.waitFor());
43-
writer.copy('jquery.min.js', writes.waitFor());
38+
writer.copyTpl('syntaxhighlighter/shBrushJScript.js', writes.waitFor());
39+
writer.copyTpl('syntaxhighlighter/shBrushXml.js', writes.waitFor());
40+
writer.copyTpl('syntaxhighlighter/shCore.css', writes.waitFor());
41+
writer.copyTpl('syntaxhighlighter/shCore.js', writes.waitFor());
42+
writer.copyTpl('syntaxhighlighter/shThemeDefault.css', writes.waitFor());
43+
writer.copyTpl('jquery.min.js', writes.waitFor());
4444
});
4545
writes.onDone(function(){
4646
console.log('DONE. Generated ' + docs.length + ' pages in ' +

docs/src/templates/docs-scenario.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html xmlns:ng="http://angularjs.org" wiki:ng="http://angularjs.org">
33
<head>
44
<title>&lt;angular/&gt; Docs Scenario Runner</title>
5-
<script type="text/javascript" src="../angular-scenario.js" ng:autobind></script>
5+
<script type="text/javascript" src="../angular-scenario.js" ng:autotest></script>
66
<script type="text/javascript" src="docs-scenario.js"></script>
77
</head>
88
<body>

docs/src/writer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ exports.makeDir = function (path, callback) {
4949
})();
5050
};
5151

52-
exports.copy = function(filename, callback){
52+
exports.copyTpl = function(filename, callback) {
5353
copy('docs/src/templates/' + filename, OUTPUT_DIR + filename, callback);
5454
};
5555

example/personalLog/scenario/runner.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
33
<head>
44
<title>Personal Log Scenario Runner</title>
5-
<script type="text/javascript" src="../../../src/scenario/angular-bootstrap.js"></script>
5+
<script type="text/javascript" src="../../../src/scenario/angular-bootstrap.js" ng:autotest></script>
66
<script type="text/javascript" src="personalLogScenario.js"></script>
77
</head>
88
<body>

jsTestDriver-scenario.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
server: http://localhost:9877
2+
3+
load:
4+
- build/angular-scenario.js
5+
- build/jstd-scenario-adapter-config.js
6+
- build/jstd-scenario-adapter.js
7+
- build/docs/docs-scenario.js
8+
9+
proxy:
10+
- {matcher: "*", server: "http://localhost:8000"}

0 commit comments

Comments
 (0)
X Tutup