diff --git a/src/frontend/apps/impress/.env.development b/src/frontend/apps/impress/.env.development index 06cbc57c..2056c636 100644 --- a/src/frontend/apps/impress/.env.development +++ b/src/frontend/apps/impress/.env.development @@ -1,2 +1,3 @@ NEXT_PUBLIC_API_ORIGIN=http://localhost:8071 NEXT_PUBLIC_SIGNALING_URL=ws://localhost:4444 +NEXT_PUBLIC_SW_DEACTIVATED=true diff --git a/src/frontend/apps/impress/next.config.js b/src/frontend/apps/impress/next.config.js index 41115e4c..e59b6237 100644 --- a/src/frontend/apps/impress/next.config.js +++ b/src/frontend/apps/impress/next.config.js @@ -11,7 +11,7 @@ const nextConfig = { // Enables the styled-components SWC transform styledComponents: true, }, - webpack(config, { isServer, dev }) { + webpack(config, { isServer }) { // Grab the existing rule that handles SVG imports const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'), @@ -33,7 +33,7 @@ const nextConfig = { }, ); - if (!isServer && !dev) { + if (!isServer && process.env.NEXT_PUBLIC_SW_DEACTIVATED !== 'true') { config.plugins.push( new InjectManifest({ swSrc: './src/core/service-worker.ts', diff --git a/src/frontend/apps/impress/package.json b/src/frontend/apps/impress/package.json index fcc20ca6..e8842507 100644 --- a/src/frontend/apps/impress/package.json +++ b/src/frontend/apps/impress/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "next dev", "build": "prettier --check . && yarn stylelint && next build", - "build:ci": "cp .env.development .env.local && cross-env NEXT_PUBLIC_CI=true yarn build", + "build:ci": "cp .env.development .env.local && yarn build", "build-theme": "cunningham -g css,ts -o src/cunningham --utility-classes", "start": "npx -y serve@latest out", "lint": "tsc --noEmit && next lint", @@ -21,7 +21,6 @@ "@gouvfr-lasuite/integration": "1.0.1", "@openfun/cunningham-react": "2.9.3", "@tanstack/react-query": "5.48.0", - "cross-env": "*", "i18next": "23.11.5", "lodash": "4.17.21", "luxon": "3.4.4", @@ -49,6 +48,7 @@ "@types/node": "*", "@types/react": "18.3.3", "@types/react-dom": "*", + "cross-env": "*", "dotenv": "16.4.5", "eslint-config-impress": "*", "fetch-mock": "9.11.0", diff --git a/src/frontend/apps/impress/src/core/service-worker/__tests__/_app.test.tsx b/src/frontend/apps/impress/src/core/service-worker/__tests__/_app.test.tsx new file mode 100644 index 00000000..3e83e24e --- /dev/null +++ b/src/frontend/apps/impress/src/core/service-worker/__tests__/_app.test.tsx @@ -0,0 +1,71 @@ +import '@testing-library/jest-dom'; +import { render } from '@testing-library/react'; +import { Router } from 'next/router'; +import { PropsWithChildren, ReactElement } from 'react'; + +import App from '@/pages/_app'; +import { AppWrapper } from '@/tests/utils'; +import { NextPageWithLayout } from '@/types/next'; + +const Page: NextPageWithLayout = () => { + return