Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Aug 12, 2024
1 parent 50c2c19 commit 844349e
Show file tree
Hide file tree
Showing 27 changed files with 732 additions and 335 deletions.
6 changes: 4 additions & 2 deletions frontend/.eslintrc.js → frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
ecmaVersion: 2022,
project: path.join(__dirname, 'tsconfig.json')
},
ignorePatterns: ['.eslintrc.js', '.eslintrc.partial.js', 'config/cypress.config.js'],
ignorePatterns: ['.eslintrc.cjs', '.eslintrc.partial.cjs'],
env: {
browser: true
},
Expand Down Expand Up @@ -200,12 +200,14 @@ module.exports = {
'./scripts/**/*.js',
'**/*.spec.ts',
'./config/**/*.ts',
'./scripts/**/*.mjs',
'./scripts/**/*.ts'
],
env: {
browser: false,
node: true
},
rules: {
'import/no-default-export': 'off'
}
}
]
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions frontend/__mocks__/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mockConsole = mockConsole;
var globals_1 = require("@jest/globals");
function mockConsole() {
var originalConsole = {};
var methods = ['error', 'group', 'info', 'log', 'warning'];
(0, globals_1.beforeAll)(function () {
methods.forEach(function (method) {
originalConsole[method] = console[method];
console[method] = globals_1.jest.fn();
});
});
(0, globals_1.afterAll)(function () {
methods.forEach(function (method) {
console[method] = originalConsole[method];
});
});
}
2 changes: 1 addition & 1 deletion frontend/config/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
// eslint-disable-next-line @typescript-eslint/naming-convention
__esModule: true,
default: 'test-file-stub'
Expand Down
43 changes: 0 additions & 43 deletions frontend/config/cypress.config.js

This file was deleted.

30 changes: 20 additions & 10 deletions frontend/config/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineConfig } from 'cypress'
import initCypressMousePositionPlugin from 'cypress-mouse-position/plugin'
import { initPlugin } from 'cypress-plugin-snapshots/plugin'
// import { initPlugin } from 'cypress-plugin-snapshots/plugin'
import vitePreprocessor from 'cypress-vite'
import { resolve } from 'node:path'

const IS_CI = Boolean(process.env.CI)
const DEFAULT_PORT = IS_CI ? 8880 : 3000
Expand All @@ -9,20 +11,28 @@ export default defineConfig({
e2e: {
baseUrl: `http://localhost:${DEFAULT_PORT}`,
excludeSpecPattern: ['**/__snapshots__/*', '**/__image_snapshots__/*'],
setupNodeEvents(on, config) {
setupNodeEvents(on, _config) {
on(
'file:preprocessor',
vitePreprocessor({
configFile: resolve(import.meta.dirname, '../vite.config.ts'),
mode: 'development'
})
)

initCypressMousePositionPlugin(on)
initPlugin(on, config)
// initPlugin(on, config)
},
specPattern: 'cypress/e2e/**/*.spec.ts'
},
env: {
'cypress-plugin-snapshots': {
imageConfig: {
threshold: 20,
thresholdType: 'pixel'
},
updateSnapshots: false
},
// 'cypress-plugin-snapshots': {
// imageConfig: {
// threshold: 20,
// thresholdType: 'pixel'
// },
// updateSnapshots: false
// },
/**
* When running Cypress tests, we modify this env var in spec file, so we use `window.Cypress.env()`
* instead of `import.meta.env` in application code.
Expand Down
4 changes: 2 additions & 2 deletions frontend/config/fileTransformer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path')
import path from 'path'

// https://jestjs.io/docs/code-transformation#examples

module.exports = {
export default {
process(sourceText, sourcePath) {
return {
code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
clearMocks: true,
collectCoverageFrom: ['**/{hooks,libs,utils}/**/*.t{s,sx}', '**/utils.ts'],
globalSetup: '<rootDir>/config/jest.global.js',
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/jest.global.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @see https://jestjs.io/docs/configuration#globalsetup-string
*/
module.exports = () => {
export default () => {
process.env.TZ = 'America/New_York'
}
2 changes: 1 addition & 1 deletion frontend/config/multi-windows/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
globalSetup: '<rootDir>/puppeteer/setup.ts',
// because it's detected by the default value of testRegex
// https://jestjs.io/docs/configuration#testregex-string--arraystring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ALL_SEAFRONT_GROUP } from '@constants/seafront'

import { addSideWindowPriorNotification, editSideWindowPriorNotification } from './utils'
import { ALL_SEAFRONT_GROUP } from '../../../../src/constants/seafront'
import { customDayjs } from '../../utils/customDayjs'
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SideWindowMenuLabel } from 'domain/entities/sideWindow/constants'
import { SideWindowMenuLabel } from '../../../../src/domain/entities/sideWindow/constants'

export const addSideWindowPriorNotification = () => {
cy.viewport(1920, 1080)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SideWindowMenuLabel } from 'domain/entities/sideWindow/constants'
import { SideWindowMenuLabel } from '../../../../src/domain/entities/sideWindow/constants'

export const openSideWindowPriorNotification = (vesselName: string, isSuperUser: boolean = true) => {
cy.viewport(1920, 1080)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertNotNullish } from '@utils/assertNotNullish'
import { SideWindowMenuLabel } from 'domain/entities/sideWindow/constants'

import { openSideWindowPriorNotificationList } from './utils'
import { SideWindowMenuLabel } from '../../../../src/domain/entities/sideWindow/constants'
import { assertAll } from '../../utils/assertAll'
import { customDayjs } from '../../utils/customDayjs'
import { getUtcDateInMultipleFormats } from '../../utils/getUtcDateInMultipleFormats'
Expand Down
4 changes: 1 addition & 3 deletions frontend/cypress/support/commands/countRequestsByAlias.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Interception } from 'cypress/types/net-stubbing'

const STORE: Record<string, string[]> = {}

/**
Expand All @@ -23,7 +21,7 @@ export function countRequestsByAlias(alias: string, waitForInMs: number = 0): Cy
cy.wait(waitForInMs)
}

return cy.get<Interception>(alias).then(interception => {
return cy.get<{ id: string }>(alias).then(interception => {
if (!STORE[alias]) {
STORE[alias] = []
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="../../node_modules/@mtes-mct/monitor-ui/cypress/global.d.ts" />

import 'cypress-mouse-position/commands'
import 'cypress-plugin-snapshots/commands'
// import 'cypress-plugin-snapshots/commands'

import './commands'
import './commands/dragTo'
Expand Down
Loading

0 comments on commit 844349e

Please sign in to comment.