@corva/create-app 0.0.0-73c49372 → 0.0.0-9a3cf8e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +7 -0
  2. package/bin/create-corva-app.cjs +4 -9
  3. package/lib/commands/build-release.js +60 -0
  4. package/lib/commands/release.js +6 -0
  5. package/lib/constants/cli.js +13 -3
  6. package/lib/constants/manifest.js +1 -0
  7. package/lib/constants/package.js +18 -6
  8. package/lib/flows/build-release.js +31 -0
  9. package/lib/flows/lib/api.js +6 -12
  10. package/lib/flows/lib/manifest.js +1 -1
  11. package/lib/flows/release.js +2 -1
  12. package/lib/flows/steps/build.js +25 -0
  13. package/lib/flows/steps/release/get-config.js +2 -2
  14. package/lib/flows/steps/release/prepare-data.js +14 -5
  15. package/lib/flows/steps/release/upload-zip-to-corva.js +80 -2
  16. package/lib/flows/steps/resolve-built-files-for-zip.js +35 -0
  17. package/lib/flows/steps/zip-file-list-resolve.js +45 -25
  18. package/lib/helpers/cli-version.js +38 -2
  19. package/lib/helpers/manifest.js +9 -1
  20. package/lib/helpers/resolve-app-runtime.js +3 -3
  21. package/lib/main.js +2 -0
  22. package/package.json +1 -104
  23. package/template_extensions/corva/.eslintrc +32 -0
  24. package/template_extensions/corva/.github/workflows/develop.yml +2 -0
  25. package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +1 -1
  26. package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +1 -1
  27. package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +1 -1
  28. package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +1 -1
  29. package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +1 -1
  30. package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +1 -1
  31. package/templates/stream_depth/javascript/__tests__/processor.spec.js +1 -1
  32. package/templates/stream_depth/typescript/__tests__/processor.spec.ts +1 -1
  33. package/templates/stream_time/javascript/__tests__/processor.spec.js +1 -1
  34. package/templates/stream_time/typescript/__tests__/processor.spec.ts +1 -1
  35. package/templates/task/javascript/__tests__/processor.spec.js +1 -1
  36. package/templates/task/typescript/__tests__/processor.spec.ts +1 -1
  37. package/templates/ui/javascript/config/jest/setupTests.js +19 -0
  38. package/templates/ui/javascript/src/App.completion.js +30 -31
  39. package/templates/ui/javascript/src/App.css +0 -13
  40. package/templates/ui/javascript/src/App.drilling.js +31 -36
  41. package/templates/ui/javascript/src/__tests__/App.test.js +27 -2
  42. package/templates/ui/typescript/config/jest/setupTests.js +19 -0
  43. package/templates/ui/typescript/src/App.completion.tsx +32 -42
  44. package/templates/ui/typescript/src/App.css +0 -13
  45. package/templates/ui/typescript/src/App.drilling.tsx +32 -41
  46. package/templates/ui/typescript/src/AppSettings.tsx +2 -12
  47. package/templates/ui/typescript/src/__mocks__/mockData.ts +194 -0
  48. package/templates/ui/typescript/src/__tests__/App.test.tsx +80 -6
  49. package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +14 -3
  50. package/templates/ui/typescript/src/types.ts +618 -0
  51. package/templates/ui/typescript/tsconfig.json +0 -1
  52. package/templates/ui/typescript/src/__mocks__/mockAppProps.ts +0 -590
  53. package/templates/ui/typescript/src/__mocks__/mockAppSettingsProps.ts +0 -290
@@ -4,9 +4,10 @@ import semver from 'semver';
4
4
  import inquirer from 'inquirer';
5
5
  import { join } from 'path';
6
6
  import * as url from 'url';
7
+ import fs from 'fs-extra';
7
8
 
8
9
  import { logger } from './logger.js';
9
- import fs from 'fs-extra';
10
+ import { StepError } from '../flows/lib/step-error.js';
10
11
 
11
12
  const npm = new NpmApi();
12
13
 
@@ -17,13 +18,41 @@ const asterisks = '*************************************************************
17
18
 
18
19
  const getCurrentVersion = async () =>
19
20
  (await fs.readJSON(join(url.fileURLToPath(new URL('.', import.meta.url)), '../../package.json'))).version;
20
- const getLatestVersion = async () => npm.repo('@corva/create-app').prop('version');
21
+
22
+ const getLatestVersion = async () => {
23
+ try {
24
+ return await npm.repo('@corva/create-app').prop('version');
25
+ } catch (caughtError) {
26
+ if (caughtError.name === 'FetchError') {
27
+ throw new StepError(`The request to check the latest available version has failed due to the network error. Details:
28
+
29
+ ${caughtError}
30
+
31
+ Please check your internet connection and that the above request is not blocked in your network
32
+ `);
33
+ }
34
+
35
+ throw caughtError;
36
+ }
37
+ };
38
+
39
+ // Utility function to check if a version is a regular semver without prerelease identifiers
40
+ const isRegularVersion = (version) => {
41
+ return semver.prerelease(version) === null;
42
+ };
21
43
 
22
44
  // NOTE: Stop process and show error if version is outdated
23
45
  export async function ensureLatestVersion() {
24
46
  const currentVersion = await getCurrentVersion();
25
47
  const latestVersion = await getLatestVersion();
26
48
 
49
+ // Skip version check if current version is a prerelease (dev or next)
50
+ if (!isRegularVersion(currentVersion)) {
51
+ logger.write('Skipping version check for prerelease version.\n');
52
+
53
+ return;
54
+ }
55
+
27
56
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
28
57
 
29
58
  if (isCurrentVersionOutdated) {
@@ -48,6 +77,13 @@ export async function warnIfOutdated() {
48
77
  const currentVersion = await getCurrentVersion();
49
78
  const latestVersion = await getLatestVersion();
50
79
 
80
+ // Skip version check if current version is a prerelease (dev or next)
81
+ if (!isRegularVersion(currentVersion)) {
82
+ logger.write(' ⚠️ Skipping version check for prerelease version.\n');
83
+
84
+ return;
85
+ }
86
+
51
87
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
52
88
 
53
89
  if (isCurrentVersionOutdated) {
@@ -1,4 +1,4 @@
1
- import { APP_RUNTIMES, APP_TYPES, TEMPLATE_TYPES } from '../constants/cli.js';
1
+ import { APP_EXTENSIONS, APP_RUNTIMES, APP_TYPES, TEMPLATE_TYPES } from '../constants/cli.js';
2
2
  import * as manifestConstants from '../constants/manifest.js';
3
3
 
4
4
  export function fillManifest(answers) {
@@ -10,6 +10,13 @@ export function fillManifest(answers) {
10
10
  runtime,
11
11
  });
12
12
 
13
+ const enable_isolation =
14
+ answers.appType === APP_TYPES.UI &&
15
+ answers.runtime === APP_RUNTIMES.UI &&
16
+ answers.extensions.includes(APP_EXTENSIONS.CORVA)
17
+ ? false
18
+ : undefined;
19
+
13
20
  const manifest = {
14
21
  ...manifestConstants.defaultManifest,
15
22
  ...defaultManifestProperties,
@@ -35,6 +42,7 @@ export function fillManifest(answers) {
35
42
  ...defaultManifestProperties.settings,
36
43
  runtime,
37
44
  app: defaultAppSettings(answers),
45
+ enable_isolation,
38
46
  },
39
47
  };
40
48
 
@@ -61,8 +61,8 @@ export const IS_WINDOWS = process.platform === 'win32';
61
61
 
62
62
  const semverVersionsMapping = {
63
63
  node: {
64
- 16: '16.19.0',
65
- 18: '18.13.0',
64
+ 18: '18.14.0',
65
+ 20: '20.16.0',
66
66
  },
67
67
  python: {
68
68
  '3.8': '3.8.16',
@@ -82,7 +82,7 @@ const semverVersionsMapping = {
82
82
  */
83
83
  export const resolveAppRuntime = (opts) => {
84
84
  if (opts.appType === APP_TYPES.UI) {
85
- const version = '18';
85
+ const version = '20';
86
86
 
87
87
  return {
88
88
  language: opts.useTypescript ? 'typescript' : 'javascript',
package/lib/main.js CHANGED
@@ -14,6 +14,7 @@ import { createCommand } from './commands/create.js';
14
14
  import { ERROR_ICON } from './constants/messages.js';
15
15
  import { StepError } from './flows/lib/step-error.js';
16
16
  import debugFn from 'debug';
17
+ import { buildReleasePaasCommand } from './commands/build-release.js';
17
18
 
18
19
  const debug = debugFn('cca:main');
19
20
 
@@ -47,6 +48,7 @@ export async function run() {
47
48
  .addCommand(createCommand, { isDefault: true })
48
49
  .addCommand(zipCommand)
49
50
  .addCommand(releaseCommand)
51
+ .addCommand(buildReleasePaasCommand)
50
52
  .addCommand(rerunCommand)
51
53
  .addCommand(attachCommand)
52
54
  .showHelpAfterError()
package/package.json CHANGED
@@ -1,104 +1 @@
1
- {
2
- "name": "@corva/create-app",
3
- "version": "0.0.0-73c49372",
4
- "private": false,
5
- "description": "Create an app to use it in CORVA.AI",
6
- "keywords": [
7
- "react"
8
- ],
9
- "bugs": {
10
- "url": "https://github.com/facebook/create-react-app/issues"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/corva-ai/create-corva-app",
15
- "directory": "@corva/create-app"
16
- },
17
- "license": "MIT",
18
- "type": "module",
19
- "bin": {
20
- "create-corva-app": "./bin/create-corva-app.cjs"
21
- },
22
- "files": [
23
- "bin/**/*.cjs",
24
- "bin/**/*.js",
25
- "lib/**/*.js",
26
- "templates",
27
- "template_extensions",
28
- "common"
29
- ],
30
- "scripts": {
31
- "helper-cli": "npx @corva/fe-dev-helper-cli@latest",
32
- "build": "echo \"build is not configured for package \\\"×\\\", skipping.\"",
33
- "get-changelog": "conventional-changelog -r 2 -p angular",
34
- "lint": "eslint . --resolve-plugins-relative-to $(pwd) --max-warnings 0",
35
- "lint:fix": "eslint . --fix",
36
- "release": "git add -A && standard-version -a",
37
- "release-rc": "npm run release -- --prerelease",
38
- "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest"
39
- },
40
- "lint-staged": {
41
- "*.js": "npm run lint:fix"
42
- },
43
- "dependencies": {
44
- "archiver": "^5.3.0",
45
- "chalk": "^4.1.0",
46
- "commander": "^9.1.0",
47
- "cross-spawn": "^7.0.3",
48
- "debug": "^4.3.4",
49
- "dotenv": "^16.0.0",
50
- "figlet": "^1.5.0",
51
- "form-data": "^4.0.0",
52
- "fs-extra": "^9.0.1",
53
- "glob": "^8.0.1",
54
- "got": "^12.5.1",
55
- "inquirer": "^8.2.3",
56
- "is-glob": "^4.0.3",
57
- "lodash": "^4.17.21",
58
- "npm-api": "^1.0.0",
59
- "semver": "^7.3.2",
60
- "terminal-link": "^3.0.0"
61
- },
62
- "devDependencies": {
63
- "@babel/core": "^7.11.0",
64
- "@babel/eslint-parser": "^7.19.1",
65
- "@babel/plugin-proposal-class-properties": "^7.18.6",
66
- "@babel/plugin-syntax-import-assertions": "^7.20.0",
67
- "@babel/preset-react": "^7.18.6",
68
- "@commitlint/cli": "^17.3.0",
69
- "@commitlint/config-conventional": "^17.3.0",
70
- "@corva/eslint-config-browser": "^0.1.7",
71
- "@corva/eslint-config-node": "^5.1.1",
72
- "@corva/node-sdk": "^8.0.1",
73
- "@types/cross-spawn": "^6.0.2",
74
- "@types/jest": "^29.5.4",
75
- "@typescript-eslint/eslint-plugin": "^5.42.1",
76
- "@typescript-eslint/parser": "^5.42.1",
77
- "conventional-changelog-cli": "^2.1.0",
78
- "eslint": "^8.2.0",
79
- "eslint-config-google": "^0.14.0",
80
- "eslint-config-prettier": "^8.5.0",
81
- "eslint-plugin-import": "^2.26.0",
82
- "eslint-plugin-jest": "^27.1.5",
83
- "eslint-plugin-jsx-a11y": "^6.7.1",
84
- "eslint-plugin-prettier": "^4.2.1",
85
- "eslint-plugin-react": "^7.32.0",
86
- "eslint-plugin-react-hooks": "^4.6.0",
87
- "eslint-plugin-require-sort": "^1.3.0",
88
- "husky": "^8.0.2",
89
- "jest": "^29.6.4",
90
- "prettier": "^2.0.0",
91
- "prettier-plugin-packagejson": "^2.3.0",
92
- "standard-version": "^9.0.0",
93
- "typescript": "^4.8.4",
94
- "zx": "^7.2.3"
95
- },
96
- "engines": {
97
- "node": ">=18"
98
- },
99
- "standard-version": {
100
- "skip": {
101
- "tag": true
102
- }
103
- }
104
- }
1
+ {"name":"@corva/create-app","version":"0.0.0-9a3cf8e","private":false,"description":"Create an app to use it in CORVA.AI","keywords":["react"],"bugs":{"url":"https://github.com/facebook/create-react-app/issues"},"repository":{"type":"git","url":"https://github.com/corva-ai/create-corva-app","directory":"@corva/create-app"},"license":"MIT","type":"module","bin":{"create-corva-app":"./bin/create-corva-app.cjs"},"files":["bin/**/*.cjs","bin/**/*.js","lib/**/*.js","templates","template_extensions","common"],"scripts":{"build":"echo \"build is not configured for package \\\"×\\\", skipping.\"","get-changelog":"conventional-changelog -r 2 -p angular","lint":"eslint . --resolve-plugins-relative-to $(pwd) --max-warnings 0","lint:fix":"eslint . --fix","release":"git add -A && standard-version -a","release-rc":"npm run release -- --prerelease","run:local-ui-ts-completion":"node ./bin/create-corva-app.cjs ../test-app-ui-ts-completions --appName 'TestAppUiTsCompletions' --segments 'completion' --category 'analytics' --appKey 'corva.testappuitscompletions.ui' --appType 'ui' --runtime 'ui' -t --extensions corva","run:local-ui-ts-drilling":"node ./bin/create-corva-app.cjs ../test-app-ui-ts-drilling --appName 'TestAppUiTsDrilling' --segments 'drilling' --category 'analytics' --appKey 'corva.testappuitsdrilling.ui' --appType 'ui' --runtime 'ui' -t --extensions corva","test":"NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest"},"lint-staged":{"*.js":"npm run lint:fix"},"dependencies":{"archiver":"^5.3.0","chalk":"^4.1.0","commander":"^9.1.0","cross-spawn":"^7.0.3","debug":"^4.3.4","dotenv":"^16.0.0","figlet":"^1.5.0","form-data":"^4.0.0","fs-extra":"^9.0.1","glob":"^8.0.1","got":"^12.5.1","inquirer":"^8.2.3","is-glob":"^4.0.3","lodash":"^4.17.21","npm-api":"^1.0.0","semver":"^7.3.2","terminal-link":"^3.0.0"},"devDependencies":{"@babel/core":"^7.11.0","@babel/eslint-parser":"^7.19.1","@babel/plugin-proposal-class-properties":"^7.18.6","@babel/plugin-syntax-import-assertions":"^7.20.0","@babel/preset-react":"^7.18.6","@commitlint/cli":"^17.3.0","@commitlint/config-conventional":"^17.3.0","@corva/eslint-config-browser":"^0.1.7","@corva/eslint-config-node":"^5.1.1","@corva/node-sdk":"^8.0.1","@types/cross-spawn":"^6.0.2","@types/jest":"^29.5.4","@typescript-eslint/eslint-plugin":"^5.42.1","@typescript-eslint/parser":"^5.42.1","conventional-changelog-cli":"^2.1.0","eslint":"^8.2.0","eslint-config-google":"^0.14.0","eslint-config-prettier":"^8.5.0","eslint-plugin-import":"^2.26.0","eslint-plugin-jest":"^27.1.5","eslint-plugin-jsx-a11y":"^6.7.1","eslint-plugin-prettier":"^4.2.1","eslint-plugin-react":"^7.32.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-require-sort":"^1.3.0","husky":"^8.0.2","jest":"^29.6.4","prettier":"^2.0.0","prettier-plugin-packagejson":"^2.3.0","standard-version":"^9.0.0","typescript":"^4.8.4","zx":"^7.2.3"},"packageManager":"yarn@1.22.19+sha512.ff4579ab459bb25aa7c0ff75b62acebe576f6084b36aa842971cf250a5d8c6cd3bc9420b22ce63c7f93a0857bc6ef29291db39c3e7a23aab5adfd5a4dd6c5d71","engines":{"node":">=18"},"standard-version":{"skip":{"tag":true}}}
@@ -0,0 +1,32 @@
1
+ {
2
+ "root": true,
3
+ "parser": "@typescript-eslint/parser",
4
+ "parserOptions": {
5
+ "ecmaVersion": 2020,
6
+ "sourceType": "module",
7
+ "ecmaFeature": {
8
+ "jsx": true
9
+ }
10
+ },
11
+ "extends": ["@corva/eslint-config-browser"],
12
+ "overrides": [
13
+ {
14
+ "files": ["*.ts", "*.tsx"],
15
+ "extends": [
16
+ "@corva/eslint-config-browser",
17
+ "plugin:@typescript-eslint/recommended",
18
+ "plugin:@tanstack/eslint-plugin-query/recommended"
19
+ ],
20
+ "rules": {
21
+ "@typescript-eslint/no-explicit-any": 2,
22
+ "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
23
+ /* Turned off until adopted by @corva/eslint-config-browser */
24
+ "react/prop-types": 0,
25
+ "react/default-props-match-prop-types": 0,
26
+ "react/no-unused-prop-types": 0,
27
+ "react/require-default-props": 0
28
+ /* Turned off until adopted by @corva/eslint-config-browser */
29
+ }
30
+ }
31
+ ]
32
+ }
@@ -11,6 +11,8 @@ jobs:
11
11
  - name: develop branch flow
12
12
  id: shared-workflow
13
13
  uses: corva-ai/gh-actions/shared-dc-workflows/develop@develop
14
+ env:
15
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14
16
  with:
15
17
  qa-api-key: ${{ secrets.API_KEY_QA }}
16
18
  prod-api-key: ${{ secrets.API_KEY }}
@@ -1,5 +1,5 @@
1
1
  const { ScheduledDataTimeEvent } = require('@corva/node-sdk');
2
- const { app_runner } = require('@corva/node-sdk/lib/testing');
2
+ const { app_runner } = require('@corva/node-sdk/testing');
3
3
 
4
4
  const { processor } = require('..');
5
5
 
@@ -1,4 +1,4 @@
1
- import { app_runner } from '@corva/node-sdk/lib/testing';
1
+ import { app_runner } from '@corva/node-sdk/testing';
2
2
  import { ScheduledDataTimeEvent } from '@corva/node-sdk';
3
3
 
4
4
  import { processor } from '..';
@@ -1,5 +1,5 @@
1
1
  const { ScheduledDepthEvent } = require('@corva/node-sdk');
2
- const { app_runner } = require('@corva/node-sdk/lib/testing');
2
+ const { app_runner } = require('@corva/node-sdk/testing');
3
3
 
4
4
  const { processor } = require('..');
5
5
 
@@ -1,4 +1,4 @@
1
- import { app_runner } from '@corva/node-sdk/lib/testing';
1
+ import { app_runner } from '@corva/node-sdk/testing';
2
2
  import { ScheduledDepthEvent } from '@corva/node-sdk';
3
3
 
4
4
  import { processor } from '..';
@@ -1,5 +1,5 @@
1
1
  const { ScheduledNaturalTimeEvent } = require('@corva/node-sdk');
2
- const { app_runner } = require('@corva/node-sdk/lib/testing');
2
+ const { app_runner } = require('@corva/node-sdk/testing');
3
3
 
4
4
  const { processor } = require('..');
5
5
 
@@ -1,4 +1,4 @@
1
- import { app_runner } from '@corva/node-sdk/lib/testing';
1
+ import { app_runner } from '@corva/node-sdk/testing';
2
2
  import { ScheduledNaturalTimeEvent } from '@corva/node-sdk';
3
3
 
4
4
  import { processor } from '..';
@@ -1,5 +1,5 @@
1
1
  const { StreamDepthEvent, StreamDepthRecord } = require('@corva/node-sdk');
2
- const { app_runner } = require('@corva/node-sdk/lib/testing');
2
+ const { app_runner } = require('@corva/node-sdk/testing');
3
3
 
4
4
  const { processor } = require('..');
5
5
 
@@ -1,4 +1,4 @@
1
- import { app_runner } from '@corva/node-sdk/lib/testing';
1
+ import { app_runner } from '@corva/node-sdk/testing';
2
2
  import { StreamDepthEvent, StreamDepthRecord } from '@corva/node-sdk';
3
3
 
4
4
  import { processor } from '..';
@@ -1,5 +1,5 @@
1
1
  const { StreamTimeEvent, StreamTimeRecord } = require('@corva/node-sdk');
2
- const { app_runner } = require('@corva/node-sdk/lib/testing');
2
+ const { app_runner } = require('@corva/node-sdk/testing');
3
3
 
4
4
  const { processor } = require('..');
5
5
 
@@ -1,4 +1,4 @@
1
- import { app_runner } from '@corva/node-sdk/lib/testing';
1
+ import { app_runner } from '@corva/node-sdk/testing';
2
2
  import { StreamTimeEvent, StreamTimeRecord } from '@corva/node-sdk';
3
3
 
4
4
  import { processor } from '..';
@@ -1,5 +1,5 @@
1
1
  const { TaskEvent } = require('@corva/node-sdk');
2
- const { app_runner } = require('@corva/node-sdk/lib/testing');
2
+ const { app_runner } = require('@corva/node-sdk/testing');
3
3
 
4
4
  const { processor } = require('..');
5
5
 
@@ -1,4 +1,4 @@
1
- import { app_runner } from '@corva/node-sdk/lib/testing';
1
+ import { app_runner } from '@corva/node-sdk/testing';
2
2
  import { TaskEvent } from '@corva/node-sdk';
3
3
 
4
4
  import { processor } from '..';
@@ -9,3 +9,22 @@ import '@testing-library/jest-dom/extend-expect';
9
9
 
10
10
  // Set UTC timezone for tests to not use the environment timezone
11
11
  process.env.TZ = 'UTC';
12
+
13
+ // Mock ResizeObserver & MutationObserver
14
+ class FakeObserver {
15
+ observe() {}
16
+ unobserve() {}
17
+ disconnect() {}
18
+ }
19
+
20
+ global.ResizeObserver = FakeObserver;
21
+ global.MutationObserver = FakeObserver;
22
+
23
+ // Suppressing "Could not parse CSS stylesheet" from JSDOM
24
+ const originalConsoleError = global.console.error;
25
+ global.console.error = (message, ...optionalParams) => {
26
+ if (message.includes('Could not parse CSS stylesheet')) {
27
+ return;
28
+ }
29
+ originalConsoleError(message, ...optionalParams);
30
+ };
@@ -1,4 +1,5 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
4
5
  import logo from './assets/logo.svg';
@@ -8,54 +9,52 @@ import styles from './App.css';
8
9
  /**
9
10
  * @param {Object} props
10
11
  * @param {boolean} props.isExampleCheckboxChecked
11
- * @param {Object} props.appHeaderProps
12
12
  * @param {Object} props.fracFleet
13
13
  * @param {Object} props.well
14
14
  * @param {Object[]} props.wells
15
15
  * @returns
16
16
  */
17
17
  function App({
18
- appHeaderProps,
19
18
  isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
20
19
  fracFleet,
21
20
  well,
22
21
  wells,
23
22
  }) {
23
+ const { appKey } = useAppCommons();
24
24
  // NOTE: On general type dashboard app receives wells array
25
25
  // on asset type dashboard app receives well object
26
26
  const wellsList = wells || [well];
27
27
 
28
28
  return (
29
- <div className={styles.container}>
30
- <AppHeader {...appHeaderProps} />
31
- <div className={styles.content}>
32
- <div>
33
- <img src={logo} alt="logo" className={styles.logo} />
34
- <p>
35
- Edit <code>src/App.js</code> and save to reload.
36
- <br />
37
- <br />
38
- </p>
39
- <p>
40
- Frac Fleet: {fracFleet?.name || 'No Frac Fleet'}
41
- <br />
42
- Wells: {wellsList.map(well => well.name).join(', ')}
43
- </p>
44
- <a
45
- className="App-link"
46
- href="https://reactjs.org"
47
- target="_blank"
48
- rel="noopener noreferrer"
49
- >
50
- Learn React
51
- </a>
52
- </div>
53
- <div>
54
- Settings &quot;Example&quot; checkbox is{' '}
29
+ <AppContainer header={<AppHeader />} testId={appKey}>
30
+ <div className={styles.container}>
31
+ <img src={logo} alt="logo" className={styles.logo} />
32
+ <p>
33
+ Edit <code>src/App.js</code> and save to reload.
34
+ <br />
35
+ <br />
36
+ </p>
37
+ <p>
38
+ Frac Fleet: <span data-testid="fracFleet">{fracFleet?.name || 'No Frac Fleet'}</span>
39
+ <br />
40
+ Wells: <span data-testid="wellsList">{wellsList.map(well => well?.name).join(', ')}</span>
41
+ </p>
42
+ <a
43
+ className="App-link"
44
+ href="https://reactjs.org"
45
+ target="_blank"
46
+ rel="noopener noreferrer"
47
+ >
48
+ Learn React
49
+ </a>
50
+ </div>
51
+ <div>
52
+ Settings &quot;Example&quot; checkbox is{' '}
53
+ <span data-testid="exampleCheckboxChecked">
55
54
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
56
- </div>
55
+ </span>
57
56
  </div>
58
- </div>
57
+ </AppContainer>
59
58
  );
60
59
  }
61
60
 
@@ -1,18 +1,5 @@
1
1
  .container {
2
- display: flex;
3
- flex-direction: column;
4
- height: 100%;
5
- padding: 12px 12px 30px 12px;
6
- }
7
-
8
- .content {
9
- display: flex;
10
- flex-direction: column;
11
2
  text-align: center;
12
- align-items: center;
13
- justify-content: center;
14
- flex-grow: 1;
15
- overflow: auto;
16
3
  }
17
4
 
18
5
  @keyframes App-logo-spin {
@@ -1,4 +1,5 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
4
5
  import logo from './assets/logo.svg';
@@ -7,49 +8,43 @@ import styles from './App.css';
7
8
 
8
9
  /**
9
10
  * @param {Object} props
10
- * @param {Object} props.appHeaderProps
11
11
  * @param {boolean} props.isExampleCheckboxChecked
12
12
  * @param {Object} props.rig
13
13
  * @param {Object} props.well
14
14
  * @returns
15
15
  */
16
- function App({
17
- appHeaderProps,
18
- isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
19
- rig,
20
- well,
21
- }) {
16
+ function App({ isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked, rig, well }) {
17
+ const { appKey } = useAppCommons();
22
18
  return (
23
- <div className={styles.container}>
24
- <AppHeader {...appHeaderProps} />
25
- <div className={styles.content}>
26
- <div>
27
- <img src={logo} alt="logo" className={styles.logo} />
28
- <p>
29
- Edit <code>src/App.js</code> and save to reload.
30
- <br />
31
- <br />
32
- </p>
33
- <p>
34
- Rig: {rig.name}
35
- <br />
36
- Well: {well.name}
37
- </p>
38
- <a
39
- className="App-link"
40
- href="https://reactjs.org"
41
- target="_blank"
42
- rel="noopener noreferrer"
43
- >
44
- Learn React
45
- </a>
46
- </div>
47
- <div>
48
- Settings &quot;Example&quot; checkbox is{' '}
19
+ <AppContainer header={<AppHeader />} testId={appKey}>
20
+ <div className={styles.container}>
21
+ <img src={logo} alt="logo" className={styles.logo} />
22
+ <p>
23
+ Edit <code>src/App.js</code> and save to reload.
24
+ <br />
25
+ <br />
26
+ </p>
27
+ <p>
28
+ Rig: <span data-testid="rig">{rig?.name}</span>
29
+ <br />
30
+ Well: <span data-testid="well">{well?.name}</span>
31
+ </p>
32
+ <a
33
+ className="App-link"
34
+ href="https://reactjs.org"
35
+ target="_blank"
36
+ rel="noopener noreferrer"
37
+ >
38
+ Learn React
39
+ </a>
40
+ </div>
41
+ <div>
42
+ Settings &quot;Example&quot; checkbox is{' '}
43
+ <span data-testid="exampleCheckboxState">
49
44
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
50
- </div>
45
+ </span>
51
46
  </div>
52
- </div>
47
+ </AppContainer>
53
48
  );
54
49
  }
55
50
 
@@ -1,11 +1,24 @@
1
1
  import { render, screen } from '@testing-library/react';
2
+ import { AppTestWrapper } from '@corva/ui/testing';
2
3
 
3
4
  import App from '../App';
4
5
  import { mockAppProps } from '../__mocks__/mockAppProps';
5
6
 
6
7
  describe('<App />', () => {
7
8
  it('should show correct layout', () => {
8
- render(<App {...mockAppProps} />);
9
+ render(
10
+ <AppTestWrapper
11
+ app={mockAppProps.app}
12
+ appId={123}
13
+ maximized={false}
14
+ appSettings={mockAppProps.app.settings}
15
+ onSettingChange={() => {
16
+ /* noop */
17
+ }}
18
+ >
19
+ <App {...mockAppProps} />
20
+ </AppTestWrapper>
21
+ );
9
22
 
10
23
  screen.getByText(/checked/i);
11
24
  });
@@ -14,7 +27,19 @@ describe('<App />', () => {
14
27
  const propsWithoutSettings = mockAppProps;
15
28
  delete propsWithoutSettings.isExampleCheckboxChecked;
16
29
 
17
- render(<App {...propsWithoutSettings} />);
30
+ render(
31
+ <AppTestWrapper
32
+ app={mockAppProps.app}
33
+ appId={123}
34
+ maximized={false}
35
+ appSettings={mockAppProps.app.settings}
36
+ onSettingChange={() => {
37
+ /* noop */
38
+ }}
39
+ >
40
+ <App {...propsWithoutSettings} />
41
+ </AppTestWrapper>
42
+ );
18
43
 
19
44
  screen.getByText(/unchecked/i);
20
45
  });