Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
3 changes: 2 additions & 1 deletion app/client/cypress/limited-tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# To run only limited tests - give the spec names in below format:
cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js
cypress/e2e/Regression/ClientSide/BugTests/AbortAction_Spec.ts
cypress/e2e/Regression/ServerSide/ApiTests/API_MultiPart_Spec.ts
# For running all specs - uncomment below:
#cypress/e2e/**/**/*

Expand Down
8 changes: 8 additions & 0 deletions app/client/src/pages/Editor/APIEditor/ApiEditorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ export function ApiEditorContextProvider({
],
);

/* @ts-expect-error: Types are not available */
if (typeof window.Cypress?.log === "function") {
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `ApiEditorContextProvider, ${JSON.stringify(settingsConfig || {})} ${JSON.stringify(value.settingsConfig || {})}`,
});
}

return (
<ApiEditorContext.Provider value={value}>
{children}
Expand Down
14 changes: 13 additions & 1 deletion app/client/src/pages/Editor/APIEditor/CommonEditorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function CommonEditorForm(props: CommonFormPropsWithExtraParams) {
moreActionsMenu,
notification,
saveActionName,
settingsConfig,
} = useContext(ApiEditorContext);

const {
Expand All @@ -194,9 +195,20 @@ function CommonEditorForm(props: CommonFormPropsWithExtraParams) {
isRunning,
onRunClick,
pluginId,
settingsConfig,
} = props;

/* @ts-expect-error: Types are not available */
if (typeof window.Cypress?.log === "function") {
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `CommonEditorForm: context, ${JSON.stringify(settingsConfig || {})}`,
});
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `CommonEditorForm: props, ${JSON.stringify(props.settingsConfig || {})}`,
});
}

const params = useParams<{ baseApiId?: string; baseQueryId?: string }>();

// passing lodash's equality function to ensure that this selector does not cause a rerender multiple times.
Expand Down
8 changes: 8 additions & 0 deletions app/client/src/pages/Editor/APIEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ function ApiEditorWrapper(props: ApiEditorWrapperProps) {
return <ConvertEntityNotification icon={icon} name={action?.name || ""} />;
}, [action?.name, isConverting, icon]);

/* @ts-expect-error: Types are not available */
if (typeof window.Cypress?.log === "function") {
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `ApiEditorWrapper, ${JSON.stringify(settingsConfig || {})} ${pluginId}`,
});
}

return (
<ApiEditorContextProvider
actionRightPaneBackLink={actionRightPaneBackLink}
Expand Down
8 changes: 8 additions & 0 deletions app/client/src/pages/Editor/ActionSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ const ActionSettingsWrapper = styled.div`
`;

function ActionSettings(props: ActionSettingsProps): JSX.Element {
/* @ts-expect-error: Types are not available */
if (typeof window.Cypress?.log === "function") {
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `props.actionSettingsConfig, ${JSON.stringify(props.actionSettingsConfig || {})}`,
});
}

return (
<ActionSettingsWrapper>
{!props.actionSettingsConfig ? (
Expand Down
11 changes: 11 additions & 0 deletions app/client/src/sagas/PluginSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ function* fetchPluginFormConfigsSaga(action?: {
editorConfigs[pluginId] = pluginFormData[index].editor;
}

if (
/* @ts-expect-error: Types are not available */
typeof window.Cypress?.log === "function" &&
plugin?.type === PluginType.API
) {
/* @ts-expect-error: Types are not available */
window.Cypress.log({
message: `fetchPluginFormConfigsSaga, ${JSON.stringify(pluginFormData[index].setting || {})} ${JSON.stringify(defaultActionSettings[plugin.type] || {})}`,
});
}

Comment on lines +196 to +206

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider improving type safety and logging implementation.

The current implementation has several areas for improvement:

  1. Using @ts-expect-error is not ideal for handling Cypress types
  2. The logging implementation could be more structured

Consider these improvements:

+ // Add to a types file
+ interface CypressWindow extends Window {
+   Cypress?: {
+     log: (args: { message: string }) => void;
+   };
+ }

- /* @ts-expect-error: Types are not available */
- typeof window.Cypress?.log === "function"
+ typeof (window as CypressWindow).Cypress?.log === "function"

- /* @ts-expect-error: Types are not available */
- window.Cypress.log({
+ (window as CypressWindow).Cypress?.log({
-   message: `fetchPluginFormConfigsSaga, ${JSON.stringify(pluginFormData[index].setting || {})} ${JSON.stringify(defaultActionSettings[plugin.type] || {})}`,
+   message: `Plugin Settings:
+     Current: ${JSON.stringify(pluginFormData[index].setting || {})}
+     Default: ${JSON.stringify(defaultActionSettings[plugin.type] || {})}`
  });

Committable suggestion skipped: line range outside the PR's diff.

// Action settings form if not available use default
if (plugin && !pluginFormData[index].setting) {
settingConfigs[pluginId] = defaultActionSettings[plugin.type];
Expand Down