Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enable existing aot i18n E2E test for ivy #15913

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
8 changes: 0 additions & 8 deletions tests/legacy-cli/e2e_runner.ts
Expand Up @@ -97,14 +97,6 @@ if (argv.ve) {
// Remove Ivy specific tests
allTests = allTests
.filter(name => !name.includes('tests/i18n/ivy-localize-'));
} else {
// 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;
Expand Down