refactor(examples/e2e_test): Ts'ifying examples/e2_test
Translate AtScript in examples/e2e_test to TypeScript. Closes #2294
This commit is contained in:
parent
40150379ae
commit
5035a42287
|
@ -0,0 +1,5 @@
|
||||||
|
library examples.e2e_test.hello_world.hello_world_spec;
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
describe('hello world', function () {
|
|
||||||
|
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
describe('hello world', function() {
|
||||||
|
|
||||||
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
describe('static reflection', function() {
|
describe('static reflection', function() {
|
||||||
var URL = 'examples/src/hello_world/index.html';
|
var URL = 'examples/src/hello_world/index.html';
|
||||||
|
@ -9,14 +10,14 @@ describe('hello world', function () {
|
||||||
it('should greet', function() {
|
it('should greet', function() {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
expect(getComponentText('hello-app', '.greeting')).toBe('hello world!');
|
expect(getComponentText('hello-app', '.greeting')).toEqual('hello world!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change greeting', function() {
|
it('should change greeting', function() {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
clickComponentButton('hello-app', '.changeButton');
|
clickComponentButton('hello-app', '.changeButton');
|
||||||
expect(getComponentText('hello-app', '.greeting')).toBe('howdy world!');
|
expect(getComponentText('hello-app', '.greeting')).toEqual('howdy world!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,23 +27,25 @@ describe('hello world', function () {
|
||||||
it('should greet', function() {
|
it('should greet', function() {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
expect(getComponentText('hello-app', '.greeting')).toBe('hello world!');
|
expect(getComponentText('hello-app', '.greeting')).toEqual('hello world!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change greeting', function() {
|
it('should change greeting', function() {
|
||||||
browser.get(URL);
|
browser.get(URL);
|
||||||
|
|
||||||
clickComponentButton('hello-app', '.changeButton');
|
clickComponentButton('hello-app', '.changeButton');
|
||||||
expect(getComponentText('hello-app', '.greeting')).toBe('howdy world!');
|
expect(getComponentText('hello-app', '.greeting')).toEqual('howdy world!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function getComponentText(selector, innerSelector) {
|
function getComponentText(selector, innerSelector) {
|
||||||
return browser.executeScript('return document.querySelector("'+selector+'").querySelector("'+innerSelector+'").textContent');
|
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
|
||||||
|
innerSelector + '").textContent');
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickComponentButton(selector, innerSelector) {
|
function clickComponentButton(selector, innerSelector) {
|
||||||
return browser.executeScript('return document.querySelector("'+selector+'").querySelector("'+innerSelector+'").click()');
|
return browser.executeScript('return document.querySelector("' + selector + '").querySelector("' +
|
||||||
|
innerSelector + '").click()');
|
||||||
}
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
library examples.e2e_test.key_events.key_events_spec;
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
}
|
|
@ -1,53 +1,52 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
describe('key_events', function () {
|
|
||||||
|
describe('key_events', function() {
|
||||||
|
|
||||||
var URL = 'examples/src/key_events/index.html';
|
var URL = 'examples/src/key_events/index.html';
|
||||||
|
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
beforeEach(() => {
|
beforeEach(() => { browser.get(URL); });
|
||||||
browser.get(URL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display correct key names', function() {
|
it('should display correct key names', function() {
|
||||||
var firstArea = element.all(by.css('.sample-area')).get(0);
|
var firstArea = element.all(by.css('.sample-area')).get(0);
|
||||||
expect(firstArea.getText()).toBe('(none)');
|
expect(firstArea.getText()).toEqual('(none)');
|
||||||
|
|
||||||
// testing different key categories:
|
// testing different key categories:
|
||||||
firstArea.sendKeys(protractor.Key.ENTER);
|
firstArea.sendKeys(protractor.Key.ENTER);
|
||||||
expect(firstArea.getText()).toBe('enter');
|
expect(firstArea.getText()).toEqual('enter');
|
||||||
|
|
||||||
firstArea.sendKeys(protractor.Key.SHIFT, protractor.Key.ENTER);
|
firstArea.sendKeys(protractor.Key.SHIFT, protractor.Key.ENTER);
|
||||||
expect(firstArea.getText()).toBe('shift.enter');
|
expect(firstArea.getText()).toEqual('shift.enter');
|
||||||
|
|
||||||
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.SHIFT, protractor.Key.ENTER);
|
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.SHIFT, protractor.Key.ENTER);
|
||||||
expect(firstArea.getText()).toBe('control.shift.enter');
|
expect(firstArea.getText()).toEqual('control.shift.enter');
|
||||||
|
|
||||||
firstArea.sendKeys(' ');
|
firstArea.sendKeys(' ');
|
||||||
expect(firstArea.getText()).toBe('space');
|
expect(firstArea.getText()).toEqual('space');
|
||||||
|
|
||||||
// It would not work with a letter which position depends on the keyboard layout (ie AZERTY vs
|
// It would not work with a letter which position depends on the keyboard layout (ie AZERTY vs
|
||||||
// QWERTY), see https://code.google.com/p/chromedriver/issues/detail?id=553
|
// QWERTY), see https://code.google.com/p/chromedriver/issues/detail?id=553
|
||||||
firstArea.sendKeys('u');
|
firstArea.sendKeys('u');
|
||||||
expect(firstArea.getText()).toBe('u');
|
expect(firstArea.getText()).toEqual('u');
|
||||||
|
|
||||||
firstArea.sendKeys(protractor.Key.CONTROL, 'b');
|
firstArea.sendKeys(protractor.Key.CONTROL, 'b');
|
||||||
expect(firstArea.getText()).toBe('control.b');
|
expect(firstArea.getText()).toEqual('control.b');
|
||||||
|
|
||||||
firstArea.sendKeys(protractor.Key.F1);
|
firstArea.sendKeys(protractor.Key.F1);
|
||||||
expect(firstArea.getText()).toBe('f1');
|
expect(firstArea.getText()).toEqual('f1');
|
||||||
|
|
||||||
firstArea.sendKeys(protractor.Key.ALT, protractor.Key.F1);
|
firstArea.sendKeys(protractor.Key.ALT, protractor.Key.F1);
|
||||||
expect(firstArea.getText()).toBe('alt.f1');
|
expect(firstArea.getText()).toEqual('alt.f1');
|
||||||
|
|
||||||
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.F1);
|
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.F1);
|
||||||
expect(firstArea.getText()).toBe('control.f1');
|
expect(firstArea.getText()).toEqual('control.f1');
|
||||||
|
|
||||||
// There is an issue with protractor.Key.NUMPAD0 (and other NUMPADx):
|
// There is an issue with protractor.Key.NUMPAD0 (and other NUMPADx):
|
||||||
// chromedriver does not correctly set the location property on the event to
|
// chromedriver does not correctly set the location property on the event to
|
||||||
// specify that the key is on the numeric keypad (event.location = 3)
|
// specify that the key is on the numeric keypad (event.location = 3)
|
||||||
// so the following test fails:
|
// so the following test fails:
|
||||||
// firstArea.sendKeys(protractor.Key.NUMPAD0);
|
// firstArea.sendKeys(protractor.Key.NUMPAD0);
|
||||||
// expect(firstArea.getText()).toBe('0');
|
// expect(firstArea.getText()).toEqual('0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should correctly react to the specified key', function() {
|
it('should correctly react to the specified key', function() {
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.button_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,10 +1,10 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
describe('md-button', function () {
|
describe('md-button', function() {
|
||||||
var url = 'examples/src/material/button/index.html';
|
var url = 'examples/src/material/button/index.html';
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
beforeEach(() => { browser.get(url); });
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
// Buttons are broken right now, see https://github.com/angular/angular/issues/1602
|
// Buttons are broken right now, see https://github.com/angular/angular/issues/1602
|
||||||
});
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.checkbox_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,18 +0,0 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
|
||||||
|
|
||||||
describe('md-checkbox', function () {
|
|
||||||
var url = 'examples/src/material/checkbox/index.html';
|
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
|
||||||
|
|
||||||
it('should toggle a checkbox', function() {
|
|
||||||
var checkbox = element.all(by.css('md-checkbox')).first();
|
|
||||||
|
|
||||||
checkbox.click();
|
|
||||||
expect(checkbox.getAttribute('aria-checked')).toBe('true');
|
|
||||||
|
|
||||||
checkbox.click();
|
|
||||||
expect(checkbox.getAttribute('aria-checked')).toBe('false');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
|
describe('md-checkbox', function() {
|
||||||
|
var url = 'examples/src/material/checkbox/index.html';
|
||||||
|
|
||||||
|
beforeEach(() => { browser.get(url); });
|
||||||
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
|
it('should toggle a checkbox', function() {
|
||||||
|
var checkbox = element.all(by.css('md-checkbox')).first();
|
||||||
|
|
||||||
|
checkbox.click();
|
||||||
|
expect(checkbox.getAttribute('aria-checked')).toEqual('true');
|
||||||
|
|
||||||
|
checkbox.click();
|
||||||
|
expect(checkbox.getAttribute('aria-checked')).toEqual('false');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.dialog_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,19 +1,19 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
describe('md-dialog', function () {
|
describe('md-dialog', function() {
|
||||||
var url = 'examples/src/material/dialog/index.html';
|
var url = 'examples/src/material/dialog/index.html';
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
beforeEach(() => { browser.get(url); });
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should open a dialog', function() {
|
it('should open a dialog', function() {
|
||||||
var openButton = element(by.id('open'));
|
var openButton = element(by.id('open'));
|
||||||
openButton.click();
|
openButton.click();
|
||||||
expect(element(by.css('.md-dialog')).isPresent()).toBe(true);
|
expect(element(by.css('.md-dialog')).isPresent()).toEqual(true);
|
||||||
|
|
||||||
var dialog = element(by.css('.md-dialog'));
|
var dialog = element(by.css('.md-dialog'));
|
||||||
dialog.sendKeys(protractor.Key.ESCAPE);
|
dialog.sendKeys(protractor.Key.ESCAPE);
|
||||||
|
|
||||||
expect(element(by.css('.md-dialog')).isPresent()).toBe(false);
|
expect(element(by.css('.md-dialog')).isPresent()).toEqual(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.grid_list_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,10 +1,10 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
describe('md-grid-list', function () {
|
describe('md-grid-list', function() {
|
||||||
var url = 'examples/src/material/grid_list/index.html';
|
var url = 'examples/src/material/grid_list/index.html';
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
beforeEach(() => { browser.get(url); });
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should set tiles into different positions', () => {
|
it('should set tiles into different positions', () => {
|
||||||
var tiles = element.all(by.css('md-grid-list#complex md-grid-tile'));
|
var tiles = element.all(by.css('md-grid-list#complex md-grid-tile'));
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.input_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,17 +1,16 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
describe('md-input', function () {
|
describe('md-input', function() {
|
||||||
var url = 'examples/src/material/input/index.html';
|
var url = 'examples/src/material/input/index.html';
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
beforeEach(() => { browser.get(url); });
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should enter a value to the input', () => {
|
it('should enter a value to the input', () => {
|
||||||
var input = element.all(by.css('md-input-container input')).first();
|
var input = element.all(by.css('md-input-container input')).first();
|
||||||
|
|
||||||
input.sendKeys('Hello');
|
input.sendKeys('Hello');
|
||||||
|
|
||||||
expect(input.getAttribute('value')).toBe('Hello');
|
expect(input.getAttribute('value')).toEqual('Hello');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.progress_linear_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,10 +1,10 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
describe('md-progress-linear', function () {
|
describe('md-progress-linear', function() {
|
||||||
var url = 'examples/src/material/progress-linear/index.html';
|
var url = 'examples/src/material/progress-linear/index.html';
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
beforeEach(() => { browser.get(url); });
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should increment and decrement progress', function() {
|
it('should increment and decrement progress', function() {
|
||||||
var progressBar = element.all(by.css('md-progress-linear')).first();
|
var progressBar = element.all(by.css('md-progress-linear')).first();
|
|
@ -0,0 +1,3 @@
|
||||||
|
library examples.e2e_test.material.radio_spec;
|
||||||
|
|
||||||
|
main() {}
|
|
@ -1,10 +1,10 @@
|
||||||
var testUtil = require('angular2/src/test_lib/e2e_util');
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
describe('md-radio-button', function () {
|
describe('md-radio-button', function() {
|
||||||
var url = 'examples/src/material/radio/index.html';
|
var url = 'examples/src/material/radio/index.html';
|
||||||
|
|
||||||
beforeEach(() => { browser.get(url); });
|
beforeEach(() => { browser.get(url); });
|
||||||
afterEach(testUtil.verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should check one radio button and then check another', () => {
|
it('should check one radio button and then check another', () => {
|
||||||
var standaloneRadios = element.all(by.css('[name="element"]'));
|
var standaloneRadios = element.all(by.css('[name="element"]'));
|
||||||
|
@ -12,10 +12,10 @@ describe('md-radio-button', function () {
|
||||||
var lastRadio = standaloneRadios.last();
|
var lastRadio = standaloneRadios.last();
|
||||||
|
|
||||||
firstRadio.click();
|
firstRadio.click();
|
||||||
expect(firstRadio.getAttribute('aria-checked')).toBe('true');
|
expect(firstRadio.getAttribute('aria-checked')).toEqual('true');
|
||||||
|
|
||||||
lastRadio.click();
|
lastRadio.click();
|
||||||
expect(firstRadio.getAttribute('aria-checked')).toBe('false');
|
expect(firstRadio.getAttribute('aria-checked')).toEqual('false');
|
||||||
expect(lastRadio.getAttribute('aria-checked')).toBe('true');
|
expect(lastRadio.getAttribute('aria-checked')).toEqual('true');
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -0,0 +1,5 @@
|
||||||
|
library examples.e2e_test.sourcemap.sourcemap_spec;
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
|
import * as testUtil from 'angular2/src/test_lib/e2e_util';
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var sourceMap = require('source-map');
|
var sourceMap = require('source-map');
|
||||||
|
|
||||||
describe('sourcemaps', function () {
|
describe('sourcemaps', function() {
|
||||||
var URL = 'examples/src/sourcemap/index.html';
|
var URL = 'examples/src/sourcemap/index.html';
|
||||||
|
|
||||||
it('should map sources', function() {
|
it('should map sources', function() {
|
||||||
|
@ -27,23 +29,19 @@ describe('sourcemaps', function () {
|
||||||
expect(errorColumn).not.toBeNull();
|
expect(errorColumn).not.toBeNull();
|
||||||
|
|
||||||
|
|
||||||
var sourceMapData = fs.readFileSync(
|
var sourceMapData = fs.readFileSync('dist/js/prod/es5/examples/src/sourcemap/index.js.map');
|
||||||
'dist/js/prod/es5/examples/src/sourcemap/index.js.map');
|
|
||||||
var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData));
|
var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData));
|
||||||
|
|
||||||
var originalPosition = decoder.originalPositionFor({
|
var originalPosition = decoder.originalPositionFor({line: errorLine, column: errorColumn});
|
||||||
line: errorLine,
|
|
||||||
column: errorColumn
|
|
||||||
});
|
|
||||||
|
|
||||||
var finalMapData = fs.readFileSync(
|
var finalMapData = fs.readFileSync('dist/js/prod/es6/examples/src/sourcemap/index.es6.map');
|
||||||
'dist/js/prod/es6/examples/src/sourcemap/index.es6.map');
|
|
||||||
var finalDecoder = new sourceMap.SourceMapConsumer(JSON.parse(finalMapData));
|
var finalDecoder = new sourceMap.SourceMapConsumer(JSON.parse(finalMapData));
|
||||||
|
|
||||||
var finalPosition = finalDecoder.originalPositionFor(originalPosition);
|
var finalPosition = finalDecoder.originalPositionFor(originalPosition);
|
||||||
|
|
||||||
var sourceCodeLines = fs.readFileSync('modules/examples/src/sourcemap/index.ts',
|
var sourceCodeLines =
|
||||||
{encoding: 'UTF-8'}).split('\n');
|
fs.readFileSync('modules/examples/src/sourcemap/index.ts', {encoding: 'UTF-8'})
|
||||||
|
.split('\n');
|
||||||
expect(sourceCodeLines[finalPosition.line - 1])
|
expect(sourceCodeLines[finalPosition.line - 1])
|
||||||
.toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
|
.toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
|
||||||
});
|
});
|
Loading…
Reference in New Issue