-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#712] fix: Fix displaying Governance Actions that fails the validati…
…on test
- Loading branch information
1 parent
cc64e97
commit b55aca2
Showing
17 changed files
with
137 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
govtool/frontend/src/utils/getMetadataDataMissingStatusTranslation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import i18n from "@/i18n"; | ||
import { MetadataValidationStatus } from "@/models"; | ||
|
||
/** | ||
* Retrieves the translation for the given metadata validation status. | ||
* | ||
* @param status - The metadata validation status. | ||
* @returns The translated string corresponding to the status. | ||
*/ | ||
export const getMetadataDataMissingStatusTranslation = ( | ||
status: MetadataValidationStatus, | ||
): string => { | ||
const errorKey = { | ||
[MetadataValidationStatus.URL_NOT_FOUND]: "dataMissing", | ||
[MetadataValidationStatus.INVALID_JSONLD]: "incorrectFormat", | ||
[MetadataValidationStatus.INVALID_HASH]: "notVerifiable", | ||
}[status] as "dataMissing" | "incorrectFormat" | "notVerifiable"; | ||
return i18n.t(`dataMissingErrors.${errorKey || "dataMissing"}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
govtool/frontend/src/utils/tests/getMetadataDataMissingStatusTranslation.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { MetadataValidationStatus } from "@models"; | ||
import { getMetadataDataMissingStatusTranslation } from "../getMetadataDataMissingStatusTranslation"; | ||
|
||
describe("getMetadataDataMissingStatusTranslation", () => { | ||
it("should return the correct translation for URL_NOT_FOUND status", () => { | ||
const translation = getMetadataDataMissingStatusTranslation( | ||
MetadataValidationStatus.URL_NOT_FOUND, | ||
); | ||
expect(translation).toBe("Data Missing"); | ||
}); | ||
|
||
it("should return the correct translation for INVALID_JSONLD status", () => { | ||
const translation = getMetadataDataMissingStatusTranslation( | ||
MetadataValidationStatus.INVALID_JSONLD, | ||
); | ||
expect(translation).toBe("Incorrect Format"); | ||
}); | ||
|
||
it("should return the correct translation for INVALID_HASH status", () => { | ||
const translation = getMetadataDataMissingStatusTranslation( | ||
MetadataValidationStatus.INVALID_HASH, | ||
); | ||
expect(translation).toBe("Not Verifiable"); | ||
}); | ||
|
||
it("should return the default translation for unknown status", () => { | ||
const translation = getMetadataDataMissingStatusTranslation( | ||
"UNKNOWN_STATUS" as MetadataValidationStatus, | ||
); | ||
expect(translation).toBe("Data Missing"); | ||
}); | ||
}); |
Oops, something went wrong.