Skip to content

Commit

Permalink
Refactor check_overflow_text function This commit refactors the funct…
Browse files Browse the repository at this point in the history
…ion to . The logic for handling if remaining characters less than 0 than show exceeded msg and else condition show remainingCharacters. This change simplifies the code while ensuring clarity in different scenarios of remaining characters.

Additionally, the tooltip associated with the character counter has been updated to display 'Maximum message length: 10000 characters.'

Fixes: zulip#28706
  • Loading branch information
amaranand360 committed Feb 13, 2024
1 parent a8f4082 commit 15ad747
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
12 changes: 0 additions & 12 deletions web/tests/compose.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,16 +851,4 @@ test_ui("narrow_button_titles", ({override}) => {

run_test("reset MockDate", () => {
MockDate.reset();
});

run_test("test check_overflow_text with compose_limit_indicator.hbs", ({ mock_template }) => {

// Set the expected remaining_length value
const remaining_length = 42;

mock_template("compose_limit_indicator.hbs", false, (data) => {
assert.deepEqual(data, { remaining_length });
return "stub-for-zjquery";
});

});
10 changes: 0 additions & 10 deletions web/tests/compose_validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,16 +595,6 @@ test_ui("test_check_overflow_text", ({mock_template}) => {

// Indicator should show orange colored text
banner_rendered = false;
$textarea.val("a".repeat(9000 + 1));
compose_validate.check_overflow_text();
assert.ok(!$indicator.hasClass("over_limit"));
assert.equal(limit_indicator_html, "9001\n");
assert.ok(!$textarea.hasClass("over_limit"));
assert.ok(!$(".message-send-controls").hasClass("disabled-message-send-controls"));
assert.ok(!banner_rendered);

// Indicator must be empty
banner_rendered = false;
$textarea.val("a".repeat(9000));
compose_validate.check_overflow_text();
assert.ok(!$indicator.hasClass("over_limit"));
Expand Down

0 comments on commit 15ad747

Please sign in to comment.