test(platform-server): add initial e2e tests for platform-server (#15061)
This commit is contained in:

committed by
Chuck Jazdzewski

parent
13686bb518
commit
ff60c041f6
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {browser, by, element} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from './util';
|
||||
|
||||
describe('Hello world E2E Tests', function() {
|
||||
it('should display: Hello world!', function() {
|
||||
// Load the page without waiting for Angular since it is not boostrapped automatically.
|
||||
browser.driver.get(browser.baseUrl + 'helloworld');
|
||||
|
||||
const style = browser.driver.findElement(by.css('style[ng-transition="hlw"]'));
|
||||
expect(style.getText()).not.toBeNull();
|
||||
|
||||
// Test the contents from the server.
|
||||
const serverDiv = browser.driver.findElement(by.css('div'));
|
||||
expect(serverDiv.getText()).toEqual('Hello world!');
|
||||
|
||||
// Bootstrap the client side app.
|
||||
browser.executeScript('doBootstrap()');
|
||||
|
||||
// Retest the contents after the client bootstraps.
|
||||
expect(element(by.css('div')).getText()).toEqual('Hello world!');
|
||||
|
||||
// Make sure the server styles got replaced by client side ones.
|
||||
expect(element(by.css('style[ng-transition="hlw"]')).isPresent()).toBe(false);
|
||||
expect(element(by.css('style')).getText()).toBe('');
|
||||
|
||||
// Make sure there were no client side errors.
|
||||
verifyNoBrowserErrors();
|
||||
});
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
exports.config = {
|
||||
specs: ['../built/e2e/*-spec.js'],
|
||||
capabilities: {
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
args: ['--no-sandbox'],
|
||||
binary: process.env.CHROME_BIN,
|
||||
}
|
||||
},
|
||||
directConnect: true,
|
||||
baseUrl: 'http://localhost:9876/',
|
||||
framework: 'jasmine',
|
||||
useAllAngular2AppRoots: true
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "../built/e2e",
|
||||
"types": ["jasmine"],
|
||||
// TODO(alexeagle): was required for Protractor 4.0.11
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
25
packages/platform-server/integrationtest/e2e/util.ts
Normal file
25
packages/platform-server/integrationtest/e2e/util.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
/* tslint:disable:no-console */
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
declare var browser: any;
|
||||
declare var expect: any;
|
||||
|
||||
export function verifyNoBrowserErrors() {
|
||||
browser.manage().logs().get('browser').then(function(browserLog: any[]) {
|
||||
const errors: any[] = [];
|
||||
browserLog.filter(logEntry => {
|
||||
const msg = logEntry.message;
|
||||
console.log('>> ' + msg);
|
||||
if (logEntry.level.value >= webdriver.logging.Level.INFO.value) {
|
||||
errors.push(msg);
|
||||
}
|
||||
});
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user