Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions .azure/azure-pipelines.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ extends:
parameters:
break: false
jobs:
- job: test
displayName: 'Test'
steps:
- template: /templates/test/docker.yml@stratus-templates
parameters:
dockerComposeFilePaths:
- '$(Pipeline.Workspace)/github/docker-compose-unit-tests.yml'
- '$(Pipeline.Workspace)/github/docker-compose-integration-tests.yml'
dockerfilePath: $(dockerfilePath)
imageName: $(imageName)
tag: $(tag)
- job: unit_test
displayName: Unit tests
steps:
- template: /templates/test/npm.yml@stratus-templates
parameters:
nodeVersion: 20
buildCommand: run build:shared
76 changes: 36 additions & 40 deletions .azure/azure-pipelines.ref.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,42 @@ extends:
parameters:
break: false
jobs:
- job: test
displayName: 'Docker Compose Test'
steps:
- template: /templates/test/docker.yml@stratus-templates
parameters:
imageName: $(imageName)
dockerfilePath: $(dockerfilePath)
tag: $(tag)
dockerComposeFilePaths:
- '$(Pipeline.Workspace)/github/docker-compose-unit-tests.yml'
- '$(Pipeline.Workspace)/github/docker-compose-integration-tests.yml'
- job: unit_test
displayName: Unit tests
steps:
- template: /templates/test/npm.yml@stratus-templates
parameters:
nodeVersion: 20
buildCommand: run build:shared

- job: sonarqube
displayName: 'SonarQube'
steps:
- template: /templates/codescan/sonarqube.yml@stratus-templates
parameters:
projectName: $(imageName)
- job: sonarqube
displayName: 'SonarQube'
steps:
- template: /templates/codescan/sonarqube.yml@stratus-templates
parameters:
projectName: $(imageName)

- job: build_push
dependsOn:
- sonarqube
- test
displayName: 'Build and Push image'
steps:
- template: /templates/docker/push.yml@stratus-templates
parameters:
build: true
break: false
dockerFilePath: $(dockerfilePath)
imageName: $(imageName)
tag: $(tag)
- job: build_push
dependsOn:
- sonarqube
- unit_test
displayName: 'Build and Push image'
steps:
- template: /templates/docker/push.yml@stratus-templates
parameters:
build: true
break: false
dockerFilePath: $(dockerfilePath)
imageName: $(imageName)
tag: $(tag)

- job: update
dependsOn:
- build_push
displayName: 'Update App Service'
steps:
- template: /templates/app-service/update-image.yml@stratus-templates
parameters:
parametersFileName: $(parametersFileName)
imageName: $(imageName)
tag: $(tag)
- job: update
dependsOn:
- build_push
displayName: 'Update App Service'
steps:
- template: /templates/app-service/update-image.yml@stratus-templates
parameters:
parametersFileName: $(parametersFileName)
imageName: $(imageName)
tag: $(tag)
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": ["@kth/eslint-config-kth"],
"rules": {
"react/prop-types": "warn"
}
"react/prop-types": "warn",
},
"settings": {
"import/resolver": {
"webpack": { "config": "webpack.config.js" },
},
},
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ test/performance-artillery-dev/docker-compose.yml

# Developer notes
notes/
notes*
notes*

# test coverage
coverage
26 changes: 6 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

ENV=$1
ENV="${1:-dev}"

function echoYellow() {
MSG=$1
Expand All @@ -12,21 +13,9 @@ echoYellow "|--------------------------------------------------------|"
echoYellow "| Building the application with Bash and Webpack |"
echoYellow "|--------------------------------------------------------|\n"

#if [ "$ENV" == "dev" ]; then
# export NODE_ENV=development
#else
# export NODE_ENV=production
#fi

#echoYellow " 1. Cleaning up & copying files"
echoYellow " 1. Copying files"

# Removing the dist folder. Important for development environement.
#if [ -d ./dist ]; then
# echoYellow " -> Removing all files from the /dist folder"
# rm -rf ./dist/*
#fi

echoYellow " -> Creating the server view folders"
mkdir -p ./server/views/system ./server/views/layouts

Expand All @@ -36,7 +25,7 @@ cp -R ./node_modules/@kth/kth-node-web-common/lib/handlebars/pages/views/. serve
echoYellow " -> Copying errorLayout.handlebars to server/views/layouts folder"
cp -R ./node_modules/@kth/kth-node-web-common/lib/handlebars/pages/layouts/. server/views/layouts

if [ "$ENV" == "prod" ]; then
if [[ "$ENV" == "prod" ]]; then
echo
echoYellow " 2. Bundling the client app into the /dist folder\n"
WEBPACK_ENV=prod WEBPACK_MODE=build webpack
Expand All @@ -47,22 +36,19 @@ if [ "$ENV" == "prod" ]; then

echo
echoYellow " Done.\n"
fi

if [ "$ENV" == "dev" ]; then
elif [[ "$ENV" == "dev" ]]; then
echo
echoYellow " 2. Bundling the client app into the /dist folder to list results\n"
WEBPACK_ENV=dev WEBPACK_MODE=build webpack

echo
echoYellow " 3. Running watch on client app. Check /dist for changes\n"
WEBPACK_ENV=dev WEBPACK_MODE=watch webpack
fi

if [ "$ENV" == "docker" ]; then
elif [ "$ENV" == "docker" ]; then
echo
echoYellow " 2. Bundling the client app into the /dist folder to list results\n"
WEBPACK_ENV=dev WEBPACK_MODE=build webpack

fi

21 changes: 0 additions & 21 deletions domain/date.js

This file was deleted.

52 changes: 0 additions & 52 deletions domain/date.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion domain/searchParams.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const querystring = require('querystring')
const { getSummerPeriodsList, groupedPeriodsBySeasonInCorrectOrder } = require('kopps-public-react-web/shared/periods')
const i18n = require('../i18n')
const { formatLongTerm, getRelevantTerms, isSpringTerm } = require('./term')
const { getSummerPeriodsList, groupedPeriodsBySeasonInCorrectOrder } = require('./periods')
const { CLIENT_EDU_LEVELS, educationalLevel } = require('./eduLevels')
const { CLIENT_SHOW_OPTIONS, ONLY_MHU, getShowOptions } = require('./courseOptions')

Expand Down
12 changes: 12 additions & 0 deletions jest.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// jest.base.js
module.exports = {
clearMocks: true,
transformIgnorePatterns: ['node_modules/(?!(@kth|@babel|@jest|uuid|nanoid)/)'],
moduleNameMapper: {
'^shared/(.*)$': '<rootDir>/shared/$1',
'^domain/(.*)$': '<rootDir>/domain/$1',
'\\.(css|less|scss|sass)$': '<rootDir>/public/__mocks__/styleMock.js',
},
setupFilesAfterEnv: ['jest-extended/all'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
26 changes: 26 additions & 0 deletions jest.client.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const base = require('./jest.base')

module.exports = {
...base,
displayName: 'client',
testEnvironment: 'jsdom',

// ✅ anchor project to the folder
roots: ['<rootDir>/public'],

// ✅ relative patterns now that roots is set
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],

// keep ignores relative to roots
testPathIgnorePatterns: ['<rootDir>/public/dist/', '<rootDir>/node_modules/'],

transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: '<rootDir>/public/tsconfig.json' }],
'^.+\\.[jt]sx?$': 'babel-jest',
},
moduleNameMapper: {
'\\.(css|less|scss|sass)$': '<rootDir>/public/__mocks__/styleMock.js',
'^@kth/kopps-public-react-web/shared/(.*)$': '<rootDir>/shared/dist/$1',
'^@kth/kopps-public-react-web/domain/(.*)$': '<rootDir>/domain/$1',
},
}
23 changes: 11 additions & 12 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module.exports = {
globals: {
NODE_ENV: 'test',
},
clearMocks: true,
notify: true,
notifyMode: 'failure-change',
transformIgnorePatterns: ['node_modules/(?!(@kth|@babel|@jest|uuid|nanoid)/)'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
moduleNameMapper: {
'\\.(css|less|scss|sass)$': '<rootDir>/public/__mocks__/styleMock.js',
},
setupFilesAfterEnv: ['jest-extended/all'],
testEnvironment: 'jsdom',
verbose: true,
projects: [
'<rootDir>/jest.client.config.js',
'<rootDir>/jest.shared.config.js',
'<rootDir>/jest.domain.config.js',
'<rootDir>/jest.server.config.js',
],
reporters: [
'default',
['summary', { summaryThreshold: 0 }], // Enable failed test summary at the end of test run
],
}
11 changes: 11 additions & 0 deletions jest.domain.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const base = require('./jest.base')

module.exports = {
...base,
displayName: 'domain',
testEnvironment: 'node',
roots: ['<rootDir>/domain'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
transform: { '^.+\\.[jt]sx?$': 'babel-jest' },
}
15 changes: 15 additions & 0 deletions jest.server.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const base = require('./jest.base')

module.exports = {
...base,
displayName: 'server',
testEnvironment: 'node',
roots: ['<rootDir>/server'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
transform: { '^.+\\.[jt]sx?$': 'babel-jest' },
moduleNameMapper: {
'^kopps-public-react-web/shared/(.*)$': '<rootDir>/shared/dist/$1',
'^kopps-public-react-web/domain/(.*)$': '<rootDir>/domain/$1',
},
}
17 changes: 17 additions & 0 deletions jest.shared.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const base = require('./jest.base')

module.exports = {
...base,
displayName: 'shared',
testEnvironment: 'node',
roots: ['<rootDir>/shared'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: ['<rootDir>/shared/dist/', '<rootDir>/node_modules/'],
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: '<rootDir>/shared/tsconfig.json' }],
},
moduleNameMapper: {
'^kopps-public-react-web/shared/(.*)$': '<rootDir>/shared/$1',
'^kopps-public-react-web/domain/(.*)$': '<rootDir>/domain/$1',
},
}
Loading