Commit Graph

60 Commits

Author SHA1 Message Date
Dinesh 6ce2662df5 timerender: Extract timezone offset string generation to a function. 2021-07-05 18:08:18 -07:00
Dinesh 6c7526002f timerender_test: Restore previous process.env.TZ.
Deleting this variable was causing failures for some.

Was introduced in d779a1c.
2021-07-02 13:30:15 -07:00
Dinesh d779a1cf2f timestamp_tooltip: Reformat tooltip content.
Reformats to a format like: 5/19/17, 2:42:53 AM IST (UTC+5.5).
2021-07-01 11:46:25 -07:00
Dinesh afe6404167 timerender: Use tippy tooltip for topic header timestamp. 2021-06-25 18:10:42 -07:00
Dinesh 177dd05d0b timestamp: Move tooltip date, time rendering logic to tippyjs.js.
Makes use of `onShow` for all calculations and rendering
of date, time for tooltip.
2021-06-25 18:10:42 -07:00
Dinesh c10e56698c timestamp: Migrate message_time from title to tippyjs tooltip.
This keeps it consistent with other widgets in message body area.

Set the display position to top to be consistent with
compose control buttons.

Changed the tooltip content to be more readable like
Thursday, May 18, 2017
7:12:53 AM India Standard Time

Also changed timerender.get_full_datetime() to consider
users' 24 hour format preference.
2021-06-25 18:10:42 -07:00
Aman Agrawal 3e872b1fa5 timerender: Render past time till 24 hours before showing yesterday.
This avoids the issue of all the topics in recent topics marked
as yesterday after mid-night.

This change also affects other pieces of UI using this function
like buddy list in a similar way.
2021-06-17 15:18:08 -07:00
Steve Howell d5c4495fa5 zjsunit: Wire $ to zjquery by default.
I introduce `mock_jquery` for modules that
want their own mock implementation.
2021-06-16 12:55:53 -04:00
Anders Kaseorg 2004a85fb1 i18n: Automatically convert remaining JavaScript messages to FormatJS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-13 17:41:10 -07:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg bb1b2048bd js: Convert static/js/i18n.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Steve Howell bbe12a3967 node tests: Ensure clean data for timerender tests.
We explicitly initialize things that future tests
could possibly mutate.
2021-03-14 11:38:21 -04:00
Anders Kaseorg ea9ca6b7d0 js: Use jQuery as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:08:25 -08:00
Steve Howell 1a241cef88 node tests: Use array syntax more aggressively. 2021-02-23 09:15:36 -05:00
Anders Kaseorg 7e3735b9ba node_tests: Don’t read page_params from deprecated global variable.
Follow up to commit 89aa3155a9 (#17262).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 19:46:42 -08:00
Steve Howell 64c7eb67eb zjquery: Make zjquery a singleton.
We no longer export make_zjquery().

We now instead have a singleton zjquery instance
that we attach to global.$ in index.js.

We call $.clear_all_elements() before each module.
(We will soon get even more aggressive about doing
it in run_test.)

Test functions can still override $ with set_global.
A good example of this is copy_and_paste using the
real jquery module.

We no longer exempt $ as a global variable, so
test modules that use the zjquery $ need to do:

    const $ = require("../zjsunit/zjquery");
2021-02-21 17:34:55 -05:00
Anders Kaseorg 89aa3155a9 node_tests: Don’t read from most deprecated global variables.
We still need to write to these globals with set_global because the
code being tested reads from them, but the tests themselves should
never need to read from them.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 07:40:22 -08:00
Anders Kaseorg 9896782fd1 dependencies: Remove XDate.
It’s even more unmaintained than Moment and doesn’t add any
functionality we don’t already have.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-07 06:41:33 -05:00
Anders Kaseorg 87cbd3bf16 node_tests: Use MockDate in timerender test too.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 13:46:37 -08:00
aryanshridhar f92f99d92d dependencies: Replace moment.js with date-fns.
Replaced methods/functions of moment.js with date-fns library.
The motive was to replace it with a smaller frontend timezone library.

Date-fns ~ 11.51 kb
moment.js ~ 217.87 kb

Some of the format strings change because date-fns encodes them
differently from how moment did.

Fixes #16373.
2021-02-05 11:04:32 -08:00
Aman Agrawal 8729965548 last_seen_status_from_date: Fix incorrect last seen value.
We use day_old calculated based on day instead of hours to
render last seen values. This fixes us incorrectly quoting
anything 24 - 48 hours ago as Yesterday and
incorrectly quoting `time` that are Yesterday
but < 24 hours ago in 'x hours ago' format.
2021-01-27 09:58:22 -08:00
Anders Kaseorg 21d432e12c zjsunit: Deglobalize run_test.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-12-01 07:14:00 -05:00
Anders Kaseorg 3715e68598 zjsunit: Deglobalize zjquery.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-12-01 07:14:00 -05:00
Anders Kaseorg 425f1789e2 zjsunit: Deglobalize namespace.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-12-01 07:14:00 -05:00
Anders Kaseorg 7b03d48798 zjsunit: Deglobalize assert.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-12-01 07:14:00 -05:00
Anders Kaseorg 73a14bee6f eslint: Fix unicorn/escape-case and unicorn/no-hex-escape.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/escape-case.md
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-hex-escape.md

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-07 16:00:33 -07:00
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00
Anders Kaseorg a43307bc4e js: Use Moment.js as a module.
Note that require("moment") and require("moment-timezone") resolve to
the same thing, but the latter adds timezone support as a side effect.
So I went with the latter in every file where .tz is used.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-28 10:54:35 -07:00
Anders Kaseorg bcab7efb37 js: Use XDate as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-28 10:54:35 -07:00
Steve Howell fb06aa9419 node tests: Swap actual/expected in various assert calls. 2020-07-28 11:48:55 -04:00
Anders Kaseorg e3b3df328d eslint: Replace sort-imports with import/order.
import/order sorts require() calls as well as import statements.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-24 09:42:56 -07:00
Anders Kaseorg b65d2e063d js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00
Anders Kaseorg 8046b6477a js: Remove extra consecutive spaces.
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00
Anders Kaseorg f3726db89a js: Normalize strings to double quotes.
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:24 -07:00
Rohitt Vashishtha 1d3234b6c6 timerender: Make moment() return static date.
The previous iteration of the test was flaky when we could get
off by one errors between two moment() calls.
2020-07-07 08:04:50 -04:00
Rohitt Vashishtha c87446a8de timestamp: Extract and improve timerender.get_timestamp_for_flatpickr.
To make the typeahead code more readable, we extract this function to
timerender. We also improve the logic to be more readable, and add tests
to confirm its validity.
2020-07-06 15:53:56 -07:00
Anders Kaseorg a79322bc94 eslint: Enable prefer-arrow-callback.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:55:50 -07:00
Steve Howell b994889315 node tests: Just set i18n every time.
Explicitly stubbing i18n in 48 different files
is mostly busy work at this point, and it doesn't
provide much signal, since often it's invoked
only to satisfy transitive dependencies.
2020-02-28 17:11:24 -08:00
Steve Howell 30ad1b6f16 zjsunit: Remove Dict dependency.
We now require the actual tests to explicitly
to zrequire Dict, rather than magically adding this.

In one case, the use of Dict was clearly just for
the test (not the app), so I converted that an ordinary
JS object (see timerender.js).
2020-01-03 17:19:59 -08:00
Anders Kaseorg 428956c086 zjsunit: Remove set_global side effect from zrequire.
ES6 and TS modules don’t insert themselves into `window`, so our tests
shouldn’t insert them either.  Since the test `window` behaves like
`global` now, we can rely on legacy modules that do insert themselves
to do it themselves.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-13 14:29:17 -08:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
vinitS101 3d01921e1a user status: Changes to Last active field of Full User Profile.
If a user was active within the last 90 days,
show number of days (23 Days ago).
If the user was active more than 90 days ago and in the same year,
then show MMM DD (Mar 15).
In any other case show MMM DD YYYY (Nov 10 2018),
Change timerender.js test to accomodate changes.
2019-08-07 16:20:19 -07:00
Thomas Ip c6cdcd082e dependencies: Upgrade node to 12.3.1.
API changes:
* The behaviour of Date.toLocaleTimeString() reverts to pre 8.0.0,
  this only affects automated tests. Lots of other API changes but
  we didn't use any of those.
* The internal sorting algorithm changed which causes one of our own
  compare function to miss coverage.
2019-06-05 17:15:52 -07:00
Tim Abbott b2939cdf19 lint: Fix comma spacing in node tests.
I apparently failed to check the tests codebase before merging the
last linter commit.  Oops.
2018-12-07 13:14:28 -08:00
Aditya Bansal a4b51a33f8 timerender.js: Remove use of legacy font awesome base class 'icon-vector'. 2018-10-15 19:22:57 +05:30
Yashashvi Dave e398b25429 user popover: Remove repetitive "Last seen" text from all last seens.
This text was unnecessary.

Fixes part of #10303.
2018-08-28 16:04:52 -07:00
Yashashvi Dave 6622f995b0 user profile popover: Rename user last seen.
Rename "Last seen just now" to "Just now",
and "Unknown" to "More than 2 weeks ago"
in user profile popover.
2018-08-21 11:42:59 -07:00
Steve Howell 42435db492 Add run_test helper for individual tests.
This run_test helper sets up a convention that allows
us to give really short tracebacks for errors, and
eventually we can have more control over running
individual tests.  (The latter goal has some
complications, since we often intentionally leak
setup in tests.)
2018-05-15 08:24:44 -07:00
Priyank ee078c372f install-node: Upgrade node, yarn, and nvm.
node -> v8.9.4
yarn -> 1.5.1
nvm -> 0.33.8

Also updates a test in timerender.js which depends on time
provided by node which is now changed in newer release.

Some changes have been made in circeci script, we just create ~/.config
directory and chown it to circleci user so installing new version of yarn
does not cause any ci failure on circleci during provision.
2018-04-09 13:56:48 -07:00
Shubham Dhama 804a5f3306 drafts: Add timestamps showing when last modified.
Fixes: #3790.
2018-02-19 09:55:50 -08:00