Skip to content

Commit

Permalink
Add multi-windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Jan 17, 2024
1 parent 7da7386 commit 07f95aa
Show file tree
Hide file tree
Showing 25 changed files with 8,748 additions and 7,522 deletions.
49 changes: 48 additions & 1 deletion .github/workflows/cicd-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,56 @@ jobs:
wait-on: "http://localhost:8880"
working-directory: ./frontend

e2e_multi_windows_test:
name: Run E2E multi windows tests
needs: [version, build]
runs-on: ubuntu-22.04
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
ENV_PROFILE: ${{needs.version.outputs.ENV_PROFILE}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MONITORENV_VERSION: ${{ needs.version.outputs.VERSION }}
REACT_APP_CYPRESS_PORT: 8880
VERSION: ${{needs.version.outputs.VERSION}}
steps:
- name: Checkout
uses: actions/checkout@v4
steps:

- uses: browser-actions/setup-chrome@v1
with:
chrome-version: 120

- name: Download image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: monitorenv-app:${{ env.VERSION }}

- name: Run docker images
run: make run-infra-for-frontend-tests

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./frontend/package-lock.json
node-version: 20

- name: Install Node.js dependencies
# TODO Remove `--legacy-peer-deps` option as soon as CRA is migrate to Vite.
run: npm ci --legacy-peer-deps
working-directory: ./frontend

- name: Curl stubbed geoserver check
run: until $(curl --output /dev/null --silent --fail "http://localhost:8081/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=monitorenv:regulations&outputFormat=application/json&CQL_FILTER=topic=%27Ouest%20Cotentin%20Bivalves%27%20AND%20zone=%27Praires%20Ouest%20cotentin%27"); do printf '.'; sleep 5; done;

- name: Run multi-windows tests
run: npm run test:multi-windows:run
working-directory: ./frontend

push_to_registry:
name: Push to registry
needs: [version, e2e_test]
needs: [version, e2e_test, e2e_multi_windows_test]
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/heads/dependabot') == false
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter.event
import java.time.ZonedDateTime
import java.util.*

@Component
Expand All @@ -29,7 +30,7 @@ class SSEMission {
* This method register a listener for a given mission id
*/
fun registerListener(): SseEmitter {
logger.info("Adding new SSE listener of mission updates.")
logger.info("Adding new SSE listener of mission updates at ${ZonedDateTime.now()}.")
val sseEmitter = SseEmitter(TWENTY_FOUR_HOURS)

synchronized(mutexLock) {
Expand All @@ -55,10 +56,10 @@ class SSEMission {
*/
@EventListener(UpdateMissionEvent::class)
fun handleUpdateMissionEvent(event: UpdateMissionEvent) {
logger.info("Received mission event for mission ${event.mission.id}.")
logger.info("SSE: Received mission event for mission ${event.mission.id}.")
val missionId = event.mission.id

logger.info("Sending update of mission $missionId to ${sseStore.size} listener(s).")
logger.info("SSE: Sending update of mission $missionId to ${sseStore.size} listener(s).")
val sseEmittersToRemove = sseStore.map { sseEmitter ->
try {
val data = MissionDataOutput.fromMissionEntity(event.mission)
Expand All @@ -69,16 +70,15 @@ class SSEMission {
.build()

sseEmitter.send(sseEvent)

sseEmitter.complete()

return@map null
return@map sseEmitter
} catch (e: Exception) {
sseEmitter.completeWithError(e)

return@map sseEmitter
}
}.filterNotNull()
}

synchronized(mutexLock) {
sseStore.removeAll(sseEmittersToRemove)
Expand Down
12 changes: 9 additions & 3 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,23 @@ module.exports = {

// Jest
{
files: ['**/*.test.ts', '**/*.test.tsx'],
files: ['**/*.test.ts', '**/*.test.tsx', 'puppeteer/**/*.ts'],
plugins: ['jest'],
env: {
jest: true
jest: true,
},
rules: {
'jest/no-disabled-tests': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'error',
'jest/valid-expect': 'error'
'jest/valid-expect': 'error',
'no-await-in-loop': 'off',
'no-console': 'off',
'no-restricted-syntax': 'off',
'no-underscore-dangle': 'off',
'import/no-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
}
},

Expand Down
19 changes: 19 additions & 0 deletions frontend/config/multi-windows/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
rootDir: '../..',
globalSetup: "<rootDir>/puppeteer/setup.ts",
testEnvironment: '<rootDir>/puppeteer/puppeteer_environment.ts',
// because it's detected by the default value of testRegex
// https://jestjs.io/docs/configuration#testregex-string--arraystring
globalTeardown: "<rootDir>/puppeteer/teardown.ts",
testMatch: ['<rootDir>/puppeteer/e2e/*.spec.ts'],
preset: "ts-jest",
transform: {
".ts": [
"ts-jest",
{
isolatedModules: true,
useESM: true,
}
]
}
};
Loading

0 comments on commit 07f95aa

Please sign in to comment.