Skip to content

Commit b75b21f

Browse files
filipesilvahansl
authored andcommitted
test: re-enable disabled architect build tests
1 parent 38c8463 commit b75b21f

File tree

93 files changed

+186
-552
lines changed

Some content is hidden

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

93 files changed

+186
-552
lines changed

packages/@angular/cli/utilities/build-webpack-compat.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const expectedWorkspace = {
101101
},
102102
'configurations': {
103103
'production': {
104+
'optimizationLevel': 1,
104105
'outputHashing': 'all',
105106
'sourceMap': false,
106107
'extractCss': true,
@@ -182,6 +183,7 @@ const expectedWorkspace = {
182183
},
183184
'configurations': {
184185
'production': {
186+
'optimizationLevel': 1,
185187
'outputHashing': 'all',
186188
'sourceMap': false,
187189
'extractCss': true,

packages/@angular/cli/utilities/build-webpack-compat.ts

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function createArchitectWorkspace(cliConfig: any): any {
4343
options: browserOptions,
4444
configurations: {
4545
production: {
46+
optimizationLevel: 1,
4647
outputHashing: 'all',
4748
sourceMap: false,
4849
extractCss: true,

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { updateTsConfig } from '../../utils/project';
33
import { appendToFile, writeFile } from '../../utils/fs';
44

55
export default async function() {
6-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
7-
return;
6+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
87

98
await writeFile('src/my-js-file.js', 'console.log(1); export const a = 2;');
109
await appendToFile('src/main.ts', `

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ import {expectToFail} from '../../../utils/utils';
44
import {ngVersionMatches} from '../../../utils/version';
55

66
export default function() {
7-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
7+
// TODO(architect): This behaviour seems to have changed in devkit/build-webpack. Figure out why.
88
return;
99

10-
if (!ngVersionMatches('^4.0.0')) {
11-
return Promise.resolve();
12-
}
13-
1410
return ng('generate', 'component', 'test-component', '--module', 'app.module.ts')
1511
.then(() => prependToFile('src/app/test-component/test-component.component.ts', `
1612
import { Optional, SkipSelf } from '@angular/core';

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

+13-34
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import {ng} from '../../../utils/process';
2-
import {expectFileToMatch, writeFile, createDir, appendToFile, readFile} from '../../../utils/fs';
3-
import {expectToFail} from '../../../utils/utils';
4-
import {Version} from '../../../../../packages/@angular/cli/upgrade/version';
5-
import {SemVer} from 'semver';
1+
import { ng } from '../../../utils/process';
2+
import { expectFileToMatch, writeFile, createDir, appendToFile, readFile } from '../../../utils/fs';
3+
import { expectToFail } from '../../../utils/utils';
4+
import { Version } from '../../../../../packages/@angular/cli/upgrade/version';
5+
import { SemVer } from 'semver';
66

7-
export default function() {
8-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
9-
return;
7+
export default function () {
8+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
109

1110
return Promise.resolve()
1211
.then(() => createDir('src/locale'))
@@ -25,37 +24,17 @@ export default function() {
2524
</xliff>`))
2625
.then(() => appendToFile('src/app/app.component.html',
2726
'<h1 i18n="An introduction header for this sample">Hello i18n!</h1>'))
28-
.then(() => ng('build', '--aot', '--i18n-file', 'src/locale/messages.fr.xlf', '--i18n-format',
27+
.then(() => ng('build', '--aot', '--i18n-file', 'locale/messages.fr.xlf', '--i18n-format',
2928
'xlf', '--i18n-locale', 'fr'))
3029
.then(() => expectFileToMatch('dist/main.js', /Bonjour i18n!/))
3130
.then(() => ng('build', '--aot'))
3231
.then(() => expectToFail(() => expectFileToMatch('dist/main.js', /Bonjour i18n!/)))
3332
.then(() => expectFileToMatch('dist/main.js', /Hello i18n!/))
3433
.then(() => appendToFile('src/app/app.component.html',
3534
'<p i18n>Other content</p>'))
36-
.then(() => readFile('node_modules/@angular/compiler-cli/package.json')
37-
.then((compilerCliPackage): any => {
38-
const version = new Version(JSON.parse(compilerCliPackage).version);
39-
if (version.major === 2) {
40-
return expectToFail(() => ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
41-
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore'));
42-
} else {
43-
return ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf', '--i18nFormat',
44-
'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore')
45-
.then(() => expectFileToMatch('dist/main.js', /Other content/));
46-
}
47-
})
48-
)
49-
.then(() => readFile('node_modules/@angular/compiler-cli/package.json')
50-
.then((compilerCliPackage): any => {
51-
const version = new Version(JSON.parse(compilerCliPackage).version);
52-
if (version.isGreaterThanOrEqualTo(new SemVer('4.2.0-beta.0')) || version.major === 2) {
53-
return expectToFail(() => ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
54-
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error'));
55-
} else {
56-
return ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
57-
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error');
58-
}
59-
})
60-
);
35+
.then(() => ng('build', '--aot', '--i18nFile', 'locale/messages.fr.xlf', '--i18nFormat',
36+
'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore'))
37+
.then(() => expectFileToMatch('dist/main.js', /Other content/))
38+
.then(() => expectToFail(() => ng('build', '--aot', '--i18nFile', 'locale/messages.fr.xlf',
39+
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error')));
6140
}

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

-48
This file was deleted.

tests/e2e/tests/build/aot/exclude.ts

-38
This file was deleted.

tests/e2e/tests/build/base-href.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
import { ng } from '../../utils/process';
2-
import { expectFileToMatch, replaceInFile } from '../../utils/fs';
3-
import { updateJsonFile } from '../../utils/project';
2+
import { expectFileToMatch } from '../../utils/fs';
43

54

65
export default function() {
7-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
8-
return;
6+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
97

108
return ng('build', '--base-href', '/myUrl')
11-
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
12-
.then(() => updateJsonFile('.angular-cli.json', configJson => {
13-
const app = configJson['apps'][0];
14-
app['baseHref'] = '/myUrl';
15-
}))
16-
.then(() => ng('build'))
17-
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
18-
.then(() => replaceInFile('src/index.html', 'href="/"', 'href=""'))
19-
.then(() => ng('build'))
209
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
2110
}

tests/e2e/tests/build/build-errors.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const extraErrors = [
1212
];
1313

1414
export default function () {
15-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
16-
return;
15+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
1716

1817
if (process.platform.startsWith('win')) {
1918
return Promise.resolve();

tests/e2e/tests/build/build-optimizer.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { expectToFail } from '../../utils/utils';
44

55

66
export default function () {
7-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
8-
return;
7+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
98

109
return ng('build', '--aot', '--build-optimizer')
1110
.then(() => expectToFail(() => expectFileToMatch('dist/main.js', /\.decorators =/)))
12-
.then(() => ng('build', '--optimization-level', '1'))
11+
.then(() => ng('build', '--prod'))
1312
.then(() => expectToFail(() => expectFileToExist('dist/vendor.js')))
1413
.then(() => expectToFail(() => expectFileToMatch('dist/main.js', /\.decorators =/)));
1514
}

tests/e2e/tests/build/chunk-hash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function validateHashes(
4242
}
4343

4444
export default function() {
45-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
45+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
4646
return;
4747

4848
let oldHashes: Map<string, string>;

tests/e2e/tests/build/css-urls.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const imgSvg = `
1515
`;
1616

1717
export default function () {
18-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
19-
return;
18+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
2019

2120
return Promise.resolve()
2221
// Verify absolute/relative paths in global/component css.
@@ -41,16 +40,16 @@ export default function () {
4140
.then(() => expectFileToMatch('dist/styles.css',
4241
/url\('\/assets\/global-img-absolute\.svg'\)/))
4342
.then(() => expectFileToMatch('dist/styles.css',
44-
/global-img-relative\.[0-9a-f]{20}\.png/))
43+
/global-img-relative\.png/))
4544
.then(() => expectFileToMatch('dist/main.js',
4645
'/assets/component-img-absolute.svg'))
4746
.then(() => expectFileToMatch('dist/main.js',
48-
/component-img-relative\.[0-9a-f]{20}\.png/))
47+
/component-img-relative\.png/))
4948
// Check files are correctly created.
5049
.then(() => expectToFail(() => expectFileToExist('dist/global-img-absolute.svg')))
5150
.then(() => expectToFail(() => expectFileToExist('dist/component-img-absolute.svg')))
52-
.then(() => expectFileMatchToExist('./dist', /global-img-relative\.[0-9a-f]{20}\.png/))
53-
.then(() => expectFileMatchToExist('./dist', /component-img-relative\.[0-9a-f]{20}\.png/))
51+
.then(() => expectFileMatchToExist('./dist', /global-img-relative\.png/))
52+
.then(() => expectFileMatchToExist('./dist', /component-img-relative\.png/))
5453
// Check urls with deploy-url scheme are used as is.
5554
.then(() => ng('build', '--base-href=/base/', '--deploy-url=http://deploy.url/',
5655
'--extract-css'))
@@ -78,31 +77,31 @@ export default function () {
7877
.then(() => expectFileToMatch('dist/styles.css',
7978
'/base/deploy/assets/global-img-absolute.svg'))
8079
.then(() => expectFileToMatch('dist/styles.css',
81-
/global-img-relative\.[0-9a-f]{20}\.png/))
80+
/global-img-relative\.png/))
8281
.then(() => expectFileToMatch('dist/main.js',
8382
'/base/deploy/assets/component-img-absolute.svg'))
8483
.then(() => expectFileToMatch('dist/main.js',
85-
/deploy\/component-img-relative\.[0-9a-f]{20}\.png/))
84+
/deploy\/component-img-relative\.png/))
8685
// Check with identical base-href and deploy-url flags.
8786
.then(() => ng('build', '--base-href=/base/', '--deploy-url=/base/',
8887
'--extract-css', '--aot'))
8988
.then(() => expectFileToMatch('dist/styles.css',
9089
'/base/assets/global-img-absolute.svg'))
9190
.then(() => expectFileToMatch('dist/styles.css',
92-
/global-img-relative\.[0-9a-f]{20}\.png/))
91+
/global-img-relative\.png/))
9392
.then(() => expectFileToMatch('dist/main.js',
9493
'/base/assets/component-img-absolute.svg'))
9594
.then(() => expectFileToMatch('dist/main.js',
96-
/\/base\/component-img-relative\.[0-9a-f]{20}\.png/))
95+
/\/base\/component-img-relative\.png/))
9796
// Check with only base-href flag.
9897
.then(() => ng('build', '--base-href=/base/',
9998
'--extract-css', '--aot'))
10099
.then(() => expectFileToMatch('dist/styles.css',
101100
'/base/assets/global-img-absolute.svg'))
102101
.then(() => expectFileToMatch('dist/styles.css',
103-
/global-img-relative\.[0-9a-f]{20}\.png/))
102+
/global-img-relative\.png/))
104103
.then(() => expectFileToMatch('dist/main.js',
105104
'/base/assets/component-img-absolute.svg'))
106105
.then(() => expectFileToMatch('dist/main.js',
107-
/component-img-relative\.[0-9a-f]{20}\.png/));
106+
/component-img-relative\.png/));
108107
}

tests/e2e/tests/build/delete-output-path.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {deleteFile, expectFileToExist} from '../../utils/fs';
44
import {getGlobalVariable} from '../../utils/env';
55

66
export default function() {
7-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
8-
return;
7+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
98

109
// Skip this in ejected tests.
1110
if (getGlobalVariable('argv').eject) {
@@ -16,7 +15,7 @@ export default function() {
1615
// This is supposed to fail since there's a missing file
1716
.then(() => deleteFile('src/app/app.component.ts'))
1817
// The build fails but we don't delete the output of the previous build.
19-
.then(() => expectToFail(() => ng('build', '--no-delete-output-path')))
18+
.then(() => expectToFail(() => ng('build', '--delete-output-path=false')))
2019
.then(() => expectFileToExist('dist'))
2120
// By default, output path is always cleared.
2221
.then(() => expectToFail(() => ng('build')))

tests/e2e/tests/build/deploy-url.ts

+9-17
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { getGlobalVariable } from '../../utils/env';
66

77

88
export default function () {
9-
// TODO(architect): reenable, validate, then delete this test. It is now in devkit/build-webpack.
10-
return;
9+
// TODO(architect): Delete this test. It is now in devkit/build-webpack.
1110

1211
return Promise.resolve()
1312
.then(() => writeMultipleFiles({
@@ -19,26 +18,19 @@ export default function () {
1918
.then(() => expectFileToMatch('dist/index.html', 'deployUrl/main.js'))
2019
// verify --deploy-url isn't applied to extracted css urls
2120
.then(() => expectFileToMatch('dist/styles.css',
22-
/url\(['"]?more\.[0-9a-f]{20}\.png['"]?\)/))
21+
/url\(['"]?more\.png['"]?\)/))
2322
.then(() => ng('build', '--deploy-url=http://example.com/some/path/', '--extract-css'))
2423
.then(() => expectFileToMatch('dist/index.html', 'http://example.com/some/path/main.js'))
25-
// verify option also works in config
26-
.then(() => updateJsonFile('.angular-cli.json', configJson => {
27-
const app = configJson['apps'][0];
28-
app['deployUrl'] = 'config-deployUrl/';
29-
}))
30-
.then(() => ng('build'))
31-
.then(() => expectFileToMatch('dist/index.html', 'config-deployUrl/main.js'))
3224
// verify --deploy-url is applied to non-extracted css urls
3325
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false'))
3426
.then(() => expectFileToMatch('dist/styles.js',
35-
/\(['"]?deployUrl\/more\.[0-9a-f]{20}\.png['"]?\)/))
27+
/\(['"]?deployUrl\/more\.png['"]?\)/))
3628
.then(() => expectFileToMatch('dist/runtime.js',
3729
/__webpack_require__\.p = "deployUrl\/";/))
38-
// verify slash is appended to the end of --deploy-url if missing
39-
.then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
40-
// skip this in ejected tests
41-
.then(() => getGlobalVariable('argv').eject
42-
? Promise.resolve()
43-
: expectFileToMatch('dist/runtime.js', /__webpack_require__\.p = "deployUrl\/";/));
30+
// // verify slash is appended to the end of --deploy-url if missing
31+
// .then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
32+
// // skip this in ejected tests
33+
// .then(() => getGlobalVariable('argv').eject
34+
// ? Promise.resolve()
35+
// : expectFileToMatch('dist/runtime.js', /__webpack_require__\.p = "deployUrl\/";/));
4436
}

0 commit comments

Comments
 (0)