Skip to content

Commit 8062f7d

Browse files
ocombeIgorMinar
authored andcommitted
test: add i18n to cli-hello-world integration test (angular#23527)
PR Close angular#23527
1 parent cc6c434 commit 8062f7d

File tree

9 files changed

+110
-98
lines changed

9 files changed

+110
-98
lines changed

integration/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ to work, so they allow high-fidelity reproductions of real-world issues.
66
For this to work, we first build the Angular distribution just like we would
77
publish it to npm, then install the distribution into each app.
88

9-
To test Angular CLI applications, we generate integration tests such as `cli-hello-world`.
10-
This was generated with a current version of the CLI, and the only modification was replacement of `@angular/*` packages with their counterparts coming from `file:../../dist/packages-dist/*`.
11-
When a significant change is released in the CLI, the application should be re-generated from scratch:
9+
To test Angular CLI applications, we use the integration test `cli-hello-world`.
10+
When a significant change is released in the CLI, the application should be updated with `ng update`:
1211

1312
```bash
1413
$ cd integration
15-
$ rm -rf cli-hello-world
16-
$ ng new cli-hello-world
17-
# Edit cli-hello-world/package.json to point the @angular packages to dist/packages-dist, and preserve local mods to
14+
$ ng update
1815
# ng build
1916
# ng test
2017
# typescript version

integration/cli-hello-world/angular.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@
137137
"options": {
138138
"protractorConfig": "./protractor.conf.js",
139139
"devServerTarget": "cli-hello-world:serve"
140+
},
141+
"configurations": {
142+
"production": {
143+
"devServerTarget": "cli-hello-world:serve:production"
144+
}
140145
}
141146
},
142147
"lint": {

integration/cli-hello-world/e2e/app.e2e-spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ describe('cli-hello-world App', () => {
1111
page.navigateTo();
1212
expect(page.getParagraphText()).toEqual('Welcome to app!');
1313
});
14+
15+
it('the percent pipe should work', () => {
16+
page.navigateTo();
17+
expect(page.getPipeContent()).toEqual('100 % awesome');
18+
})
1419
});

integration/cli-hello-world/e2e/app.po.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ export class AppPage {
88
getParagraphText() {
99
return element(by.css('app-root h1')).getText();
1010
}
11+
12+
getPipeContent() {
13+
return element(by.css('app-root p')).getText();
14+
}
1115
}

integration/cli-hello-world/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"version": "0.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"ng": "ng",
7-
"start": "ng serve",
86
"build": "ng build --prod --progress false",
9-
"test": "ng test",
7+
"e2e": "ng e2e",
108
"lint": "ng lint",
11-
"e2e": "ng e2e"
9+
"ng": "ng",
10+
"postinstall": "webdriver-manager update --gecko false --standalone false $CHROMEDRIVER_VERSION_ARG",
11+
"start": "ng serve",
12+
"test": "ng test && ng e2e --webdriver-update=false && ng e2e --prod --webdriver-update=false"
1213
},
1314
"private": true,
1415
"dependencies": {
@@ -27,21 +28,21 @@
2728
},
2829
"devDependencies": {
2930
"@angular-devkit/build-angular": "~0.5.0",
30-
"@angular/cli": "^6.0.0-rc.0",
31+
"@angular/cli": "^6.0.0-rc.5",
3132
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
3233
"@angular/language-service": "file:../../dist/packages-dist/language-service",
3334
"@types/jasmine": "~2.8.3",
3435
"@types/jasminewd2": "~2.0.2",
3536
"@types/node": "~6.0.60",
36-
"codelyzer": "^4.0.1",
37+
"codelyzer": "^4.3.0",
3738
"jasmine-core": "~2.8.0",
3839
"jasmine-spec-reporter": "~4.2.1",
3940
"karma": "~2.0.0",
4041
"karma-chrome-launcher": "~2.2.0",
4142
"karma-coverage-istanbul-reporter": "^1.2.1",
4243
"karma-jasmine": "~1.1.0",
4344
"karma-jasmine-html-reporter": "^0.2.2",
44-
"protractor": "~5.1.2",
45+
"protractor": "file:../../node_modules/protractor",
4546
"ts-node": "~4.1.0",
4647
"tslint": "~5.9.1",
4748
"typescript": "file:../../node_modules/typescript"

integration/cli-hello-world/protractor.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ exports.config = {
99
'./e2e/**/*.e2e-spec.ts'
1010
],
1111
capabilities: {
12-
'browserName': 'chrome',
12+
browserName: 'chrome',
1313
chromeOptions: {
14+
binary: process.env.CHROME_BIN,
1415
args: ['--no-sandbox']
1516
}
1617
},

integration/cli-hello-world/src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ <h1>
55
</h1>
66
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
77
</div>
8+
<p>{{ 1 | percent }} awesome</p>
89
<h2>Here are some links to help you start: </h2>
910
<ul>
1011
<li>
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { BrowserModule } from '@angular/platform-browser';
2-
import { NgModule } from '@angular/core';
3-
2+
import { LOCALE_ID, NgModule } from '@angular/core';
3+
import { registerLocaleData } from '@angular/common';
4+
import localeFr from '@angular/common/locales/fr';
45

56
import { AppComponent } from './app.component';
67

8+
// adding this code to detect issues like https://github.com/angular/angular-cli/issues/10322
9+
registerLocaleData(localeFr);
710

811
@NgModule({
912
declarations: [
@@ -12,7 +15,7 @@ import { AppComponent } from './app.component';
1215
imports: [
1316
BrowserModule
1417
],
15-
providers: [],
18+
providers: [{ provide: LOCALE_ID, useValue: 'fr' }],
1619
bootstrap: [AppComponent]
1720
})
1821
export class AppModule { }

0 commit comments

Comments
 (0)