From 89fc14609e8c19698e9b43b57357b329e36cc5e3 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov Date: Mon, 30 Oct 2023 12:31:41 +0200 Subject: [PATCH] refactor: improve blacklisted username error by adding secondary message (#3444) --- api/index.js | 2 +- api/pin.js | 2 +- api/top-langs.js | 2 +- tests/api.test.js | 4 +++- tests/pin.test.js | 4 +++- tests/top-langs.test.js | 4 +++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/api/index.js b/api/index.js index e1e1c27..2029367 100644 --- a/api/index.js +++ b/api/index.js @@ -43,7 +43,7 @@ export default async (req, res) => { if (blacklist.includes(username)) { return res.send( - renderError("Something went wrong", "", { + renderError("Something went wrong", "This username is blacklisted", { title_color, text_color, bg_color, diff --git a/api/pin.js b/api/pin.js index bdad925..c67df29 100644 --- a/api/pin.js +++ b/api/pin.js @@ -30,7 +30,7 @@ export default async (req, res) => { if (blacklist.includes(username)) { return res.send( - renderError("Something went wrong", "", { + renderError("Something went wrong", "This username is blacklisted", { title_color, text_color, bg_color, diff --git a/api/top-langs.js b/api/top-langs.js index 0ca96fe..382ee42 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -38,7 +38,7 @@ export default async (req, res) => { if (blacklist.includes(username)) { return res.send( - renderError("Something went wrong", "", { + renderError("Something went wrong", "This username is blacklisted", { title_color, text_color, bg_color, diff --git a/tests/api.test.js b/tests/api.test.js index a6ed04b..0c0da38 100644 --- a/tests/api.test.js +++ b/tests/api.test.js @@ -291,7 +291,9 @@ describe("Test /api/", () => { await api(req, res); expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); - expect(res.send).toBeCalledWith(renderError("Something went wrong")); + expect(res.send).toBeCalledWith( + renderError("Something went wrong", "This username is blacklisted"), + ); }); it("should render error card when wrong locale is provided", async () => { diff --git a/tests/pin.test.js b/tests/pin.test.js index 0dcb5aa..105e445 100644 --- a/tests/pin.test.js +++ b/tests/pin.test.js @@ -155,7 +155,9 @@ describe("Test /api/pin", () => { await pin(req, res); expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); - expect(res.send).toBeCalledWith(renderError("Something went wrong")); + expect(res.send).toBeCalledWith( + renderError("Something went wrong", "This username is blacklisted"), + ); }); it("should render error card if wrong locale provided", async () => { diff --git a/tests/top-langs.test.js b/tests/top-langs.test.js index 272ee7e..692681b 100644 --- a/tests/top-langs.test.js +++ b/tests/top-langs.test.js @@ -183,7 +183,9 @@ describe("Test /api/top-langs", () => { await topLangs(req, res); expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml"); - expect(res.send).toBeCalledWith(renderError("Something went wrong")); + expect(res.send).toBeCalledWith( + renderError("Something went wrong", "This username is blacklisted"), + ); }); it("should render error card if wrong locale provided", async () => {