From 125847ba2ccada0895e56123bed86f70f63bdb67 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 25 Oct 2019 21:38:15 +0200 Subject: [PATCH] test: fix platform server e2e test --- tests/legacy-cli/e2e/ng-snapshot/package.json | 1 + .../build/build-app-shell-with-schematic.ts | 2 +- .../e2e/tests/build/build-app-shell.ts | 3 +- .../e2e/tests/build/platform-server.ts | 2 +- .../e2e/tests/i18n/ivy-localize-server.ts | 28 +++++++++++++------ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/legacy-cli/e2e/ng-snapshot/package.json b/tests/legacy-cli/e2e/ng-snapshot/package.json index 1706e4f9c36c..640048cc6173 100644 --- a/tests/legacy-cli/e2e/ng-snapshot/package.json +++ b/tests/legacy-cli/e2e/ng-snapshot/package.json @@ -12,6 +12,7 @@ "@angular/localize": "github:angular/localize-builds#33c7636c27a4f147607cf5a9dbf8cc1f7235da99", "@angular/platform-browser": "github:angular/platform-browser-builds#ce1e659ca1354adb43047933dcd4197cbd96174f", "@angular/platform-browser-dynamic": "github:angular/platform-browser-dynamic-builds#d8664790dc89a1d30cf18788479cd5ccb1fb5ee6", + "@angular/platform-server": "github:angular/platform-server-builds#278e7555b936edf9d9292f75e67ba5b233bd285a", "@angular/router": "github:angular/router-builds#f75458fdef2ef233080332e0a96f4d0cbfad93e9" } } \ No newline at end of file diff --git a/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts b/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts index f610c4d2bcc7..6f5c87f12b84 100644 --- a/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts +++ b/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts @@ -11,7 +11,7 @@ export default async function () { await updateJsonFile('package.json', packageJson => { const dependencies = packageJson['dependencies']; dependencies['@angular/platform-server'] = getGlobalVariable('argv')['ng-snapshots'] - ? 'github:angular/platform-server-builds' + ? require('../../ng-snapshot/package.json').dependencies['@angular/platform-server'] : readNgVersion(); }); diff --git a/tests/legacy-cli/e2e/tests/build/build-app-shell.ts b/tests/legacy-cli/e2e/tests/build/build-app-shell.ts index 796ea16e1395..e74e4f1de8c0 100644 --- a/tests/legacy-cli/e2e/tests/build/build-app-shell.ts +++ b/tests/legacy-cli/e2e/tests/build/build-app-shell.ts @@ -9,7 +9,8 @@ export default function() { let platformServerVersion = readNgVersion(); if (getGlobalVariable('argv')['ng-snapshots']) { - platformServerVersion = 'github:angular/platform-server-builds'; + platformServerVersion = require('../../ng-snapshot/package.json') + .dependencies['@angular/platform-server']; } return Promise.resolve() diff --git a/tests/legacy-cli/e2e/tests/build/platform-server.ts b/tests/legacy-cli/e2e/tests/build/platform-server.ts index d9fb520a7f2c..75096038424c 100644 --- a/tests/legacy-cli/e2e/tests/build/platform-server.ts +++ b/tests/legacy-cli/e2e/tests/build/platform-server.ts @@ -14,7 +14,7 @@ export default async function () { await updateJsonFile('package.json', packageJson => { const dependencies = packageJson['dependencies']; dependencies['@angular/platform-server'] = getGlobalVariable('argv')['ng-snapshots'] - ? 'github:angular/platform-server-builds' + ? require('../../ng-snapshot/package.json').dependencies['@angular/platform-server'] : readNgVersion(); }); diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts index 835e55fdebac..860cc0abc079 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts @@ -9,23 +9,34 @@ import { replaceInFile, writeFile, } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { ng, silentNpm } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; import { readNgVersion } from '../../utils/version'; +const snapshots = require('../../ng-snapshot/package.json'); + export default async function () { - let localizeVersion = '@angular/localize@' + readNgVersion(); - if (getGlobalVariable('argv')['ng-snapshots']) { - localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize']; - } + const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots']; - await npm('install', `${localizeVersion}`); + await updateJsonFile('package.json', packageJson => { + const dependencies = packageJson['dependencies']; + dependencies['@angular/localize'] = isSnapshotBuild + ? snapshots.dependencies['@angular/localize'] + : readNgVersion(); + }); // Add universal to the project - await ng('add', '@nguniversal/express-engine@9.0.0-next.6'); + await ng('add', '@nguniversal/express-engine@9.0.0-next.6', '--skip-install'); + + if (isSnapshotBuild) { + await updateJsonFile('package.json', packageJson => { + const dependencies = packageJson['dependencies']; + dependencies['@angular/platform-server'] = snapshots.dependencies['@angular/platform-server']; + }); + } - await npm('run', 'webdriver-update'); + await silentNpm('install'); const serverbaseDir = 'dist/test-project/server'; const serverBuildArgs = ['run', 'test-project:server']; @@ -34,7 +45,6 @@ export default async function () { const langTranslations = [ { lang: 'en-US', translation: 'Hello i18n!' }, { lang: 'fr', translation: 'Bonjour i18n!' }, - { lang: 'de', translation: 'Hallo i18n!' }, ]; await updateJsonFile('angular.json', workspaceJson => {