Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validates client config #1116

Open
wants to merge 27 commits into
base: feature/distributed-demo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fecd5f0
Code from old PR
atomicgamedeveloper Dec 17, 2024
e689979
Add test env to preview test setup
atomicgamedeveloper Dec 17, 2024
9ddb439
Refactor
atomicgamedeveloper Dec 17, 2024
07426cf
Merge pull request #1 from atomicgamedeveloper/658-validate-client-co…
atomicgamedeveloper Dec 18, 2024
d388e92
Restructure into route/config
atomicgamedeveloper Dec 18, 2024
fd5da93
Fix endless loop, add loading to /verify
atomicgamedeveloper Dec 18, 2024
aab3df6
Make config warning responsive
atomicgamedeveloper Dec 19, 2024
30ac82d
Add new / and /config/verify pages
atomicgamedeveloper Dec 20, 2024
dfbab92
Extend responsiveness to other boxes
atomicgamedeveloper Dec 20, 2024
0433ded
Ensure tests pass with updated logic
atomicgamedeveloper Dec 23, 2024
41b9583
Refactor getConfigIcon and fix retry bug
atomicgamedeveloper Dec 23, 2024
e15161f
Add ConfigUtil unit tests, fix memory leak in unit.testUtil
atomicgamedeveloper Dec 27, 2024
b03dfa5
Add ConfigItems unit tests
atomicgamedeveloper Dec 28, 2024
5ed7c8c
Unit test Config.tsx
atomicgamedeveloper Dec 30, 2024
58bddce
Add .json to yarn format
atomicgamedeveloper Dec 30, 2024
60b8841
Rm route/config from Eslint ignore list, fix issues
atomicgamedeveloper Dec 30, 2024
67ded78
Strengthen flaky e2e setup
atomicgamedeveloper Jan 1, 2025
36a3652
Update playwright.config.ts
atomicgamedeveloper Jan 1, 2025
96a99b7
Merge branch 'feature/distributed-demo' into feature/distributed-demo
atomicgamedeveloper Jan 1, 2025
24add35
Bump cross-spawn from 7.0.3 to 7.0.6 in /client
dependabot[bot] Jan 1, 2025
cb0fa48
Bump nanoid from 3.3.7 to 3.3.8 in /client
dependabot[bot] Jan 1, 2025
4628b93
Merge pull request #2 from atomicgamedeveloper/dependabot/npm_and_yar…
atomicgamedeveloper Jan 1, 2025
201f65f
Merge pull request #3 from atomicgamedeveloper/dependabot/npm_and_yar…
atomicgamedeveloper Jan 1, 2025
e533f21
Refactor Signin function
atomicgamedeveloper Jan 1, 2025
dbf3929
Merge branch 'feature/distributed-demo' of https://github.com/atomicg…
atomicgamedeveloper Jan 1, 2025
239ae3a
Add Docker setup, fix more CodeCov issues, change routing
atomicgamedeveloper Jan 22, 2025
8edc264
Undo PreviewTab.tsx changes
atomicgamedeveloper Jan 22, 2025
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
10 changes: 7 additions & 3 deletions client/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import jsxA11Y from "eslint-plugin-jsx-a11y";
import react from "eslint-plugin-react";
import jest from "eslint-plugin-jest";
import reactHooks from "eslint-plugin-react-hooks";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
Expand All @@ -21,7 +22,7 @@ export default [{
ignores: [
"**/api/",
"**/build/",
"**/config/",
"client/config/",
"**/node_modules/",
"**/script/",
"**/coverage/",
Expand All @@ -40,8 +41,9 @@ export default [{
plugins: {
"jsx-a11y": jsxA11Y,
react,
"react-hooks": reactHooks,
jest,
"@typescript-eslint": typescriptEslint,
"@typescript-eslint": typescriptEslint
},

languageOptions: {
Expand Down Expand Up @@ -86,9 +88,11 @@ export default [{
"@typescript-eslint/no-unused-vars": [
"error",
{
"caughtErrorsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
}
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"no-console": "error",
"import/first": "error",
"react/prop-types": "off",
Expand Down
26 changes: 5 additions & 21 deletions client/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?![d3-shape|recharts]).+\\.js$"
],
"transformIgnorePatterns": ["/node_modules/(?![d3-shape|recharts]).+\\.js$"],
"collectCoverage": true,
"coverageReporters": [
"text",
"cobertura",
"clover",
"lcov",
"json"
],
"coverageReporters": ["text", "cobertura", "clover", "lcov", "json"],
"testTimeout": 15000,
"collectCoverageFrom": [
"src/**/*.{ts,tsx}"
],
"collectCoverageFrom": ["src/**/*.{ts,tsx}"],
"coveragePathIgnorePatterns": [
"node_modules",
"build",
Expand All @@ -27,21 +17,15 @@
"src/store/store.ts",
"src/preview/util/gitlabDriver.ts"
],
"modulePathIgnorePatterns": [
"test/e2e",
"mocks",
"config"
],
"modulePathIgnorePatterns": ["test/e2e", "mocks", "config"],
"coverageDirectory": "<rootDir>/coverage/",
"globals": {
"window.ENV.SERVER_HOSTNAME": "localhost",
"window.ENV.SERVER_PORT": 3500
},
"verbose": true,
"testRegex": "/test/.*\\.test.tsx?$",
"modulePaths": [
"<rootDir>/src/"
],
"modulePaths": ["<rootDir>/src/"],
"moduleNameMapper": {
"^test/(.*)$": "<rootDir>/test/$1",
"\\.(css|less|scss)$": "<rootDir>/test/preview/__mocks__/styleMock.ts"
Expand Down
23 changes: 14 additions & 9 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{
"name": "@into-cps-association/dtaas-web",
"version": "0.8.0",
"version": "0.8.1",
"description": "Web client for Digital Twin as a Service (DTaaS)",
"main": "index.tsx",
"author": "prasadtalasila <[email protected]> (http://prasad.talasila.in/)",
"contributors": [
"Omar Suleiman",
"Asger Busk Breinholm",
"Mathias Brændgaard",
"Emre Temel",
"Cesar Vela",
"Emre Temel",
"Enok Maj",
"Mathias Brændgaard",
"Omar Suleiman",
"Vanessa Scherma"
],
"license": "SEE LICENSE IN <LICENSE.md>",
"private": false,
"type": "module",
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"build": "npx react-scripts build",
"clean": "npx rimraf build/ dist/ node_modules/ coverage/ playwright-report/ test-results/ test.svg src.svg src/util/gitlab.json",
"config:dev": "npx shx cp config/dev.js public/env.js && npx shx cp config/dev.js build/env.js",
"config:local": "npx shx cp config/local.js public/env.js && npx shx cp config/local.js build/env.js",
"config:prod": "npx shx cp config/prod.js public/env.js && npx shx cp config/prod.js build/env.js",
"config:test": "npx shx cp config/test.js public/env.js && npx shx cp config/test.js build/env.js",
"develop": "npx react-scripts start",
"format": "prettier --ignore-path ../.gitignore --write \"**/*.{ts,tsx,css,scss}\"",
"format": "prettier --ignore-path ../.gitignore --write \"**/*.{ts,tsx,css,scss,json}\"",
"graph": "npx madge --image src.svg src && npx madge --image test.svg test",
"start": "serve -s build -l 4000",
"stop": "npx kill-port 4000",
"syntax": "npx eslint . --fix",
"test:all": "yarn test:unit && yarn test:int && yarn test:e2e",
"test:all": "yarn test:unit && yarn test:int && yarn test:e2e && yarn test:preview:unit && yarn test:preview:int",
"test:e2e:ext": "cross-env ext=true yarn test:e2e",
"test:e2e": "yarn config:test && playwright test -c ./playwright.config.ts",
"test:e2e": "yarn config:test && yarn build && playwright test -c ./playwright.config.ts",
"test:coverage:int-unit": "npx istanbul-combine -d coverage/all -r lcov -r json -r text coverage/unit/coverage-final.json coverage/int/coverage-final.json coverage/preview/unit/coverage-final.json coverage/preview/int/coverage-final.json",
"test:int": "jest -c ./jest.config.json jest --coverage --coverageDirectory=coverage/int ../test/integration --setupFilesAfterEnv ./test/integration/jest.setup.ts",
"test:int": "jest -c ./jest.config.json --coverage --coverageDirectory=coverage/int ../test/integration --setupFilesAfterEnv ./test/integration/jest.setup.ts",
"test:unit": "jest -c ./jest.config.json --coverageDirectory=coverage/unit ../test/unit --setupFilesAfterEnv ./test/unit/jest.setup.ts",
"test:preview:int": "jest -c ./jest.config.json --coverageDirectory=coverage/preview/int ../test/preview/integration --setupFilesAfterEnv ./test/preview/integration/jest.setup.ts",
"test:preview:unit": "jest -c ./jest.config.json --coverageDirectory=coverage/preview/unit ../test/preview/unit --setupFilesAfterEnv ./test/preview/unit/jest.setup.ts"
Expand Down Expand Up @@ -71,6 +73,8 @@
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^5.1.0",
"http-status-codes": "^2.3.0",
"jest-fetch-mock": "^3.0.3",
"katex": "^0.16.11",
"markdown-it-katex": "^2.0.3",
Expand All @@ -93,7 +97,8 @@
"resize-observer-polyfill": "^1.5.1",
"serve": "^14.2.1",
"styled-components": "^6.1.1",
"typescript": "5.1.6"
"typescript": "5.1.6",
"zod": "^3.24.1"
},
"devDependencies": {
"@babel/core": "7.25.8",
Expand Down
4 changes: 3 additions & 1 deletion client/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export default defineConfig({
? undefined
: {
command: 'yarn start',
url: BASE_URI,
},
retries: process.env.CI ? 0 : 1, // Disable retries on Github actions for now as setup always fails
timeout: 60 * 1000,
timeout: process.env.CI ? 1000 : 30 * 1000,
globalTimeout: 10 * 60 * 1000,
testDir: './test/e2e/tests',
testMatch: /.*\.test\.ts/,
Expand Down Expand Up @@ -50,6 +51,7 @@ export default defineConfig({
use: {
baseURL: BASE_URI,
trace: 'on-first-retry', // Wil not record trace on Github actions because of no retries
headless: true,
},
projects: [
// Setup project
Expand Down
12 changes: 9 additions & 3 deletions client/src/page/LayoutPublic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AppBar from '@mui/material/AppBar';
import Footer from 'page/Footer';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import { Container } from '@mui/material';
import { Breakpoint, Container } from '@mui/material';
import LinkButtons from 'components/LinkButtons';
import toolbarLinkValues from 'util/toolbarUtil';

Expand All @@ -26,7 +26,10 @@ const DTappBar = () => (
</AppBar>
);

function LayoutPublic(props: { children: React.ReactNode }) {
function LayoutPublic(props: {
children: React.ReactNode;
containerMaxWidth?: Breakpoint;
}) {
return (
<Box
sx={{
Expand All @@ -38,7 +41,10 @@ function LayoutPublic(props: { children: React.ReactNode }) {
>
<DTappBar />
<Toolbar />
<Container component="main" maxWidth="xs">
<Container
component="main"
maxWidth={props.containerMaxWidth ? props.containerMaxWidth : 'xs'}
>
{props.children}
</Container>

Expand Down
75 changes: 38 additions & 37 deletions client/src/preview/route/digitaltwins/editor/PreviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ import * as RemarkableKatex from 'remarkable-katex';
import SyntaxHighlighter from 'react-syntax-highlighter';

interface PreviewProps {
fileContent: string;
fileType: string;
fileContent: string;
fileType: string;
}

function PreviewTab({ fileContent, fileType }: PreviewProps) {
if (fileType === 'md') {
const md = new Remarkable({
html: true,
typographer: true,
}).use(RemarkableKatex);
if (fileType === 'md') {
const md = new Remarkable({
html: true,
typographer: true,
}).use(RemarkableKatex);

const renderedMarkdown = md.render(fileContent);
const renderedMarkdown = md.render(fileContent);

return (
<div
style={{
width: '100%',
overflowWrap: 'break-word',
wordWrap: 'break-word',
whiteSpace: 'normal',
overflow: 'hidden',
}}
>
<div
dangerouslySetInnerHTML={{
__html: renderedMarkdown,
}}
style={{
maxWidth: '100%',
}}
/>
<style>{`
return (
<div
style={{
width: '100%',
overflowWrap: 'break-word',
wordWrap: 'break-word',
whiteSpace: 'normal',
overflow: 'hidden',
}}
>
<div
dangerouslySetInnerHTML={{
__html: renderedMarkdown,
}}
style={{
maxWidth: '100%',
}}
/>
<style>{`
img {
max-width: 100%;
height: auto;
Expand All @@ -58,17 +58,18 @@ function PreviewTab({ fileContent, fileType }: PreviewProps) {
background-color: #f0f0f0;
}
`}</style>
</div>
);
}
</div>
);
}

if (fileType === 'json') {
return <SyntaxHighlighter language="json">{fileContent}</SyntaxHighlighter>;
}
if (fileType === 'yaml' || fileType === 'yml') {
return <SyntaxHighlighter language="yaml">{fileContent}</SyntaxHighlighter>;
}
return <SyntaxHighlighter language="bash">{fileContent}</SyntaxHighlighter>;
if (fileType === 'json') {
return <SyntaxHighlighter language="json">{fileContent}</SyntaxHighlighter>;
}
if (fileType === 'yaml' || fileType === 'yml') {
return <SyntaxHighlighter language="yaml">{fileContent}</SyntaxHighlighter>;
}
return <SyntaxHighlighter language="bash">{fileContent}</SyntaxHighlighter>;
return null;
}

export default PreviewTab;
Loading
Loading