Skip to content

Commit

Permalink
test: enable existing aot i18n E2E test for ivy
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin committed Oct 22, 2019
1 parent 0a959ab commit 890fc14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
22 changes: 18 additions & 4 deletions tests/legacy-cli/e2e/tests/build/aot/aot-i18n.ts
Expand Up @@ -2,9 +2,10 @@ import * as express from 'express';
import { resolve } from 'path';
import { getGlobalVariable } from '../../../utils/env';
import { appendToFile, copyFile, expectFileToExist, expectFileToMatch, replaceInFile, writeFile } from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { ng, npm } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';
import { expectToFail } from '../../../utils/utils';
import { readNgVersion } from '../../../utils/version';

export default async function () {
const baseDir = 'dist/test-project';
Expand All @@ -19,6 +20,16 @@ export default async function () {
{ lang: 'de', translation: 'Hallo i18n!', outputPath: deDir },
];

if (!getGlobalVariable('argv')['ve']) {
let localizeVersion = '@angular/localize@' + readNgVersion();
if (getGlobalVariable('argv')['ng-snapshots']) {
localizeVersion = require('../../../ng-snapshot/package.json').dependencies['@angular/localize'];
}
await npm('install', localizeVersion);

await appendToFile('src/polyfills.ts', `\nimport '@angular/localize/init';`);
}

await updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].architect;
const browserConfigs = appArchitect['build'].configurations;
Expand Down Expand Up @@ -88,8 +99,11 @@ export default async function () {
for (const { lang, translation } of langTranslations) {
if (lang != 'en') {
await copyFile('src/locale/messages.xlf', `src/locale/messages.${lang}.xlf`);
await replaceInFile(`src/locale/messages.${lang}.xlf`, '<source>Hello i18n!</source>',
`<source>Hello i18n!</source>\n<target>${translation}</target>`);
await replaceInFile(
`src/locale/messages.${lang}.xlf`,
'<source>Hello i18n!</source>',
`<source>Hello i18n!</source>\n<target>${translation}</target>`,
);
}
}

Expand All @@ -109,7 +123,7 @@ export default async function () {
const server = app.listen(4200, 'localhost');
try {
// Execute without a devserver.
await ng('e2e', '--devServerTarget=');
await ng('e2e', `--configuration=${lang}`, '--devServerTarget=');
} finally {
server.close();
}
Expand Down
10 changes: 0 additions & 10 deletions tests/legacy-cli/e2e_runner.ts
Expand Up @@ -93,16 +93,6 @@ allTests = allTests
// Disabled on rc.0 due to needed sync with devkit for changes.
.filter(name => !name.endsWith('/service-worker.ts'));

if (!argv.ve) {
// These tests are disabled on the Ivy CI jobs because:
// - Ivy doesn't support the functionality yet
// - The test itself is not applicable to Ivy
// As we transition into using Ivy as the default this list should be reassessed.
allTests = allTests
// Ivy doesn't support i18n externally at the moment.
.filter(name => !name.endsWith('tests/build/aot/aot-i18n.ts'));
}

const shardId = 'shard' in argv ? argv['shard'] : null;
const nbShards = (shardId === null ? 1 : argv['nb-shards']) || 2;
const tests = allTests.filter(name => {
Expand Down

0 comments on commit 890fc14

Please sign in to comment.