-
Notifications
You must be signed in to change notification settings - Fork 18
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
Implement JSON formatting and syntax highlighting #443
base: master
Are you sure you want to change the base?
Conversation
2148e57
to
e493080
Compare
e493080
to
b761066
Compare
b761066
to
896bc9b
Compare
896bc9b
to
1d73438
Compare
1d73438
to
db10ac3
Compare
db10ac3
to
339313b
Compare
00f7438
to
a095ea6
Compare
a095ea6
to
2e2ccbe
Compare
Enhance UX in Dashboard with JSON text editor using Monaco Editor (@monaco-editor/react) for improved formatting, syntax highlighting, and validation error reporting. Signed-off-by: AmerMesanovic <amer.mesanovic@secomind.com>
utilizing MonacoEditor. - Updated test selectors to target JSONEditor component. - Used force option for clicks to handle overlays in the editor. - Increased timeouts where necessary to account for MonacoEditor's loading times Signed-off-by: AmerMesanovic <amer.mesanovic@secomind.com>
2e2ccbe
to
44e9eb8
Compare
databaseTTL, | ||
} = parseMappingOptions(_.get(iface.mappings, '0')); | ||
const { reliability, explicitTimestamp, retention, expiry, databaseRetention, databaseTTL } = | ||
parseMappingOptions(_.get(iface.mappings, '0')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there are no changes, please avoid to change code format as this will introduce undesired noise to the pr.
Same goes for unnecessary ; at the end of a line
there are multiple occurrences in this PR that only changes how the code is styled but add nothing, it's better to move a restyling in another PR
@@ -128,7 +128,7 @@ const checkMappingEditorUIValues = ({ mapping, type, aggregation = 'individual' | |||
.should('be.visible') | |||
.within(() => { | |||
cy.contains(mapping.endpoint); | |||
cy.get('button').contains('Edit...').click(); | |||
cy.get('button').contains('Edit...').should('have.length', 1).click({ force: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could possible have more that one edit button? There is a necessity to check that?
interfaceFixtures.forEach((interfaceFixture) => { | ||
cy.fixture(interfaceFixture).then(({ data: iface }) => { | ||
setupInterfaceEditorFromUI(iface); | ||
checkInterfaceEditorUIValues(iface); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above, avoid newlines if not necessary
if (win.monaco && win.monaco.editor) { | ||
const editor = win.monaco.editor.getModels()[0]; | ||
const editorContent = editor.getValue(); | ||
const editorJson = JSON.parse(editorContent); | ||
|
||
expect(editorJson.simple_triggers[0].interface_name).to.equal(iface); | ||
} else { | ||
throw new Error('Monaco Editor instance is not available'); | ||
} | ||
}); | ||
cy.window().then((win) => { | ||
if (win.monaco && win.monaco.editor) { | ||
const editor = win.monaco.editor.getModels()[0]; | ||
const editorContent = editor.getValue(); | ||
const editorJson = JSON.parse(editorContent); | ||
|
||
expect(editorJson.simple_triggers[0].interface_major).to.equal(simpleTrigger.interface_major); | ||
} else { | ||
throw new Error('Monaco Editor instance is not available'); | ||
} | ||
}); | ||
cy.window().then((win) => { | ||
if (win.monaco && win.monaco.editor) { | ||
const editor = win.monaco.editor.getModels()[0]; | ||
const editorContent = editor.getValue(); | ||
const editorJson = JSON.parse(editorContent); | ||
|
||
expect(editorJson.simple_triggers[0].match_path).to.equal(simpleTrigger.match_path); | ||
} else { | ||
throw new Error('Monaco Editor instance is not available'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here there is a repetition of
cy.window().then((win) => {
if (win.monaco && win.monaco.editor) {
const editor = win.monaco.editor.getModels()[0];
const editorContent = editor.getValue();
const editorJson = JSON.parse(editorContent);
all of that can be merged in a single if clause
.scrollIntoView() | ||
.should('be.visible') | ||
.contains(simpleTrigger.interface_major) | ||
.contains(triggerOperatorToLabel[simpleTrigger.value_match_operator]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to check for more than one property, but
.contains(simpleTrigger.interface_major)
got removed
.scrollIntoView() | ||
.should('be.visible') | ||
.contains(simpleTrigger.interface_major) | ||
.contains(triggerOperatorToLabel[simpleTrigger.value_match_operator]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to check for more than one property, but
.contains(simpleTrigger.interface_major)
got removed entirely
cy.get('#triggerSource', { timeout: 1000 }).scrollIntoView().should('be.visible'); | ||
cy.get('button').contains('Hide source', { timeout: 1000 }).scrollIntoView().click(); | ||
cy.get('#triggerSource', { timeout: 1000 }).should('not.exist'); | ||
cy.get('button').contains('Show source', { timeout: 1000 }).scrollIntoView().click(); | ||
cy.get('#triggerSource', { timeout: 1000 }).scrollIntoView().should('be.visible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not required, all of those timeouts would only prolong the duration of this already long tests
This apply for the entire PR, check and be sure the timeouts/cy.wait functions are really needed
Enhance UX in Dashboard with JSON text editor using Monaco Editor (@monaco-editor/react) for improved formatting, syntax highlighting, and validation error reporting.