Skip to content

Commit d4f53c5

Browse files
Broccohansl
authored andcommitted
test: Update e2e tests for new project structure
1 parent 8cb2376 commit d4f53c5

File tree

113 files changed

+360
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+360
-366
lines changed

packages/@angular/cli/lib/init.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
// @ignoreDep v8-profiler
9+
import 'symbol-observable';
910
const isWarningEnabled = require('../utilities/config').isWarningEnabled;
10-
const Version = require('../upgrade/version').Version;
1111

1212
const fs = require('fs');
13-
const findUp = require('../utilities/find-up').findUp;
1413
const packageJson = require('../package.json');
1514
const path = require('path');
1615
const resolve = require('resolve');
1716
const stripIndents = require('common-tags').stripIndents;
1817
const yellow = require('chalk').yellow;
1918
const SemVer = require('semver').SemVer;
20-
const semver = require('semver');
2119
const events = require('events');
2220

23-
2421
function _fromPackageJson(cwd?: string) {
2522
cwd = cwd || process.cwd();
2623

tests/e2e/tests/basic/assets.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function () {
9090
// Add asset config in angular.json.
9191
.then(() => updateJsonFile('angular.json', workspaceJson => {
9292
const assets = [
93-
{ 'glob': '**/*', 'input': 'projects/test-project/src/folder', 'output': 'folder' },
93+
{ 'glob': '**/*', 'input': 'src/folder', 'output': 'folder' },
9494
{ 'glob': 'glob-asset.txt' },
9595
{ 'glob': 'output-asset.txt', 'output': 'output-folder' },
9696
{ 'glob': '**/*', 'input': 'node_modules/some-package/', 'output': 'package-folder' }
@@ -111,7 +111,7 @@ export default function () {
111111
.then(() => expectToFail(() => expectFileToExist('dist/assets/.gitkeep')))
112112
// Update app to test assets are present.
113113
.then(_ => !ejected && writeMultipleFiles({
114-
'projects/test-project/src/app/app.module.ts': `
114+
'src/app/app.module.ts': `
115115
import { BrowserModule } from '@angular/platform-browser';
116116
import { NgModule } from '@angular/core';
117117
import { FormsModule } from '@angular/forms';
@@ -132,7 +132,7 @@ export default function () {
132132
})
133133
export class AppModule { }
134134
`,
135-
'projects/test-project/src/app/app.component.ts': `
135+
'src/app/app.component.ts': `
136136
import { Component } from '@angular/core';
137137
import { Http, Response } from '@angular/http';
138138
@@ -152,7 +152,7 @@ export default function () {
152152
.subscribe(res => asset.content = res['_body']));
153153
}
154154
}`,
155-
'projects/test-project/src/app/app.component.spec.ts': `
155+
'src/app/app.component.spec.ts': `
156156
import { TestBed, async } from '@angular/core/testing';
157157
import { HttpModule } from '@angular/http';
158158
import { AppComponent } from './app.component';

tests/e2e/tests/basic/e2e.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@ export default function () {
2626
.then(() => ng('e2e', 'test-project-e2e'))
2727
.then(() => ng('e2e', 'test-project-e2e', '--devServerTarget=test-project:serve:production'))
2828
// Should accept different config file
29-
.then(() => moveFile('./projects/test-project-e2e/protractor.conf.js',
30-
'./projects/test-project-e2e/renamed-protractor.conf.js'))
29+
.then(() => moveFile('./e2e/protractor.conf.js',
30+
'./e2e/renamed-protractor.conf.js'))
3131
.then(() => ng('e2e', 'test-project-e2e',
32-
'--protractorConfig=projects/test-project-e2e/renamed-protractor.conf.js'))
33-
.then(() => moveFile('./projects/test-project-e2e/renamed-protractor.conf.js', './projects/test-project-e2e/protractor.conf.js'))
32+
'--protractorConfig=e2e/renamed-protractor.conf.js'))
33+
.then(() => moveFile('./e2e/renamed-protractor.conf.js', './e2e/protractor.conf.js'))
3434
// Should accept different multiple spec files
35-
.then(() => moveFile('./projects/test-project-e2e/src/app.e2e-spec.ts',
36-
'./projects/test-project-e2e/src/renamed-app.e2e-spec.ts'))
37-
.then(() => copyFile('./projects/test-project-e2e/src/renamed-app.e2e-spec.ts',
38-
'./projects/test-project-e2e/src/another-app.e2e-spec.ts'))
35+
.then(() => moveFile('./e2e/src/app.e2e-spec.ts',
36+
'./e2e/src/renamed-app.e2e-spec.ts'))
37+
.then(() => copyFile('./e2e/src/renamed-app.e2e-spec.ts',
38+
'./e2e/src/another-app.e2e-spec.ts'))
3939
.then(() => ng('e2e', 'test-project-e2e', '--specs', './e2e/renamed-app.e2e-spec.ts',
4040
'--specs', './e2e/another-app.e2e-spec.ts'))
4141
// Rename the spec back to how it was.
42-
.then(() => moveFile('./projects/test-project-e2e/src/renamed-app.e2e-spec.ts',
43-
'./projects/test-project-e2e/src/app.e2e-spec.ts'))
42+
.then(() => moveFile('./e2e/src/renamed-app.e2e-spec.ts',
43+
'./e2e/src/app.e2e-spec.ts'))
4444
// Suites block need to be added in the protractor.conf.js file to test suites
45-
.then(() => replaceInFile('projects/test-project-e2e/protractor.conf.js', `allScriptsTimeout: 11000,`,
45+
.then(() => replaceInFile('e2e/protractor.conf.js', `allScriptsTimeout: 11000,`,
4646
`allScriptsTimeout: 11000,
4747
suites: {
48-
app: './projects/test-project-e2e/src/app.e2e-spec.ts'
48+
app: './e2e/src/app.e2e-spec.ts'
4949
},
5050
`))
5151
.then(() => ng('e2e', 'test-project-e2e', '--suite=app'))
5252
// Remove suites block from protractor.conf.js file after testing suites
53-
.then(() => replaceInFile('projects/test-project-e2e/protractor.conf.js', `allScriptsTimeout: 11000,
53+
.then(() => replaceInFile('e2e/protractor.conf.js', `allScriptsTimeout: 11000,
5454
suites: {
55-
app: './projects/test-project-e2e/src/app.e2e-spec.ts'
55+
app: './e2e/src/app.e2e-spec.ts'
5656
},
5757
`, `allScriptsTimeout: 11000,`
5858
))

tests/e2e/tests/basic/rebuild.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function() {
3030
// the file, otherwise rebuilds can be too fast and fail CI.
3131
.then(() => Promise.all([
3232
waitForAnyProcessOutputToMatch(validBundleRegEx, 10000),
33-
writeFile('projects/test-project/src/app/app.module.ts', `
33+
writeFile('src/app/app.module.ts', `
3434
import { BrowserModule } from '@angular/platform-browser';
3535
import { NgModule } from '@angular/core';
3636
import { FormsModule } from '@angular/forms';
@@ -68,7 +68,7 @@ export default function() {
6868
.then(() => Promise.all([
6969
waitForAnyProcessOutputToMatch(validBundleRegEx, 10000),
7070
writeMultipleFiles({
71-
'projects/test-project/src/app/app.module.ts': `
71+
'src/app/app.module.ts': `
7272
import { BrowserModule } from '@angular/platform-browser';
7373
import { NgModule } from '@angular/core';
7474
@@ -89,7 +89,7 @@ export default function() {
8989
console.log('$$_E2E_GOLDEN_VALUE_1');
9090
export let X = '$$_E2E_GOLDEN_VALUE_2';
9191
`,
92-
'projects/test-project/src/main.ts': `
92+
'src/main.ts': `
9393
import { enableProdMode } from '@angular/core';
9494
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
9595

tests/e2e/tests/basic/scripts-array.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@ import * as path from 'path';
1515
// tslint:disable:max-line-length
1616
export default function () {
1717
return writeMultipleFiles({
18-
'projects/test-project/src/string-script.js': 'console.log(\'string-script\'); var number = 1+1;',
19-
'projects/test-project/src/zstring-script.js': 'console.log(\'zstring-script\');',
20-
'projects/test-project/src/fstring-script.js': 'console.log(\'fstring-script\');',
21-
'projects/test-project/src/ustring-script.js': 'console.log(\'ustring-script\');',
22-
'projects/test-project/src/bstring-script.js': 'console.log(\'bstring-script\');',
23-
'projects/test-project/src/astring-script.js': 'console.log(\'astring-script\');',
24-
'projects/test-project/src/cstring-script.js': 'console.log(\'cstring-script\');',
25-
'projects/test-project/src/input-script.js': 'console.log(\'input-script\');',
26-
'projects/test-project/src/lazy-script.js': 'console.log(\'lazy-script\');',
27-
'projects/test-project/src/pre-rename-script.js': 'console.log(\'pre-rename-script\');',
28-
'projects/test-project/src/pre-rename-lazy-script.js': 'console.log(\'pre-rename-lazy-script\');'
18+
'src/string-script.js': 'console.log(\'string-script\'); var number = 1+1;',
19+
'src/zstring-script.js': 'console.log(\'zstring-script\');',
20+
'src/fstring-script.js': 'console.log(\'fstring-script\');',
21+
'src/ustring-script.js': 'console.log(\'ustring-script\');',
22+
'src/bstring-script.js': 'console.log(\'bstring-script\');',
23+
'src/astring-script.js': 'console.log(\'astring-script\');',
24+
'src/cstring-script.js': 'console.log(\'cstring-script\');',
25+
'src/input-script.js': 'console.log(\'input-script\');',
26+
'src/lazy-script.js': 'console.log(\'lazy-script\');',
27+
'src/pre-rename-script.js': 'console.log(\'pre-rename-script\');',
28+
'src/pre-rename-lazy-script.js': 'console.log(\'pre-rename-lazy-script\');'
2929
})
30-
.then(() => appendToFile('projects/test-project/src/main.ts', 'import \'./string-script.js\';'))
30+
.then(() => appendToFile('src/main.ts', 'import \'./string-script.js\';'))
3131
.then(() => updateJsonFile('angular.json', configJson => {
3232
const appArchitect = configJson.projects['test-project'].architect;
3333
appArchitect.build.options.scripts = [
34-
{ input: 'projects/test-project/src/string-script.js' },
35-
{ input: 'projects/test-project/src/zstring-script.js' },
36-
{ input: 'projects/test-project/src/fstring-script.js' },
37-
{ input: 'projects/test-project/src/ustring-script.js' },
38-
{ input: 'projects/test-project/src/bstring-script.js' },
39-
{ input: 'projects/test-project/src/astring-script.js' },
40-
{ input: 'projects/test-project/src/cstring-script.js' },
41-
{ input: 'projects/test-project/src/input-script.js' },
42-
{ input: 'projects/test-project/src/lazy-script.js', lazy: true },
43-
{ input: 'projects/test-project/src/pre-rename-script.js', output: 'renamed-script' },
44-
{ input: 'projects/test-project/src/pre-rename-lazy-script.js', output: 'renamed-lazy-script', lazy: true }
34+
{ input: 'src/string-script.js' },
35+
{ input: 'src/zstring-script.js' },
36+
{ input: 'src/fstring-script.js' },
37+
{ input: 'src/ustring-script.js' },
38+
{ input: 'src/bstring-script.js' },
39+
{ input: 'src/astring-script.js' },
40+
{ input: 'src/cstring-script.js' },
41+
{ input: 'src/input-script.js' },
42+
{ input: 'src/lazy-script.js', lazy: true },
43+
{ input: 'src/pre-rename-script.js', output: 'renamed-script' },
44+
{ input: 'src/pre-rename-lazy-script.js', output: 'renamed-lazy-script', lazy: true }
4545
];
4646
}))
4747
.then(() => ng('build', '--extract-css'))

tests/e2e/tests/basic/styles-array.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import { oneLineTrim } from 'common-tags';
1010

1111
export default function () {
1212
return writeMultipleFiles({
13-
'projects/test-project/src/string-style.css': '.string-style { color: red }',
14-
'projects/test-project/src/input-style.css': '.input-style { color: red }',
15-
'projects/test-project/src/lazy-style.css': '.lazy-style { color: red }',
16-
'projects/test-project/src/pre-rename-style.css': '.pre-rename-style { color: red }',
17-
'projects/test-project/src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }'
13+
'src/string-style.css': '.string-style { color: red }',
14+
'src/input-style.css': '.input-style { color: red }',
15+
'src/lazy-style.css': '.lazy-style { color: red }',
16+
'src/pre-rename-style.css': '.pre-rename-style { color: red }',
17+
'src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }'
1818
})
1919
.then(() => updateJsonFile('angular.json', workspaceJson => {
2020
const appArchitect = workspaceJson.projects['test-project'].architect;
2121
appArchitect.build.options.styles = [
22-
{ input: 'projects/test-project/src/string-style.css' },
23-
{ input: 'projects/test-project/src/input-style.css' },
24-
{ input: 'projects/test-project/src/lazy-style.css', lazy: true },
25-
{ input: 'projects/test-project/src/pre-rename-style.css', output: 'renamed-style' },
26-
{ input: 'projects/test-project/src/pre-rename-lazy-style.css', output: 'renamed-lazy-style', lazy: true }
22+
{ input: 'src/string-style.css' },
23+
{ input: 'src/input-style.css' },
24+
{ input: 'src/lazy-style.css', lazy: true },
25+
{ input: 'src/pre-rename-style.css', output: 'renamed-style' },
26+
{ input: 'src/pre-rename-lazy-style.css', output: 'renamed-lazy-style', lazy: true }
2727
];
2828
}))
2929
.then(() => ng('build', '--extract-css'))

tests/e2e/tests/basic/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { moveFile } from '../../utils/fs';
55
export default function () {
66
// make sure both --watch=false work
77
return ng('test', '--watch=false')
8-
.then(() => moveFile('./projects/test-project/karma.conf.js',
9-
'./projects/test-project/karma.conf.bis.js'))
10-
.then(() => ng('test', '--watch=false', '--karmaConfig=projects/test-project/karma.conf.bis.js'));
8+
.then(() => moveFile('./src/karma.conf.js',
9+
'./src/karma.conf.bis.js'))
10+
.then(() => ng('test', '--watch=false', '--karmaConfig=src/karma.conf.bis.js'));
1111
}

tests/e2e/tests/build/allow-js.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { appendToFile, writeFile } from '../../utils/fs';
55
export default async function() {
66
// TODO(architect): Delete this test. It is now in devkit/build-angular.
77

8-
await writeFile('projects/test-project/src/my-js-file.js', 'console.log(1); export const a = 2;');
9-
await appendToFile('projects/test-project/src/main.ts', `
8+
await writeFile('src/my-js-file.js', 'console.log(1); export const a = 2;');
9+
await appendToFile('src/main.ts', `
1010
import { a } from './my-js-file';
1111
console.log(a);
1212
`);

tests/e2e/tests/build/aot/aot-decorators.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export default function() {
88
return;
99

1010
return ng('generate', 'component', 'test-component', '--module', 'app.module.ts')
11-
.then(() => prependToFile('projects/test-project/src/app/test-component/test-component.component.ts', `
11+
.then(() => prependToFile('src/app/test-component/test-component.component.ts', `
1212
import { Optional, SkipSelf } from '@angular/core';
1313
`))
14-
.then(() => replaceInFile('projects/test-project/src/app/test-component/test-component.component.ts',
14+
.then(() => replaceInFile('src/app/test-component/test-component.component.ts',
1515
/constructor.*/, `
1616
constructor(@Optional() @SkipSelf() public test: TestComponentComponent) {
1717
console.log(test);
1818
}
1919
`))
20-
.then(() => appendToFile('projects/test-project/src/app/app.component.html', `
20+
.then(() => appendToFile('src/app/app.component.html', `
2121
<app-test-component></app-test-component>
2222
`))
2323
.then(() => ng('build', '--aot'))

tests/e2e/tests/build/aot/aot-i18n.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export default function () {
99
// TODO(architect): Delete this test. It is now in devkit/build-angular.
1010

1111
return Promise.resolve()
12-
.then(() => createDir('projects/test-project/src/locale'))
13-
.then(() => writeFile('projects/test-project/src/locale/messages.fr.xlf', `
12+
.then(() => createDir('src/locale'))
13+
.then(() => writeFile('src/locale/messages.fr.xlf', `
1414
<?xml version="1.0" encoding="UTF-8" ?>
1515
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
1616
<file source-language="en" datatype="plaintext" original="ng2.template">
@@ -23,19 +23,19 @@ export default function () {
2323
</body>
2424
</file>
2525
</xliff>`))
26-
.then(() => appendToFile('projects/test-project/src/app/app.component.html',
26+
.then(() => appendToFile('src/app/app.component.html',
2727
'<h1 i18n="An introduction header for this sample">Hello i18n!</h1>'))
28-
.then(() => ng('build', '--aot', '--i18n-file', 'projects/test-project/src/locale/messages.fr.xlf', '--i18n-format',
28+
.then(() => ng('build', '--aot', '--i18n-file', 'src/locale/messages.fr.xlf', '--i18n-format',
2929
'xlf', '--i18n-locale', 'fr'))
3030
.then(() => expectFileToMatch('dist/test-project/main.js', /Bonjour i18n!/))
3131
.then(() => ng('build', '--aot'))
3232
.then(() => expectToFail(() => expectFileToMatch('dist/test-project/main.js', /Bonjour i18n!/)))
3333
.then(() => expectFileToMatch('dist/test-project/main.js', /Hello i18n!/))
34-
.then(() => appendToFile('projects/test-project/src/app/app.component.html',
34+
.then(() => appendToFile('src/app/app.component.html',
3535
'<p i18n>Other content</p>'))
36-
.then(() => ng('build', '--aot', '--i18nFile', 'projects/test-project/src/locale/messages.fr.xlf', '--i18nFormat',
36+
.then(() => ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf', '--i18nFormat',
3737
'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore'))
3838
.then(() => expectFileToMatch('dist/test-project/main.js', /Other content/))
39-
.then(() => expectToFail(() => ng('build', '--aot', '--i18nFile', 'projects/test-project/src/locale/messages.fr.xlf',
39+
.then(() => expectToFail(() => ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
4040
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error')));
4141
}

0 commit comments

Comments
 (0)