mockaton 10.4.0 → 10.4.2
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/README.md +5 -1
- package/package.json +1 -1
- package/src/Dashboard.css +3 -4
- package/src/Dashboard.js +13 -8
package/README.md
CHANGED
|
@@ -431,8 +431,12 @@ config.plugins = [
|
|
|
431
431
|
// IOW, your plugins array overwrites the default list. This way you can remove it.
|
|
432
432
|
[/\.(js|ts)$/, jsToJsonPlugin],
|
|
433
433
|
|
|
434
|
+
|
|
434
435
|
[/\.yml$/, yamlToJsonPlugin],
|
|
435
|
-
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
// e.g. GET /api/foo would be capitalized
|
|
439
|
+
[/foo\.GET\.200\.txt$/, capitalizePlugin]
|
|
436
440
|
]
|
|
437
441
|
|
|
438
442
|
function yamlToJsonPlugin(filePath) {
|
package/package.json
CHANGED
package/src/Dashboard.css
CHANGED
|
@@ -385,7 +385,7 @@ table {
|
|
|
385
385
|
border-top: 20px solid transparent;
|
|
386
386
|
text-align: left;
|
|
387
387
|
}
|
|
388
|
-
|
|
388
|
+
|
|
389
389
|
> tr:first-child > th {
|
|
390
390
|
border-top: 0;
|
|
391
391
|
}
|
|
@@ -633,7 +633,7 @@ table {
|
|
|
633
633
|
height: 2px;
|
|
634
634
|
background: var(--colorComboBoxHeaderBackground);
|
|
635
635
|
|
|
636
|
-
div {
|
|
636
|
+
> div {
|
|
637
637
|
position: absolute;
|
|
638
638
|
top: 0;
|
|
639
639
|
left: 0;
|
|
@@ -642,8 +642,7 @@ table {
|
|
|
642
642
|
background: var(--colorAccent);
|
|
643
643
|
animation-name: _kfProgress;
|
|
644
644
|
animation-timing-function: linear;
|
|
645
|
-
|
|
646
|
-
/*animation-duration: It's in JavaScript */
|
|
645
|
+
/* duration in JavaScript */
|
|
647
646
|
}
|
|
648
647
|
}
|
|
649
648
|
@keyframes _kfProgress {
|
package/src/Dashboard.js
CHANGED
|
@@ -13,6 +13,8 @@ const Strings = {
|
|
|
13
13
|
delay: 'Delay',
|
|
14
14
|
delay_ms: 'Delay (ms)',
|
|
15
15
|
empty_response_body: '/* Empty Response Body */',
|
|
16
|
+
error_server_down: 'Looks like the Mockaton server is not running',
|
|
17
|
+
error_unexpected_error: 'Unexpected Error',
|
|
16
18
|
fallback_server: 'Fallback',
|
|
17
19
|
fallback_server_error: '⛔ Fallback Backend Error',
|
|
18
20
|
fallback_server_placeholder: 'Type backend address',
|
|
@@ -111,7 +113,7 @@ const state = {
|
|
|
111
113
|
leftSideWidth: undefined
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
const mockaton = new Commander(
|
|
116
|
+
const mockaton = new Commander(location.origin)
|
|
115
117
|
updateState()
|
|
116
118
|
initLongPoll()
|
|
117
119
|
|
|
@@ -124,7 +126,7 @@ async function updateState() {
|
|
|
124
126
|
document.body.replaceChildren(...App())
|
|
125
127
|
}
|
|
126
128
|
catch (error) {
|
|
127
|
-
onError(
|
|
129
|
+
onError(error)
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
|
|
@@ -449,7 +451,7 @@ function MockSelector(broker) {
|
|
|
449
451
|
}
|
|
450
452
|
|
|
451
453
|
let selected = broker.currentMock.file
|
|
452
|
-
const { status
|
|
454
|
+
const { status } = parseFilename(selected)
|
|
453
455
|
const files = broker.mocks.filter(item =>
|
|
454
456
|
status === 500 ||
|
|
455
457
|
!item.includes(AUTOGENERATED_500_COMMENT))
|
|
@@ -461,7 +463,7 @@ function MockSelector(broker) {
|
|
|
461
463
|
function nameFor(file) {
|
|
462
464
|
if (file === Strings.proxied)
|
|
463
465
|
return Strings.proxied
|
|
464
|
-
const { status, ext
|
|
466
|
+
const { status, ext } = parseFilename(file)
|
|
465
467
|
const comments = extractComments(file)
|
|
466
468
|
const isAutogen500 = comments.includes(AUTOGENERATED_500_COMMENT)
|
|
467
469
|
return [
|
|
@@ -745,14 +747,17 @@ async function previewMock(method, urlMask, href) {
|
|
|
745
747
|
previewMock.controller?.abort()
|
|
746
748
|
previewMock.controller = new AbortController
|
|
747
749
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
+
const spinnerTimer = setTimeout(() => {
|
|
751
|
+
payloadViewerTitleRef.current.replaceChildren(Strings.fetching)
|
|
752
|
+
payloadViewerRef.current.replaceChildren(PayloadViewerProgressBar())
|
|
753
|
+
}, 80)
|
|
750
754
|
|
|
751
755
|
try {
|
|
752
756
|
const response = await fetch(href, {
|
|
753
757
|
method,
|
|
754
758
|
signal: previewMock.controller.signal
|
|
755
759
|
})
|
|
760
|
+
clearTimeout(spinnerTimer)
|
|
756
761
|
await updatePayloadViewer(method, urlMask, response)
|
|
757
762
|
}
|
|
758
763
|
catch (err) {
|
|
@@ -829,9 +834,9 @@ function onError(error) {
|
|
|
829
834
|
if (error?.name === 'AbortError')
|
|
830
835
|
return
|
|
831
836
|
if (error?.message === 'Failed to fetch')
|
|
832
|
-
showErrorToast(
|
|
837
|
+
showErrorToast(Strings.error_server_down)
|
|
833
838
|
else
|
|
834
|
-
showErrorToast(error ||
|
|
839
|
+
showErrorToast(error || Strings.error_unexpected_error)
|
|
835
840
|
console.error(error)
|
|
836
841
|
}
|
|
837
842
|
|