Fix instances of double translation and guard translation calls using typescript (#11443)

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Michael Telatynski
2023-08-22 16:32:05 +01:00
committed by GitHub
co-authored by Richard van der Hoff
parent d13b6e1b41
commit ac70f7ac9b
157 changed files with 554 additions and 780 deletions
+22
View File
@@ -87,6 +87,20 @@ describe("AutoDiscoveryUtils", () => {
expect(logger.error).toHaveBeenCalled();
});
it("throws an error when homeserver config has fail error and recognised error string", () => {
const discoveryResult = {
...validIsConfig,
"m.homeserver": {
state: AutoDiscoveryAction.FAIL_ERROR,
error: AutoDiscovery.ERROR_INVALID_HOMESERVER,
},
};
expect(() => AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, discoveryResult)).toThrow(
"Unexpected error resolving homeserver configuration",
);
expect(logger.error).toHaveBeenCalled();
});
it("throws an error with fallback message identity server config has fail error", () => {
const discoveryResult = {
...validHsConfig,
@@ -249,4 +263,12 @@ describe("AutoDiscoveryUtils", () => {
);
});
});
describe("authComponentStateForError", () => {
const error = new Error("TEST");
it("should return expected error for the registration page", () => {
expect(AutoDiscoveryUtils.authComponentStateForError(error, "register")).toMatchSnapshot();
});
});
});
@@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`AutoDiscoveryUtils authComponentStateForError should return expected error for the registration page 1`] = `
{
"serverDeadError": <div>
<strong>
Your Element is misconfigured
</strong>
<div>
<span>
Ask your Element admin to check
<a
href="https://github.com/vector-im/element-web/blob/master/docs/config.md"
rel="noreferrer noopener"
target="_blank"
>
your config
</a>
for incorrect or duplicate entries.
</span>
</div>
</div>,
"serverErrorIsFatal": true,
"serverIsAlive": false,
}
`;