[DURACOM-309] add prod-e2e build script and use it for e2e tests

This commit is contained in:
Andrea Barbasso
2025-05-08 12:20:10 +02:00
parent ea265075c8
commit c0a5420e8b
9 changed files with 79 additions and 6 deletions

View File

@@ -102,7 +102,7 @@ jobs:
run: npm run check-circ-deps run: npm run check-circ-deps
- name: Run build - name: Run build
run: npm run build:prod run: npm run build:prod-e2e
- name: Run specs (unit tests) - name: Run specs (unit tests)
run: npm run test:headless run: npm run test:headless

View File

@@ -105,6 +105,37 @@
"maximumError": "300kb" "maximumError": "300kb"
} }
] ]
},
"production-e2e": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production-e2e.ts"
},
{
"replace": "src/config/store/devtools.ts",
"with": "src/config/store/devtools.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "3mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "200kb",
"maximumError": "300kb"
}
]
} }
} }
}, },
@@ -120,6 +151,9 @@
}, },
"production": { "production": {
"buildTarget": "dspace-angular:build:production" "buildTarget": "dspace-angular:build:production"
},
"production-e2e": {
"buildTarget": "dspace-angular:build:production-e2e"
} }
} }
}, },
@@ -181,6 +215,9 @@
"configurations": { "configurations": {
"production": { "production": {
"devServerTarget": "dspace-angular:serve:production" "devServerTarget": "dspace-angular:serve:production"
},
"production-e2e": {
"devServerTarget": "dspace-angular:serve:production-e2e"
} }
} }
}, },
@@ -215,6 +252,20 @@
"with": "src/config/store/devtools.prod.ts" "with": "src/config/store/devtools.prod.ts"
} }
] ]
},
"production-e2e": {
"sourceMap": false,
"optimization": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production-e2e.ts"
},
{
"replace": "src/config/store/devtools.ts",
"with": "src/config/store/devtools.prod.ts"
}
]
} }
} }
}, },
@@ -229,6 +280,10 @@
"production": { "production": {
"buildTarget": "dspace-angular:build:production", "buildTarget": "dspace-angular:build:production",
"serverTarget": "dspace-angular:server:production" "serverTarget": "dspace-angular:server:production"
},
"production-e2e": {
"buildTarget": "dspace-angular:build:production-e2e",
"serverTarget": "dspace-angular:server:production-e2e"
} }
} }
}, },
@@ -242,7 +297,8 @@
] ]
}, },
"configurations": { "configurations": {
"production": {} "production": {},
"production-e2e": {}
} }
}, },
"cypress-run": { "cypress-run": {
@@ -253,6 +309,9 @@
"configurations": { "configurations": {
"production": { "production": {
"devServerTarget": "dspace-angular:serve:production" "devServerTarget": "dspace-angular:serve:production"
},
"production-e2e": {
"devServerTarget": "dspace-angular:serve:production-e2e"
} }
} }
}, },

View File

@@ -16,7 +16,9 @@
"build": "ng build --configuration development", "build": "ng build --configuration development",
"build:stats": "ng build --stats-json", "build:stats": "ng build --stats-json",
"build:prod": "cross-env NODE_ENV=production npm run build:ssr", "build:prod": "cross-env NODE_ENV=production npm run build:ssr",
"build:prod-e2e": "cross-env NODE_ENV=production npm run build:ssr-e2e",
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production", "build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
"build:ssr-e2e": "ng build --configuration production-e2e && ng run dspace-angular:server:production-e2e",
"build:lint": "rimraf 'lint/dist/**/*.js' 'lint/dist/**/*.js.map' && tsc -b lint/tsconfig.json", "build:lint": "rimraf 'lint/dist/**/*.js' 'lint/dist/**/*.js.map' && tsc -b lint/tsconfig.json",
"test": "ng test --source-map=true --watch=false --configuration test", "test": "ng test --source-map=true --watch=false --configuration test",
"test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"", "test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",

View File

@@ -191,7 +191,7 @@ export class BrowserOrejimeService extends OrejimeService {
*/ */
this.translateConfiguration(); this.translateConfiguration();
if (this._window?.nativeWindow?.Cypress) { if (environment.isE2E) {
this.orejimeConfig.apps = []; this.orejimeConfig.apps = [];
} else { } else {
this.orejimeConfig.apps = this.filterConfigApps(appsToHide); this.orejimeConfig.apps = this.filterConfigApps(appsToHide);

View File

@@ -1639,7 +1639,7 @@
"cookies.consent.app.title.correlation-id": "Correlation ID", "cookies.consent.app.title.correlation-id": "Correlation ID",
"cookies.consent.app.description.correlation-id": "Allow us to track your session for debugging purposes", "cookies.consent.app.description.correlation-id": "Allow us to track your session in backend logs for support/debugging purposes",
"cookies.consent.app.title.preferences": "Preferences", "cookies.consent.app.title.preferences": "Preferences",

View File

@@ -2669,8 +2669,8 @@
// "cookies.consent.app.title.correlation-id": "Correlation ID", // "cookies.consent.app.title.correlation-id": "Correlation ID",
"cookies.consent.app.title.correlation-id": "ID di correlazione", "cookies.consent.app.title.correlation-id": "ID di correlazione",
// "cookies.consent.app.description.correlation-id": "Allow us to track your session for debugging purposes", // "cookies.consent.app.description.correlation-id": "Allow us to track your session in backend logs for support/debugging purposes",
"cookies.consent.app.description.correlation-id": "Consentici di tracciare la tua sessione per scopi di debug", "cookies.consent.app.description.correlation-id": "Ci consente di monitorare la sessione nei log di backend per supporto/debug",
// "cookies.consent.app.title.preferences": "Preferences", // "cookies.consent.app.title.preferences": "Preferences",
"cookies.consent.app.title.preferences": "Preferenze", "cookies.consent.app.title.preferences": "Preferenze",

View File

@@ -3,4 +3,5 @@ import { SSRConfig } from './ssr-config.interface';
export interface BuildConfig extends AppConfig { export interface BuildConfig extends AppConfig {
ssr: SSRConfig; ssr: SSRConfig;
isE2E?: boolean;
} }

View File

@@ -1,5 +1,6 @@
environment.*.ts environment.*.ts
!environment.production.ts !environment.production.ts
!environment.production-e2e.ts
!environment.test.ts !environment.test.ts
!environment.ts !environment.ts

View File

@@ -0,0 +1,10 @@
import { BuildConfig } from '../config/build-config.interface';
import { environment as prodEnvironment } from './environment.production';
export const environment: Partial<BuildConfig> = Object.assign(
{},
prodEnvironment,
{
isE2E: true,
},
);