Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

chore(website): fix website tests #4080

Merged
merged 1 commit into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ gulp.task('tsc:spec', function(done) {
runSpawn(done, 'node', ['node_modules/typescript/bin/tsc', '-p', 'ts_spec_config.json']);
});

gulp.task('tsc:es5', function(done) {
runSpawn(done, './scripts/compile_to_es5.sh');
});

gulp.task('compile_to_es5', function(done) {
runSequence('checkVersion', 'tsc:es5', 'built:copy', done);
});

gulp.task('prepublish', function(done) {
runSequence('checkVersion', 'jshint', 'tsc', 'built:copy', done);
});
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"pretest": "gulp pretest",
"start": "cd testapp && npm start",
"test": "node scripts/test.js",
"website": "cd website && npm start"
"website": "cd website && npm start",
"compile_to_es5": "gulp compile_to_es5"
},
"license": "MIT",
"engines": {
Expand Down
39 changes: 39 additions & 0 deletions scripts/compile_to_es5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
cd "$( dirname "${BASH_SOURCE[0]}" )/.."

# Check number of parameters
if [ "$#" -gt 0 ]; then
echo "Usage: ./scripts/compile_to_es5.sh"
exit 1
fi

echo "Getting types for es6 promises..."
npm install @types/es6-promise
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Couldn't get types for es6 promises."
echo -e "\033[0m" 1>&2 # Normal Color
exit 1
fi

echo "Compiling down to es5..."
node node_modules/typescript/bin/tsc --target es5
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Couldn't compile for es5."
echo -e "\033[0m" 1>&2 # Normal Color
npm remove @types/es6-promise
exit 1
fi

echo "Uninstalling types for es6 promises..."
npm remove @types/es6-promise
if [ $? -ne 0 ]; then
echo -e "\033[0;33m" 1>&2 # Yellow
echo "Warning: couldn't uninstall types for es6 promises"
echo -e "\033[0m" 1>&2 # Normal Color
fi

echo -e "\033[0;32m" # Green
echo "Compiled to es5"
echo -e "\033[0m" 1>&2 # Normal Color
21 changes: 2 additions & 19 deletions scripts/generate-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,13 @@ if [ $? -ne 0 ]; then
exit 1
fi

echo "Getting types for es6 promises..."
npm install @types/es6-promise
# Compile to es5
./scripts/compile_to_es5.sh
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Couldn't get types for es6 promises."
echo -e "\033[0m" 1>&2 # Normal Color
git checkout "${EXEC_BRANCH}"
exit 1
fi

echo "Compiling down to es5..."
node node_modules/typescript/bin/tsc --target es5
if [ $? -ne 0 ]; then
echo -e "\033[0;31m" 1>&2 # Red
echo "Couldn't compile for es5."
echo -e "\033[0m" 1>&2 # Normal Color
npm remove @types/es6-promise
git checkout "${EXEC_BRANCH}"
exit 1
fi

# Remove unneeded type
npm remove @types/es6-promise

echo "Installing the testapp..."
npm run install_testapp
if [ $? -ne 0 ]; then
Expand Down
1 change: 1 addition & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Generates the documentation for the protractor website.
## How to run

```shell
npm run compile_to_es5
cd website/
npm install
npm run build
Expand Down
20 changes: 19 additions & 1 deletion website/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,34 @@ gulp.task('clean', function(cb) {

// Generate the table of contents json file using Dgeni. This is output to
// docgen/build/toc.json
gulp.task('dgeni', function() {
gulp.task('dgeni', function(done) {
var packages = [require('./docgen/dgeni-config')];
var dgeni = new Dgeni(packages);

dgeni.generate().then(function(docs) {
console.log(docs.length, 'docs generated');
}).then(function() {
// Check that docs were generated correctly
var toc = require('./docgen/build/toc.json');
if (!toc || !Array.isArray(toc.items)) {
return Promise.reject('Generated toc.json file is malformatted');
}
var isBrowser = function(item) {
return item.alias == 'browser';
};
if (!toc.items.some(isBrowser)) {
return Promise.reject('Generated toc.json missing docs for Protractor function.');
}

// Copy files over
gulp.src(['docgen/build/*.json'])
.pipe(gulp.dest(paths.outputDir + '/apiDocs'));
done();
}).catch(function(error) {
done(
'Could not generate docs. ' +
'Try running `npm run compile_to_es5` from Protractor\'s root folder.\n' +
'Origonal Error: ' + error);
});
});

Expand Down
3 changes: 0 additions & 3 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@
"prestart": "npm install && npm run prepublish",
"start": "gulp liveReload",
"test": "node run-tests.js"
},
"engines": {
"node": ">=4.0.0 <5.0.x"
}
}
13 changes: 9 additions & 4 deletions website/test/e2e/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ describe('Api', function() {

// Then ensure the child functions are shown.
expect(apiPage.getChildFunctionNames()).toEqual([
'clone', 'all', 'filter', 'get', 'first', 'last', '$$', 'count', 'locator',
'then', 'each', 'map', 'reduce', 'evaluate', 'allowAnimations']);
'clone', 'all', 'filter', 'get', 'first', 'last', '$$', 'count',
'isPresent', 'locator', 'then', 'each', 'map', 'reduce', 'evaluate',
'allowAnimations']);
});

it('should show element functions', function() {
Expand All @@ -114,12 +115,13 @@ describe('Api', function() {

// Then ensure the child functions are shown.
expect(apiPage.getChildFunctionNames()).toEqual([
'getProcessedConfig', 'forkNewDriverInstance', 'restart',
'angularAppRoot', 'waitForAngularEnabled', 'getProcessedConfig',
'forkNewDriverInstance', 'restart', 'restartSync',
'useAllAngular2AppRoots', 'waitForAngular', 'findElement', 'findElements',
'isElementPresent', 'addMockModule', 'clearMockModules',
'removeMockModule', 'getRegisteredMockModules', 'get', 'refresh',
'navigate', 'setLocation', 'getLocationAbsUrl', 'debugger', 'enterRepl',
'pause', 'wrapDriver']);
'explore', 'pause', 'controlFlowIsEnabled']);
});

it('should view inherited function', function() {
Expand All @@ -140,6 +142,9 @@ describe('Api', function() {
'protractor objects', function() {
expect(apiPage.getAdultNames().then(function(names) {
return names[names.indexOf('browser') + 1];
})).toBe('ExtendedWebDriver');
expect(apiPage.getAdultNames().then(function(names) {
return names[names.indexOf('ExtendedWebDriver') + 1];
})).toBe('webdriver.WebDriver');
});
});
2 changes: 1 addition & 1 deletion website/test/unit/api-controller-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('ApiCtrl', function() {
var item = scope.items[0];
expect(item.title).toBe('name2');
expect(item.base.name).toBe('name1');
expect(item.base.items.length).toBe(1);
expect(item.base.children.length).toBe(1);
});
});

Expand Down