Skip to content

Commit c0a5420

Browse files
author
Andrea Barbasso
committed
[DURACOM-309] add prod-e2e build script and use it for e2e tests
1 parent ea26507 commit c0a5420

9 files changed

Lines changed: 79 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
run: npm run check-circ-deps
103103

104104
- name: Run build
105-
run: npm run build:prod
105+
run: npm run build:prod-e2e
106106

107107
- name: Run specs (unit tests)
108108
run: npm run test:headless

angular.json

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,37 @@
105105
"maximumError": "300kb"
106106
}
107107
]
108+
},
109+
"production-e2e": {
110+
"fileReplacements": [
111+
{
112+
"replace": "src/environments/environment.ts",
113+
"with": "src/environments/environment.production-e2e.ts"
114+
},
115+
{
116+
"replace": "src/config/store/devtools.ts",
117+
"with": "src/config/store/devtools.prod.ts"
118+
}
119+
],
120+
"optimization": true,
121+
"outputHashing": "all",
122+
"namedChunks": false,
123+
"aot": true,
124+
"extractLicenses": true,
125+
"vendorChunk": false,
126+
"buildOptimizer": true,
127+
"budgets": [
128+
{
129+
"type": "initial",
130+
"maximumWarning": "3mb",
131+
"maximumError": "5mb"
132+
},
133+
{
134+
"type": "anyComponentStyle",
135+
"maximumWarning": "200kb",
136+
"maximumError": "300kb"
137+
}
138+
]
108139
}
109140
}
110141
},
@@ -120,6 +151,9 @@
120151
},
121152
"production": {
122153
"buildTarget": "dspace-angular:build:production"
154+
},
155+
"production-e2e": {
156+
"buildTarget": "dspace-angular:build:production-e2e"
123157
}
124158
}
125159
},
@@ -181,6 +215,9 @@
181215
"configurations": {
182216
"production": {
183217
"devServerTarget": "dspace-angular:serve:production"
218+
},
219+
"production-e2e": {
220+
"devServerTarget": "dspace-angular:serve:production-e2e"
184221
}
185222
}
186223
},
@@ -215,6 +252,20 @@
215252
"with": "src/config/store/devtools.prod.ts"
216253
}
217254
]
255+
},
256+
"production-e2e": {
257+
"sourceMap": false,
258+
"optimization": true,
259+
"fileReplacements": [
260+
{
261+
"replace": "src/environments/environment.ts",
262+
"with": "src/environments/environment.production-e2e.ts"
263+
},
264+
{
265+
"replace": "src/config/store/devtools.ts",
266+
"with": "src/config/store/devtools.prod.ts"
267+
}
268+
]
218269
}
219270
}
220271
},
@@ -229,6 +280,10 @@
229280
"production": {
230281
"buildTarget": "dspace-angular:build:production",
231282
"serverTarget": "dspace-angular:server:production"
283+
},
284+
"production-e2e": {
285+
"buildTarget": "dspace-angular:build:production-e2e",
286+
"serverTarget": "dspace-angular:server:production-e2e"
232287
}
233288
}
234289
},
@@ -242,7 +297,8 @@
242297
]
243298
},
244299
"configurations": {
245-
"production": {}
300+
"production": {},
301+
"production-e2e": {}
246302
}
247303
},
248304
"cypress-run": {
@@ -253,6 +309,9 @@
253309
"configurations": {
254310
"production": {
255311
"devServerTarget": "dspace-angular:serve:production"
312+
},
313+
"production-e2e": {
314+
"devServerTarget": "dspace-angular:serve:production-e2e"
256315
}
257316
}
258317
},

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"build": "ng build --configuration development",
1717
"build:stats": "ng build --stats-json",
1818
"build:prod": "cross-env NODE_ENV=production npm run build:ssr",
19+
"build:prod-e2e": "cross-env NODE_ENV=production npm run build:ssr-e2e",
1920
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
21+
"build:ssr-e2e": "ng build --configuration production-e2e && ng run dspace-angular:server:production-e2e",
2022
"build:lint": "rimraf 'lint/dist/**/*.js' 'lint/dist/**/*.js.map' && tsc -b lint/tsconfig.json",
2123
"test": "ng test --source-map=true --watch=false --configuration test",
2224
"test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",

src/app/shared/cookies/browser-orejime.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class BrowserOrejimeService extends OrejimeService {
191191
*/
192192
this.translateConfiguration();
193193

194-
if (this._window?.nativeWindow?.Cypress) {
194+
if (environment.isE2E) {
195195
this.orejimeConfig.apps = [];
196196
} else {
197197
this.orejimeConfig.apps = this.filterConfigApps(appsToHide);

src/assets/i18n/en.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@
16391639

16401640
"cookies.consent.app.title.correlation-id": "Correlation ID",
16411641

1642-
"cookies.consent.app.description.correlation-id": "Allow us to track your session for debugging purposes",
1642+
"cookies.consent.app.description.correlation-id": "Allow us to track your session in backend logs for support/debugging purposes",
16431643

16441644
"cookies.consent.app.title.preferences": "Preferences",
16451645

src/assets/i18n/it.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,8 +2669,8 @@
26692669
// "cookies.consent.app.title.correlation-id": "Correlation ID",
26702670
"cookies.consent.app.title.correlation-id": "ID di correlazione",
26712671

2672-
// "cookies.consent.app.description.correlation-id": "Allow us to track your session for debugging purposes",
2673-
"cookies.consent.app.description.correlation-id": "Consentici di tracciare la tua sessione per scopi di debug",
2672+
// "cookies.consent.app.description.correlation-id": "Allow us to track your session in backend logs for support/debugging purposes",
2673+
"cookies.consent.app.description.correlation-id": "Ci consente di monitorare la sessione nei log di backend per supporto/debug",
26742674

26752675
// "cookies.consent.app.title.preferences": "Preferences",
26762676
"cookies.consent.app.title.preferences": "Preferenze",

src/config/build-config.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { SSRConfig } from './ssr-config.interface';
33

44
export interface BuildConfig extends AppConfig {
55
ssr: SSRConfig;
6+
isE2E?: boolean;
67
}

src/environments/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
environment.*.ts
22

33
!environment.production.ts
4+
!environment.production-e2e.ts
45
!environment.test.ts
56
!environment.ts
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { BuildConfig } from '../config/build-config.interface';
2+
import { environment as prodEnvironment } from './environment.production';
3+
4+
export const environment: Partial<BuildConfig> = Object.assign(
5+
{},
6+
prodEnvironment,
7+
{
8+
isE2E: true,
9+
},
10+
);

0 commit comments

Comments
 (0)