Skip to content

Commit

Permalink
test: re-enable disabled architect build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and hansl committed Mar 16, 2018
1 parent 38c8463 commit b75b21f
Show file tree
Hide file tree
Showing 93 changed files with 186 additions and 552 deletions.
2 changes: 2 additions & 0 deletions packages/@angular/cli/utilities/build-webpack-compat.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const expectedWorkspace = {
},
'configurations': {
'production': {
'optimizationLevel': 1,
'outputHashing': 'all',
'sourceMap': false,
'extractCss': true,
Expand Down Expand Up @@ -182,6 +183,7 @@ const expectedWorkspace = {
},
'configurations': {
'production': {
'optimizationLevel': 1,
'outputHashing': 'all',
'sourceMap': false,
'extractCss': true,
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/utilities/build-webpack-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function createArchitectWorkspace(cliConfig: any): any {
options: browserOptions,
configurations: {
production: {
optimizationLevel: 1,
outputHashing: 'all',
sourceMap: false,
extractCss: true,
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/tests/build/allow-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { updateTsConfig } from '../../utils/project';
import { appendToFile, writeFile } from '../../utils/fs';

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

await writeFile('src/my-js-file.js', 'console.log(1); export const a = 2;');
await appendToFile('src/main.ts', `
Expand Down
6 changes: 1 addition & 5 deletions tests/e2e/tests/build/aot/aot-decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import {expectToFail} from '../../../utils/utils';
import {ngVersionMatches} from '../../../utils/version';

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

if (!ngVersionMatches('^4.0.0')) {
return Promise.resolve();
}

return ng('generate', 'component', 'test-component', '--module', 'app.module.ts')
.then(() => prependToFile('src/app/test-component/test-component.component.ts', `
import { Optional, SkipSelf } from '@angular/core';
Expand Down
47 changes: 13 additions & 34 deletions tests/e2e/tests/build/aot/aot-i18n.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {ng} from '../../../utils/process';
import {expectFileToMatch, writeFile, createDir, appendToFile, readFile} from '../../../utils/fs';
import {expectToFail} from '../../../utils/utils';
import {Version} from '../../../../../packages/@angular/cli/upgrade/version';
import {SemVer} from 'semver';
import { ng } from '../../../utils/process';
import { expectFileToMatch, writeFile, createDir, appendToFile, readFile } from '../../../utils/fs';
import { expectToFail } from '../../../utils/utils';
import { Version } from '../../../../../packages/@angular/cli/upgrade/version';
import { SemVer } from 'semver';

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

return Promise.resolve()
.then(() => createDir('src/locale'))
Expand All @@ -25,37 +24,17 @@ export default function() {
</xliff>`))
.then(() => appendToFile('src/app/app.component.html',
'<h1 i18n="An introduction header for this sample">Hello i18n!</h1>'))
.then(() => ng('build', '--aot', '--i18n-file', 'src/locale/messages.fr.xlf', '--i18n-format',
.then(() => ng('build', '--aot', '--i18n-file', 'locale/messages.fr.xlf', '--i18n-format',
'xlf', '--i18n-locale', 'fr'))
.then(() => expectFileToMatch('dist/main.js', /Bonjour i18n!/))
.then(() => ng('build', '--aot'))
.then(() => expectToFail(() => expectFileToMatch('dist/main.js', /Bonjour i18n!/)))
.then(() => expectFileToMatch('dist/main.js', /Hello i18n!/))
.then(() => appendToFile('src/app/app.component.html',
'<p i18n>Other content</p>'))
.then(() => readFile('node_modules/@angular/compiler-cli/package.json')
.then((compilerCliPackage): any => {
const version = new Version(JSON.parse(compilerCliPackage).version);
if (version.major === 2) {
return expectToFail(() => ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore'));
} else {
return ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf', '--i18nFormat',
'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore')
.then(() => expectFileToMatch('dist/main.js', /Other content/));
}
})
)
.then(() => readFile('node_modules/@angular/compiler-cli/package.json')
.then((compilerCliPackage): any => {
const version = new Version(JSON.parse(compilerCliPackage).version);
if (version.isGreaterThanOrEqualTo(new SemVer('4.2.0-beta.0')) || version.major === 2) {
return expectToFail(() => ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error'));
} else {
return ng('build', '--aot', '--i18nFile', 'src/locale/messages.fr.xlf',
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error');
}
})
);
.then(() => ng('build', '--aot', '--i18nFile', 'locale/messages.fr.xlf', '--i18nFormat',
'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'ignore'))
.then(() => expectFileToMatch('dist/main.js', /Other content/))
.then(() => expectToFail(() => ng('build', '--aot', '--i18nFile', 'locale/messages.fr.xlf',
'--i18nFormat', 'xlf', '--i18n-locale', 'fr', '--i18n-missing-translation', 'error')));
}
48 changes: 0 additions & 48 deletions tests/e2e/tests/build/aot/aot-rebuild.ts

This file was deleted.

38 changes: 0 additions & 38 deletions tests/e2e/tests/build/aot/exclude.ts

This file was deleted.

15 changes: 2 additions & 13 deletions tests/e2e/tests/build/base-href.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import { ng } from '../../utils/process';
import { expectFileToMatch, replaceInFile } from '../../utils/fs';
import { updateJsonFile } from '../../utils/project';
import { expectFileToMatch } from '../../utils/fs';


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

return ng('build', '--base-href', '/myUrl')
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['baseHref'] = '/myUrl';
}))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/))
.then(() => replaceInFile('src/index.html', 'href="/"', 'href=""'))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/index.html', /<base href="\/myUrl">/));
}
3 changes: 1 addition & 2 deletions tests/e2e/tests/build/build-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const extraErrors = [
];

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

if (process.platform.startsWith('win')) {
return Promise.resolve();
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/tests/build/build-optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { expectToFail } from '../../utils/utils';


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

return ng('build', '--aot', '--build-optimizer')
.then(() => expectToFail(() => expectFileToMatch('dist/main.js', /\.decorators =/)))
.then(() => ng('build', '--optimization-level', '1'))
.then(() => ng('build', '--prod'))
.then(() => expectToFail(() => expectFileToExist('dist/vendor.js')))
.then(() => expectToFail(() => expectFileToMatch('dist/main.js', /\.decorators =/)));
}
2 changes: 1 addition & 1 deletion tests/e2e/tests/build/chunk-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function validateHashes(
}

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

let oldHashes: Map<string, string>;
Expand Down
23 changes: 11 additions & 12 deletions tests/e2e/tests/build/css-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const imgSvg = `
`;

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

return Promise.resolve()
// Verify absolute/relative paths in global/component css.
Expand All @@ -41,16 +40,16 @@ export default function () {
.then(() => expectFileToMatch('dist/styles.css',
/url\('\/assets\/global-img-absolute\.svg'\)/))
.then(() => expectFileToMatch('dist/styles.css',
/global-img-relative\.[0-9a-f]{20}\.png/))
/global-img-relative\.png/))
.then(() => expectFileToMatch('dist/main.js',
'/assets/component-img-absolute.svg'))
.then(() => expectFileToMatch('dist/main.js',
/component-img-relative\.[0-9a-f]{20}\.png/))
/component-img-relative\.png/))
// Check files are correctly created.
.then(() => expectToFail(() => expectFileToExist('dist/global-img-absolute.svg')))
.then(() => expectToFail(() => expectFileToExist('dist/component-img-absolute.svg')))
.then(() => expectFileMatchToExist('./dist', /global-img-relative\.[0-9a-f]{20}\.png/))
.then(() => expectFileMatchToExist('./dist', /component-img-relative\.[0-9a-f]{20}\.png/))
.then(() => expectFileMatchToExist('./dist', /global-img-relative\.png/))
.then(() => expectFileMatchToExist('./dist', /component-img-relative\.png/))
// Check urls with deploy-url scheme are used as is.
.then(() => ng('build', '--base-href=/base/', '--deploy-url=http://deploy.url/',
'--extract-css'))
Expand Down Expand Up @@ -78,31 +77,31 @@ export default function () {
.then(() => expectFileToMatch('dist/styles.css',
'/base/deploy/assets/global-img-absolute.svg'))
.then(() => expectFileToMatch('dist/styles.css',
/global-img-relative\.[0-9a-f]{20}\.png/))
/global-img-relative\.png/))
.then(() => expectFileToMatch('dist/main.js',
'/base/deploy/assets/component-img-absolute.svg'))
.then(() => expectFileToMatch('dist/main.js',
/deploy\/component-img-relative\.[0-9a-f]{20}\.png/))
/deploy\/component-img-relative\.png/))
// Check with identical base-href and deploy-url flags.
.then(() => ng('build', '--base-href=/base/', '--deploy-url=/base/',
'--extract-css', '--aot'))
.then(() => expectFileToMatch('dist/styles.css',
'/base/assets/global-img-absolute.svg'))
.then(() => expectFileToMatch('dist/styles.css',
/global-img-relative\.[0-9a-f]{20}\.png/))
/global-img-relative\.png/))
.then(() => expectFileToMatch('dist/main.js',
'/base/assets/component-img-absolute.svg'))
.then(() => expectFileToMatch('dist/main.js',
/\/base\/component-img-relative\.[0-9a-f]{20}\.png/))
/\/base\/component-img-relative\.png/))
// Check with only base-href flag.
.then(() => ng('build', '--base-href=/base/',
'--extract-css', '--aot'))
.then(() => expectFileToMatch('dist/styles.css',
'/base/assets/global-img-absolute.svg'))
.then(() => expectFileToMatch('dist/styles.css',
/global-img-relative\.[0-9a-f]{20}\.png/))
/global-img-relative\.png/))
.then(() => expectFileToMatch('dist/main.js',
'/base/assets/component-img-absolute.svg'))
.then(() => expectFileToMatch('dist/main.js',
/component-img-relative\.[0-9a-f]{20}\.png/));
/component-img-relative\.png/));
}
5 changes: 2 additions & 3 deletions tests/e2e/tests/build/delete-output-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {deleteFile, expectFileToExist} from '../../utils/fs';
import {getGlobalVariable} from '../../utils/env';

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

// Skip this in ejected tests.
if (getGlobalVariable('argv').eject) {
Expand All @@ -16,7 +15,7 @@ export default function() {
// This is supposed to fail since there's a missing file
.then(() => deleteFile('src/app/app.component.ts'))
// The build fails but we don't delete the output of the previous build.
.then(() => expectToFail(() => ng('build', '--no-delete-output-path')))
.then(() => expectToFail(() => ng('build', '--delete-output-path=false')))
.then(() => expectFileToExist('dist'))
// By default, output path is always cleared.
.then(() => expectToFail(() => ng('build')))
Expand Down
26 changes: 9 additions & 17 deletions tests/e2e/tests/build/deploy-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { getGlobalVariable } from '../../utils/env';


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

return Promise.resolve()
.then(() => writeMultipleFiles({
Expand All @@ -19,26 +18,19 @@ export default function () {
.then(() => expectFileToMatch('dist/index.html', 'deployUrl/main.js'))
// verify --deploy-url isn't applied to extracted css urls
.then(() => expectFileToMatch('dist/styles.css',
/url\(['"]?more\.[0-9a-f]{20}\.png['"]?\)/))
/url\(['"]?more\.png['"]?\)/))
.then(() => ng('build', '--deploy-url=http://example.com/some/path/', '--extract-css'))
.then(() => expectFileToMatch('dist/index.html', 'http://example.com/some/path/main.js'))
// verify option also works in config
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['deployUrl'] = 'config-deployUrl/';
}))
.then(() => ng('build'))
.then(() => expectFileToMatch('dist/index.html', 'config-deployUrl/main.js'))
// verify --deploy-url is applied to non-extracted css urls
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false'))
.then(() => expectFileToMatch('dist/styles.js',
/\(['"]?deployUrl\/more\.[0-9a-f]{20}\.png['"]?\)/))
/\(['"]?deployUrl\/more\.png['"]?\)/))
.then(() => expectFileToMatch('dist/runtime.js',
/__webpack_require__\.p = "deployUrl\/";/))
// verify slash is appended to the end of --deploy-url if missing
.then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
// skip this in ejected tests
.then(() => getGlobalVariable('argv').eject
? Promise.resolve()
: expectFileToMatch('dist/runtime.js', /__webpack_require__\.p = "deployUrl\/";/));
// // verify slash is appended to the end of --deploy-url if missing
// .then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
// // skip this in ejected tests
// .then(() => getGlobalVariable('argv').eject
// ? Promise.resolve()
// : expectFileToMatch('dist/runtime.js', /__webpack_require__\.p = "deployUrl\/";/));
}

0 comments on commit b75b21f

Please sign in to comment.