@corva/create-app 0.50.0-2 → 0.50.0-3
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.
- package/lib/constants/package.js +41 -9
- package/package.json +1 -1
- package/templates/ui/javascript/config/jest/babelTransform.js +16 -0
- package/templates/ui/javascript/config/jest/cssTransform.js +16 -0
- package/templates/ui/javascript/config/jest/fileTransform.js +48 -0
- package/templates/ui/javascript/config/jest/globalSetup.js +5 -0
- package/templates/ui/javascript/config/jest/setupTests.js +11 -0
- package/templates/ui/javascript/gitignore +2 -0
- package/templates/ui/javascript/src/AppSettings.js +1 -0
- package/templates/ui/javascript/src/__mocks__/mockAppProps.js +580 -0
- package/templates/ui/javascript/src/__mocks__/mockAppSettingsProps.js +290 -0
- package/templates/ui/javascript/src/__tests__/App.test.js +21 -0
- package/templates/ui/javascript/src/__tests__/AppSettings.test.js +21 -0
- package/templates/ui/javascript/src/__tests__/TestsExample.test.js +37 -0
- package/templates/ui/typescript/config/jest/babelTransform.js +16 -0
- package/templates/ui/typescript/config/jest/cssTransform.js +16 -0
- package/templates/ui/typescript/config/jest/fileTransform.js +48 -0
- package/templates/ui/typescript/config/jest/globalSetup.js +5 -0
- package/templates/ui/typescript/config/jest/setupTests.js +11 -0
- package/templates/ui/typescript/gitignore +2 -0
- package/templates/ui/typescript/src/App.tsx +1 -1
- package/templates/ui/typescript/src/AppSettings.tsx +1 -0
- package/templates/ui/typescript/src/__mocks__/mockAppProps.ts +580 -0
- package/templates/ui/typescript/src/__mocks__/mockAppSettingsProps.ts +290 -0
- package/templates/ui/typescript/src/__tests__/App.test.tsx +21 -0
- package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +21 -0
- package/templates/ui/typescript/src/__tests__/TestsExample.test.tsx +37 -0
- package/templates/ui/javascript/src/__tests__/TestExample.test.js +0 -31
- package/templates/ui/javascript/src/setupTests.js +0 -2
- package/templates/ui/typescript/src/__tests__/TestExample.test.tsx +0 -31
- package/templates/ui/typescript/src/setupTests.ts +0 -2
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a real example of the props that'll come
|
|
3
|
+
* to the AppSettings component. You'll need to manually update it
|
|
4
|
+
* if in the future some new properties are added
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const mockAppSettingsProps = {
|
|
8
|
+
onSettingChange: jest.fn(),
|
|
9
|
+
onSettingsChange: jest.fn(),
|
|
10
|
+
app: {
|
|
11
|
+
id: -1,
|
|
12
|
+
app: {
|
|
13
|
+
app_key: 'company.app_key.ui',
|
|
14
|
+
platform: 'dev_center',
|
|
15
|
+
},
|
|
16
|
+
settings: {
|
|
17
|
+
package: '0.1.0',
|
|
18
|
+
rigId: 1,
|
|
19
|
+
wellId: 2,
|
|
20
|
+
isExampleCheckboxChecked: true,
|
|
21
|
+
},
|
|
22
|
+
package: {
|
|
23
|
+
manifest: {
|
|
24
|
+
format: 1,
|
|
25
|
+
license: {
|
|
26
|
+
type: 'MIT',
|
|
27
|
+
url: 'https://www.oandgexample.com/license/',
|
|
28
|
+
},
|
|
29
|
+
developer: {
|
|
30
|
+
name: 'Company Name',
|
|
31
|
+
identifier: 'companyIdentifier',
|
|
32
|
+
authors: [],
|
|
33
|
+
},
|
|
34
|
+
application: {
|
|
35
|
+
type: 'ui',
|
|
36
|
+
key: 'company.app_key.ui',
|
|
37
|
+
visibility: 'private',
|
|
38
|
+
name: 'dev center app name',
|
|
39
|
+
description: 'This is the description of my app. You can do great things with it!',
|
|
40
|
+
summary: 'More information about this app goes here',
|
|
41
|
+
category: 'analytics',
|
|
42
|
+
website: 'https://www.oandgexample.com/my-app/',
|
|
43
|
+
segments: ['drilling', 'completion'],
|
|
44
|
+
ui: {
|
|
45
|
+
initial_size: {
|
|
46
|
+
w: 4,
|
|
47
|
+
h: 10,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
settings: {
|
|
52
|
+
entrypoint: {
|
|
53
|
+
file: 'src/index.js',
|
|
54
|
+
function: 'handler',
|
|
55
|
+
},
|
|
56
|
+
environment: {},
|
|
57
|
+
runtime: 'ui',
|
|
58
|
+
app: {
|
|
59
|
+
scheduler_type: 1,
|
|
60
|
+
cron_string: '*/5 * * * *',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
datasets: {},
|
|
64
|
+
},
|
|
65
|
+
build: 'company.app_key.ui-0.1.0',
|
|
66
|
+
version: '0.1.0',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
appData: {
|
|
70
|
+
id: -1,
|
|
71
|
+
rig: {
|
|
72
|
+
name: 'Test Rig Name',
|
|
73
|
+
id: '1',
|
|
74
|
+
asset_id: 3,
|
|
75
|
+
},
|
|
76
|
+
well: {
|
|
77
|
+
name: 'Test Well Name',
|
|
78
|
+
settings: {
|
|
79
|
+
basin: 'Test Basin Name',
|
|
80
|
+
county: 'Pecos',
|
|
81
|
+
timezone: 'America/Chicago',
|
|
82
|
+
top_hole: {
|
|
83
|
+
raw: '50.123456,-102.865431',
|
|
84
|
+
coordinates: [50.123456, -102.865431],
|
|
85
|
+
},
|
|
86
|
+
api_number: '12-345-67689',
|
|
87
|
+
bottom_hole: {},
|
|
88
|
+
mud_company: 'Mud Company Name',
|
|
89
|
+
spud_release: [
|
|
90
|
+
{
|
|
91
|
+
id: '1111111111-2222-3a3a-4b4b-afc5c7c8f245',
|
|
92
|
+
spud: '01/08/2023 00:46',
|
|
93
|
+
rig_up: '01/08/2023 00:10',
|
|
94
|
+
release: '',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
string_design: '5',
|
|
98
|
+
contractor_name: 'Test Contractor Name',
|
|
99
|
+
target_formation: 'Test Traget Formation',
|
|
100
|
+
last_mongo_refresh: '2023-02-24T16:16:06.383Z',
|
|
101
|
+
rig_classification: 'land',
|
|
102
|
+
directional_driller: 'Test Directional Driller',
|
|
103
|
+
drilling_afe_number: 'AB12356',
|
|
104
|
+
day_shift_start_time: '06:00',
|
|
105
|
+
off_bottom_tolerance: 1,
|
|
106
|
+
target_formation_standard: 'Test Traget Formation',
|
|
107
|
+
completion_day_shift_start_time: '06:00',
|
|
108
|
+
associations_last_active_at_updated_at: '2023-02-24T16:15:40.000Z',
|
|
109
|
+
},
|
|
110
|
+
asset_id: 4,
|
|
111
|
+
last_active_at: '2023-02-24T16:20:29.000Z',
|
|
112
|
+
id: '2',
|
|
113
|
+
companyId: '6',
|
|
114
|
+
},
|
|
115
|
+
fracFleet: null,
|
|
116
|
+
wells: null,
|
|
117
|
+
isLoading: false,
|
|
118
|
+
appHash: '-1-2-1-NaN-NaN-NaN',
|
|
119
|
+
},
|
|
120
|
+
settings: {
|
|
121
|
+
package: '0.1.0',
|
|
122
|
+
rigId: 1,
|
|
123
|
+
wellId: 2,
|
|
124
|
+
isExampleCheckboxChecked: true,
|
|
125
|
+
},
|
|
126
|
+
layoutEnvironment: {
|
|
127
|
+
type: 'general',
|
|
128
|
+
pdfReportMode: false,
|
|
129
|
+
},
|
|
130
|
+
currentUser: {
|
|
131
|
+
id: 1,
|
|
132
|
+
company_id: 3,
|
|
133
|
+
first_name: 'John',
|
|
134
|
+
last_name: 'Doe',
|
|
135
|
+
email: 'john.doe@company.ai',
|
|
136
|
+
mobile: '',
|
|
137
|
+
created_at: '2020-11-03T08:42:53.161Z',
|
|
138
|
+
terms_acceptance_at: '2021-10-20T13:28:6.385Z',
|
|
139
|
+
profile_photo: null,
|
|
140
|
+
recently_viewed_asset_ids: [64],
|
|
141
|
+
unit_system: null,
|
|
142
|
+
role: 'user',
|
|
143
|
+
title: null,
|
|
144
|
+
group: null,
|
|
145
|
+
favorite_asset_id: null,
|
|
146
|
+
current_segment: null,
|
|
147
|
+
theme: 'dark',
|
|
148
|
+
messaging_id: '1',
|
|
149
|
+
restricted_assets: [],
|
|
150
|
+
restricted_programs: [],
|
|
151
|
+
settings: {
|
|
152
|
+
favorites: {},
|
|
153
|
+
sms_blacklisted: false,
|
|
154
|
+
restricted_assets: [],
|
|
155
|
+
restricted_programs: [],
|
|
156
|
+
participates_in_beta_apps: false,
|
|
157
|
+
last_new_dashboard_shares_check: '2021-11-24T18:57:13.679Z',
|
|
158
|
+
},
|
|
159
|
+
last_sign_in_at: '2023-02-23T10:19:06.349Z',
|
|
160
|
+
locked_access: false,
|
|
161
|
+
unit_ids: [],
|
|
162
|
+
intercom_admin_id: null,
|
|
163
|
+
resource: [],
|
|
164
|
+
intercom_user_hash: 'intercom_user_hash',
|
|
165
|
+
profile_groups: [],
|
|
166
|
+
preference: {
|
|
167
|
+
id: 6,
|
|
168
|
+
user: {
|
|
169
|
+
id: 1,
|
|
170
|
+
company_id: 3,
|
|
171
|
+
first_name: 'John',
|
|
172
|
+
last_name: 'Doe',
|
|
173
|
+
email: 'john.doe@company.ai',
|
|
174
|
+
role: 'user',
|
|
175
|
+
created_at: '2020-11-03T08:42:53.161Z',
|
|
176
|
+
updated_at: '2023-02-23T12:26:46.835Z',
|
|
177
|
+
recently_viewed_asset_ids: [64],
|
|
178
|
+
unit_system: null,
|
|
179
|
+
mobile: '',
|
|
180
|
+
terms_acceptance_at: '2021-10-20T13:28:6.385Z',
|
|
181
|
+
messaging_id: '1',
|
|
182
|
+
settings: {
|
|
183
|
+
favorites: {},
|
|
184
|
+
sms_blacklisted: false,
|
|
185
|
+
restricted_assets: [],
|
|
186
|
+
restricted_programs: [],
|
|
187
|
+
participates_in_beta_apps: false,
|
|
188
|
+
last_new_dashboard_shares_check: '2021-11-24T18:57:13.679Z',
|
|
189
|
+
},
|
|
190
|
+
theme: 'dark',
|
|
191
|
+
title: null,
|
|
192
|
+
group: null,
|
|
193
|
+
profile_photo: null,
|
|
194
|
+
favorite_asset_id: null,
|
|
195
|
+
current_segment: null,
|
|
196
|
+
state: 'active',
|
|
197
|
+
created_by: null,
|
|
198
|
+
provisioner: 'internal',
|
|
199
|
+
intercom_admin_id: null,
|
|
200
|
+
resource: [],
|
|
201
|
+
},
|
|
202
|
+
push_notifications_enabled: true,
|
|
203
|
+
emails_enabled: true,
|
|
204
|
+
sms_enabled: true,
|
|
205
|
+
alert_levels: ['info', 'warning', 'critical'],
|
|
206
|
+
play_alerts_sound: true,
|
|
207
|
+
show_intercom_icon: true,
|
|
208
|
+
segment: ['drilling', 'completion'],
|
|
209
|
+
disable_create_dashboard: false,
|
|
210
|
+
disable_costs: false,
|
|
211
|
+
disable_documents: false,
|
|
212
|
+
realtime_operation_mode: false,
|
|
213
|
+
disable_file_upload: false,
|
|
214
|
+
stay_on_app_store: false,
|
|
215
|
+
},
|
|
216
|
+
company: {
|
|
217
|
+
id: 3,
|
|
218
|
+
name: 'Test Company Name',
|
|
219
|
+
time_zone: 'America/Chicago',
|
|
220
|
+
language: 'en',
|
|
221
|
+
provider: 'company',
|
|
222
|
+
unit_system: {
|
|
223
|
+
yp: 'hsf',
|
|
224
|
+
oil: 'bbl',
|
|
225
|
+
area: 'ft2',
|
|
226
|
+
mass: 'lb',
|
|
227
|
+
time: 'min',
|
|
228
|
+
angle: 'deg',
|
|
229
|
+
force: 'klbf',
|
|
230
|
+
power: 'hp',
|
|
231
|
+
speed: 'ft/min',
|
|
232
|
+
length: 'm',
|
|
233
|
+
system: 'imperial',
|
|
234
|
+
torque: 'ft-klbf',
|
|
235
|
+
volume: 'gal',
|
|
236
|
+
current: 'mA',
|
|
237
|
+
density: 'ppg',
|
|
238
|
+
gravity: 'g',
|
|
239
|
+
voltage: 'mV',
|
|
240
|
+
porosity: 'pu',
|
|
241
|
+
pressure: 'psi',
|
|
242
|
+
velocity: 'ft/min',
|
|
243
|
+
gasVolume: 'Mscf',
|
|
244
|
+
gravityRMS: 'gRMS',
|
|
245
|
+
msePressure: 'ksi',
|
|
246
|
+
oilFlowRate: 'bbl/min',
|
|
247
|
+
resistivity: 'ohmm',
|
|
248
|
+
shortLength: 'in',
|
|
249
|
+
temperature: 'F',
|
|
250
|
+
massFlowRate: 'lb/min',
|
|
251
|
+
permiability: 'md',
|
|
252
|
+
concentration: 'ppm',
|
|
253
|
+
fluidVelocity: 'ft/min',
|
|
254
|
+
massPerLength: 'lb-ft',
|
|
255
|
+
anglePerLength: 'dp100f',
|
|
256
|
+
lengthPerAngle: 'in/rev',
|
|
257
|
+
volumeFlowRate: 'gal/min',
|
|
258
|
+
angularVelocity: 'rpm',
|
|
259
|
+
inversePressure: 'i-psi',
|
|
260
|
+
acousticSlowness: 'us/ft',
|
|
261
|
+
formationDensity: 'g/l',
|
|
262
|
+
gasConcentration: 'Units (0-5000u)',
|
|
263
|
+
pressureGradient: 'psi/ft',
|
|
264
|
+
massConcentration: 'lb/gal',
|
|
265
|
+
revolutionPerVolume: 'rpg',
|
|
266
|
+
spontaneousPotential: 'mV',
|
|
267
|
+
chemMassConcentration: 'lb/Mgal',
|
|
268
|
+
chemVolumeConcentration: 'gal/Mgal',
|
|
269
|
+
},
|
|
270
|
+
dev_center_enabled: true,
|
|
271
|
+
workflows_enabled: true,
|
|
272
|
+
with_subscription: false,
|
|
273
|
+
competitor_analysis_enabled: true,
|
|
274
|
+
},
|
|
275
|
+
groups: [
|
|
276
|
+
{
|
|
277
|
+
id: 5,
|
|
278
|
+
name: 'user',
|
|
279
|
+
company_id: 3,
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: 9,
|
|
283
|
+
name: 'customGroup',
|
|
284
|
+
company_id: 3,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
user: {},
|
|
289
|
+
company: {},
|
|
290
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
|
|
3
|
+
import App from '../App';
|
|
4
|
+
import { mockAppProps } from '../__mocks__/mockAppProps';
|
|
5
|
+
|
|
6
|
+
describe('<App />', () => {
|
|
7
|
+
it('should show correct layout', () => {
|
|
8
|
+
render(<App {...mockAppProps} />);
|
|
9
|
+
|
|
10
|
+
screen.getByText(/checked/i);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should show correct layout when settings are not provided', () => {
|
|
14
|
+
const propsWithoutSettings = mockAppProps;
|
|
15
|
+
delete propsWithoutSettings.isExampleCheckboxChecked;
|
|
16
|
+
|
|
17
|
+
render(<App {...propsWithoutSettings} />);
|
|
18
|
+
|
|
19
|
+
screen.getByText(/unchecked/i);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { render, screen, act } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
|
|
4
|
+
import AppSettings from '../AppSettings';
|
|
5
|
+
import { mockAppSettingsProps } from '../__mocks__/mockAppSettingsProps';
|
|
6
|
+
|
|
7
|
+
describe('<AppSettings />', () => {
|
|
8
|
+
it('should call onChange with a changed setting on settings change', async () => {
|
|
9
|
+
const handleSettingsChange = jest.fn();
|
|
10
|
+
|
|
11
|
+
render(<AppSettings {...mockAppSettingsProps} onSettingChange={handleSettingsChange} />);
|
|
12
|
+
|
|
13
|
+
const exampleCheckbox = screen.getByTestId('exampleCheckbox').querySelector('input');
|
|
14
|
+
|
|
15
|
+
await act(async () => {
|
|
16
|
+
await userEvent.click(exampleCheckbox);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(handleSettingsChange).toBeCalledWith('isExampleCheckboxChecked', false);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { components } from '@corva/ui';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
6
|
+
const Toggle = () => {
|
|
7
|
+
const [isOn, setIsOn] = useState<boolean>(false);
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{isOn ? 'ON' : 'OFF'}
|
|
12
|
+
<components.Button onClick={() => setIsOn(value => !value)}>toggle</components.Button>
|
|
13
|
+
</>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe('Tests examples', () => {
|
|
18
|
+
it('should use UTC timezone by default to not depend on the environment timezone', () => {
|
|
19
|
+
expect(Intl.DateTimeFormat().resolvedOptions().timeZone).toBe('UTC');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('<Toggle />', () => {
|
|
23
|
+
it('should be OFF by default', () => {
|
|
24
|
+
render(<Toggle />);
|
|
25
|
+
|
|
26
|
+
expect(screen.getByText('OFF')).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should switch to ON after a single press', async () => {
|
|
30
|
+
render(<Toggle />);
|
|
31
|
+
|
|
32
|
+
userEvent.click(screen.getByText('toggle'));
|
|
33
|
+
|
|
34
|
+
await waitFor(() => screen.getByText('ON'));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { Button } from '@corva/ui/components';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
|
|
6
|
-
const Toggle = () => {
|
|
7
|
-
const [isOn, setIsOn] = useState(false);
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<>
|
|
11
|
-
{isOn ? 'ON' : 'OFF'}
|
|
12
|
-
<Button onClick={() => setIsOn(value => !value)}>toggle</Button>
|
|
13
|
-
</>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe('<Toggle />', () => {
|
|
18
|
-
it('should be OFF by default', () => {
|
|
19
|
-
render(<Toggle />);
|
|
20
|
-
|
|
21
|
-
expect(screen.getByText('OFF')).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should switch to ON after a single press', async () => {
|
|
25
|
-
render(<Toggle />);
|
|
26
|
-
|
|
27
|
-
userEvent.click(screen.getByText('toggle'));
|
|
28
|
-
|
|
29
|
-
await waitFor(() => screen.getByText('ON'));
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { Button } from '@corva/ui/components';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
|
|
6
|
-
const Toggle = () => {
|
|
7
|
-
const [isOn, setIsOn] = useState<boolean>(false);
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<>
|
|
11
|
-
{isOn ? 'ON' : 'OFF'}
|
|
12
|
-
<Button onClick={() => setIsOn(value => !value)}>toggle</Button>
|
|
13
|
-
</>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe('<Toggle />', () => {
|
|
18
|
-
it('should be OFF by default', () => {
|
|
19
|
-
render(<Toggle />);
|
|
20
|
-
|
|
21
|
-
expect(screen.getByText('OFF')).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should switch to ON after a single press', async () => {
|
|
25
|
-
render(<Toggle />);
|
|
26
|
-
|
|
27
|
-
userEvent.click(screen.getByText('toggle'));
|
|
28
|
-
|
|
29
|
-
await waitFor(() => screen.getByText('ON'));
|
|
30
|
-
});
|
|
31
|
-
});
|