Skip to content
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

test: added test for incompatible file #37323

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
homePage,
partialImportExport,
agHelper
} from "../../../../support/Objects/ObjectsCore";

describe(
"Partial import App",
{ tags: ["@tag.ImportExport", "@tag.Git"] },
() => {
beforeEach(() => {
partialImportExport.OpenImportModal();
});

it("1. Verify Importing App into Page shows error message for incompatible json file ", () => {
homePage.ImportApp("PartialImportAppNegative.json", "", true);
agHelper.ValidateToastMessage("Unable to import artifact in workspace The file is not compatible with the current partial import operation. Please check the file and try again.. {1}")
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance test robustness with constants and additional assertions

While the test follows most best practices, consider these improvements:

  1. Move the error message to a constants file to avoid hardcoded strings in assertions
  2. Add assertions to verify the modal state after the error

Here's how you could improve it:

+ import { importExportConstants } from "../../../../support/Constants";
// ...
  it("1. Verify Importing App into Page shows error message for incompatible json file ", () => {
    homePage.ImportApp("PartialImportAppNegative.json", "", true);
-   agHelper.ValidateToastMessage("Unable to import artifact in workspace The file is not compatible with the current partial import operation. Please check the file and try again.. {1}")
+   agHelper.ValidateToastMessage(importExportConstants.INCOMPATIBLE_JSON_FILE_ERROR);
+   // Add additional assertions
+   agHelper.AssertElementVisibility(partialImportExport.importModal);
+   agHelper.AssertElementVisibility(partialImportExport.errorBlock);
  });

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

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor test case to follow best practices.

  1. Move the error message to a constant or fixture to avoid hardcoded strings in assertions
  2. Consider moving the test file name to a constant or fixture
+ const ERROR_MESSAGES = {
+   INCOMPATIBLE_FILE: "Unable to import artifact in workspace The file is not compatible with the current partial import operation. Please check the file and try again.. {1}"
+ };
+ const TEST_FILES = {
+   INCOMPATIBLE_JSON: "PartialImportAppNegative.json"
+ };

  it("1. Verify Importing App into Page shows error message for incompatible json file ", () => {
-   homePage.ImportApp("PartialImportAppNegative.json", "", true);
-   agHelper.ValidateToastMessage("Unable to import artifact in workspace The file is not compatible with the current partial import operation. Please check the file and try again.. {1}")
+   homePage.ImportApp(TEST_FILES.INCOMPATIBLE_JSON, "", true);
+   agHelper.ValidateToastMessage(ERROR_MESSAGES.INCOMPATIBLE_FILE)
  });

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

},
);
550 changes: 550 additions & 0 deletions app/client/cypress/fixtures/PartialImportAppNegative.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/client/cypress/limited-tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 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/PartialImportExport/ParitalImportAppNegative_spec.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo in spec filename: "Parital" → "Partial"

The specification filename contains a typo that should be corrected to ensure consistency and prevent potential issues.

Apply this diff:

-cypress/e2e/Regression/ClientSide/PartialImportExport/ParitalImportAppNegative_spec.ts
+cypress/e2e/Regression/ClientSide/PartialImportExport/PartialImportAppNegative_spec.ts
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cypress/e2e/Regression/ClientSide/PartialImportExport/ParitalImportAppNegative_spec.ts
cypress/e2e/Regression/ClientSide/PartialImportExport/PartialImportAppNegative_spec.ts

# For running all specs - uncomment below:
#cypress/e2e/**/**/*

Expand Down
Loading