fix: Unit test fix (#36471)
## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.ImportExport" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!IMPORTANT] > 🟣 🟣 🟣 Your tests are running. > Tests running at: <https://github.com/appsmithorg/appsmith/actions/runs/10988998437> > Commit: f59a3687d89d4e86a28c69fa7fec79190bc34ab3 > Workflow: `PR Automation test suite` > Tags: `@tag.ImportExport` > Spec: `` > <hr>Mon, 23 Sep 2024 06:43:22 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Updated error message for clarity when importing an invalid JSON file, ensuring consistent phrasing and capitalization. - Introduced a standardized error message constant for improved maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
7685c852cc
commit
44f14865d7
|
|
@ -0,0 +1,7 @@
|
|||
package com.appsmith.server.constants;
|
||||
|
||||
public class ImportExportConstants {
|
||||
|
||||
public static final String ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE =
|
||||
"'. Sorry! It seems you've imported a page-level JSON instead of an application. Please use the import within the page.";
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.appsmith.external.helpers.Stopwatch;
|
|||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.server.constants.ArtifactType;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.ImportExportConstants;
|
||||
import com.appsmith.server.converters.ArtifactExchangeJsonAdapter;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.Artifact;
|
||||
|
|
@ -421,11 +422,10 @@ public class ImportServiceCEImpl implements ImportServiceCE {
|
|||
log.error("Error in importing {}. Field {} is missing", artifactContextString, errorField);
|
||||
|
||||
if (errorField.equals(artifactContextString)) {
|
||||
return Mono.error(
|
||||
new AppsmithException(
|
||||
AppsmithError.VALIDATION_FAILURE,
|
||||
"Field '" + artifactContextString
|
||||
+ "'. Sorry! It seems you've imported a page-level JSON instead of an application. Please use the import within the page."));
|
||||
return Mono.error(new AppsmithException(
|
||||
AppsmithError.VALIDATION_FAILURE,
|
||||
"Field '" + artifactContextString
|
||||
+ ImportExportConstants.ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE));
|
||||
}
|
||||
|
||||
return Mono.error(new AppsmithException(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.appsmith.external.models.SSLDetails;
|
|||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.ImportExportConstants;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
|
|
@ -895,14 +896,11 @@ public class ImportServiceTests {
|
|||
importService.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.expectErrorMatches(
|
||||
throwable -> throwable instanceof AppsmithException
|
||||
&& throwable
|
||||
.getMessage()
|
||||
.equals(
|
||||
AppsmithError.VALIDATION_FAILURE.getMessage(
|
||||
"Field '" + FieldName.APPLICATION
|
||||
+ "' Sorry! Seems like you've imported a page-level json instead of an application. Please use the import within the page.")))
|
||||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
&& throwable
|
||||
.getMessage()
|
||||
.equals(AppsmithError.VALIDATION_FAILURE.getMessage("Field '" + FieldName.APPLICATION
|
||||
+ ImportExportConstants.ARTIFACT_JSON_IMPORT_VALIDATION_ERROR_MESSAGE)))
|
||||
.verify();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user