Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 7568629

Browse files
authored
chore(examples): migrate SSR example to angular 7 (#471)
* chore(examples): migrate SSR example to angular 7 * fix linting on version number * migrate ssr example to angular 7 * chore(tests): add tests for ssr (#472) * chore(tests): add tests for ssr * separate build steps for readability * remove caret ^ from devDeps * fix restore externals in webpack.config * explain mode: developement
1 parent b694106 commit 7568629

File tree

16 files changed

+4179
-2081
lines changed

16 files changed

+4179
-2081
lines changed

.circleci/config.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,28 @@ jobs:
2727
command: yarn build
2828

2929
- run:
30-
name: Build examples
30+
name: Build ecommerce example
3131
command: |
3232
yarn examples:ecommerce:build
33+
- run:
34+
name: Build router example
35+
command: |
3336
yarn examples:router:build
37+
- run:
38+
name: Build media example
39+
command: |
3440
yarn examples:media:build
41+
- run:
42+
name: Build ssr example
43+
command: |
3544
yarn examples:ssr:build
45+
- run:
46+
name: Test ssr example
47+
command: |
48+
yarn examples:ssr:test
49+
- run:
50+
name: Build storybook
51+
command: |
3652
yarn examples:storybook:build
3753
3854
- save_cache:

examples/server-side-rendering/.angular-cli.json

Lines changed: 0 additions & 106 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import fetch from 'node-fetch';
2+
import { JSDOM } from 'jsdom';
3+
4+
describe('SSR', () => {
5+
describe('with no state', () => {
6+
let dom;
7+
beforeAll(async () => {
8+
const res = await fetch('http://localhost:4000/');
9+
const html = await res.text();
10+
dom = new JSDOM(html);
11+
});
12+
it('should return html with a searchbox', async () => {
13+
const searchBox = dom.window.document.querySelector('ais-search-box');
14+
expect(searchBox).toBeDefined();
15+
});
16+
it('should return html with a refinement list', async () => {
17+
const refinementList = dom.window.document.querySelector(
18+
'ais-refinement-list'
19+
);
20+
expect(refinementList).toBeDefined();
21+
});
22+
it('should return page 1', async () => {
23+
const pageSelected = dom.window.document.querySelector(
24+
'.ais-Pagination-item--selected'
25+
);
26+
expect(pageSelected.textContent.trim()).toEqual('1');
27+
});
28+
});
29+
30+
describe('with state', () => {
31+
let dom;
32+
beforeAll(async () => {
33+
const res = await fetch('http://localhost:4000/?p=2');
34+
const html = await res.text();
35+
dom = new JSDOM(html);
36+
});
37+
it('should return html on page 3', async () => {
38+
const pageSelected = dom.window.document.querySelector(
39+
'.ais-Pagination-item--selected'
40+
);
41+
expect(pageSelected.textContent.trim()).toEqual('3');
42+
});
43+
});
44+
});
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"ng-universal-demo": {
7+
"root": "",
8+
"sourceRoot": "src",
9+
"projectType": "application",
10+
"architect": {
11+
"build": {
12+
"builder": "@angular-devkit/build-angular:browser",
13+
"options": {
14+
"outputPath": "dist/browser",
15+
"index": "src/index.html",
16+
"main": "src/main.ts",
17+
"tsConfig": "src/tsconfig.app.json",
18+
"polyfills": "src/polyfills.ts",
19+
"assets": ["src/assets", "src/favicon.ico"],
20+
"styles": ["src/styles.scss"],
21+
"scripts": []
22+
},
23+
"configurations": {
24+
"production": {
25+
"optimization": true,
26+
"outputHashing": "all",
27+
"sourceMap": false,
28+
"extractCss": true,
29+
"namedChunks": false,
30+
"aot": true,
31+
"extractLicenses": true,
32+
"vendorChunk": false,
33+
"buildOptimizer": true,
34+
"fileReplacements": [
35+
{
36+
"replace": "src/environments/environment.ts",
37+
"with": "src/environments/environment.prod.ts"
38+
}
39+
]
40+
}
41+
}
42+
},
43+
"serve": {
44+
"builder": "@angular-devkit/build-angular:dev-server",
45+
"options": {
46+
"browserTarget": "ng-universal-demo:build"
47+
},
48+
"configurations": {
49+
"production": {
50+
"browserTarget": "ng-universal-demo:build:production"
51+
}
52+
}
53+
},
54+
"extract-i18n": {
55+
"builder": "@angular-devkit/build-angular:extract-i18n",
56+
"options": {
57+
"browserTarget": "ng-universal-demo:build"
58+
}
59+
},
60+
"test": {
61+
"builder": "@angular-devkit/build-angular:karma",
62+
"options": {
63+
"main": "src/test.ts",
64+
"karmaConfig": "./karma.conf.js",
65+
"polyfills": "src/polyfills.ts",
66+
"preserveSymlinks": true,
67+
"tsConfig": "src/tsconfig.spec.json",
68+
"scripts": [],
69+
"styles": ["src/styles.scss"],
70+
"assets": ["src/assets", "src/favicon.ico"]
71+
}
72+
},
73+
"lint": {
74+
"builder": "@angular-devkit/build-angular:tslint",
75+
"options": {
76+
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
77+
"exclude": ["**/node_modules/**"]
78+
}
79+
},
80+
"server": {
81+
"builder": "@angular-devkit/build-angular:server",
82+
"options": {
83+
"outputPath": "dist/server",
84+
"main": "src/main.server.ts",
85+
"tsConfig": "src/tsconfig.server.json"
86+
}
87+
}
88+
}
89+
},
90+
"ng-universal-demo-e2e": {
91+
"root": "e2e",
92+
"sourceRoot": "e2e",
93+
"projectType": "application",
94+
"architect": {
95+
"e2e": {
96+
"builder": "@angular-devkit/build-angular:protractor",
97+
"options": {
98+
"protractorConfig": "./protractor.conf.js",
99+
"devServerTarget": "ng-universal-demo:serve"
100+
}
101+
},
102+
"lint": {
103+
"builder": "@angular-devkit/build-angular:tslint",
104+
"options": {
105+
"tsConfig": ["e2e/tsconfig.e2e.json"],
106+
"exclude": ["**/node_modules/**"]
107+
}
108+
}
109+
}
110+
}
111+
},
112+
"defaultProject": "ng-universal-demo",
113+
"schematics": {
114+
"@schematics/angular:class": {
115+
"spec": false
116+
},
117+
"@schematics/angular:component": {
118+
"spec": false,
119+
"inlineStyle": true,
120+
"inlineTemplate": true,
121+
"prefix": "app",
122+
"styleext": "scss"
123+
},
124+
"@schematics/angular:directive": {
125+
"spec": false,
126+
"prefix": "app"
127+
},
128+
"@schematics/angular:guard": {
129+
"spec": false
130+
},
131+
"@schematics/angular:module": {
132+
"spec": false
133+
},
134+
"@schematics/angular:pipe": {
135+
"spec": false
136+
},
137+
"@schematics/angular:service": {
138+
"spec": false
139+
}
140+
}
141+
}

0 commit comments

Comments
 (0)