Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
bot_type_values: Normalize int/string naming and migrate e2e test.
Sairam Bisoyi4cb70805c318
diff --git a/web/e2e-tests/settings.test.ts b/web/e2e-tests/settings.test.tsindex e5fd3295355..6878721cc6a 100644--- a/web/e2e-tests/settings.test.ts+++ b/web/e2e-tests/settings.test.ts@@ -2,12 +2,11 @@ import assert from "node:assert/strict";import type {Page} from "puppeteer";+import {GENERIC_BOT_TYPE, OUTGOING_WEBHOOK_BOT_TYPE} from "../src/bot_type_values.ts";+import * as common from "./lib/common.ts";import {test_credentials} from "./lib/common.ts";-const OUTGOING_WEBHOOK_BOT_TYPE = "3";-const GENERIC_BOT_TYPE = "1";-const zuliprc_regex =/^data:application\/octet-stream;charset=utf-8,\[api]\nemail=.+\nkey=.+\nsite=.+\n$/;diff --git a/web/src/bot_type_values.ts b/web/src/bot_type_values.tsindex a93e47a8ad3..4a878d73c92 100644--- a/web/src/bot_type_values.ts+++ b/web/src/bot_type_values.ts@@ -1,8 +1,9 @@// Bot type integer values from the API.-export const GENERIC_BOT_TYPE = 1;+export const GENERIC_BOT_TYPE_INT = 1;export const INCOMING_WEBHOOK_BOT_TYPE_INT = 2;export const OUTGOING_WEBHOOK_BOT_TYPE_INT = 3;// String forms used as HTML form values.+export const GENERIC_BOT_TYPE = "1";export const OUTGOING_WEBHOOK_BOT_TYPE = "3";export const EMBEDDED_BOT_TYPE = "4";diff --git a/web/src/settings_bots.ts b/web/src/settings_bots.tsindex 1a496fc991e..0fcecc8b086 100644--- a/web/src/settings_bots.ts+++ b/web/src/settings_bots.ts@@ -12,7 +12,7 @@ import type {Bot} from "./bot_data.ts";import * as bot_helper from "./bot_helper.ts";import {EMBEDDED_BOT_TYPE,- GENERIC_BOT_TYPE,+ GENERIC_BOT_TYPE_INT,INCOMING_WEBHOOK_BOT_TYPE_INT,OUTGOING_WEBHOOK_BOT_TYPE,OUTGOING_WEBHOOK_BOT_TYPE_INT,@@ -455,7 +455,7 @@ function bot_info(bot_user_id: number): BotInfo {: {bot_owner_id: null,}),- show_download_zuliprc_button: is_bot_owner && bot_user.bot_type === GENERIC_BOT_TYPE,+ show_download_zuliprc_button: is_bot_owner && bot_user.bot_type === GENERIC_BOT_TYPE_INT,show_generate_integration_url_button:can_modify_bot && bot_user.bot_type === INCOMING_WEBHOOK_BOT_TYPE_INT,};diff --git a/web/tests/peer_data.test.cjs b/web/tests/peer_data.test.cjsindex 4ce3aa45b95..e4d10ef31c4 100644--- a/web/tests/peer_data.test.cjs+++ b/web/tests/peer_data.test.cjs@@ -21,7 +21,7 @@ const {page_params} = require("./lib/zpage_params.cjs");const channel = mock_esm("../src/channel");-const {GENERIC_BOT_TYPE, INCOMING_WEBHOOK_BOT_TYPE_INT} = zrequire("bot_type_values");+const {GENERIC_BOT_TYPE_INT, INCOMING_WEBHOOK_BOT_TYPE_INT} = zrequire("bot_type_values");const peer_data = zrequire("peer_data");const people = zrequire("people");const {set_current_user, set_realm} = zrequire("state_data");@@ -544,7 +544,7 @@ test("is_subscriber_subset", async () => {email: "[email protected]",full_name: "Generic Bot",user_id: 106,- bot_type: GENERIC_BOT_TYPE,+ bot_type: GENERIC_BOT_TYPE_INT,});people.add_active_user(generic_bot);