Merge branch 'hotfix/2.17.1' into develop

This commit is contained in:
Sojan
2023-05-19 20:56:16 +05:30
5 changed files with 60 additions and 14 deletions

View File

@@ -39,7 +39,8 @@ export const getUnixStartOfDay = date => getUnixTime(startOfDay(date));
export const getUnixEndOfDay = date => getUnixTime(endOfDay(date));
export const generateRelativeTime = (value, unit, languageCode) => {
const rtf = new Intl.RelativeTimeFormat(languageCode, {
const code = languageCode?.replace(/_/g, '-'); // Hacky fix we need to handle it from source
const rtf = new Intl.RelativeTimeFormat(code, {
numeric: 'auto',
});
return rtf.format(value, unit);

View File

@@ -64,15 +64,59 @@ describe('#isTimeAfter', () => {
});
});
describe('#generateRelativeTime', () => {
it('should return correct relative time', () => {
expect(generateRelativeTime(-1, 'day', 'en')).toEqual('yesterday');
expect(generateRelativeTime(1, 'day', 'en')).toEqual('tomorrow');
expect(generateRelativeTime(1, 'hour', 'en')).toEqual('in 1 hour');
expect(generateRelativeTime(-1, 'hour', 'en')).toEqual('1 hour ago');
expect(generateRelativeTime(1, 'minute', 'en')).toEqual('in 1 minute');
expect(generateRelativeTime(-1, 'minute', 'en')).toEqual('1 minute ago');
expect(generateRelativeTime(1, 'second', 'en')).toEqual('in 1 second');
expect(generateRelativeTime(-1, 'second', 'en')).toEqual('1 second ago');
describe('generateRelativeTime', () => {
it('should return a string with the relative time', () => {
const value = 1;
const unit = 'second';
const languageCode = 'en-US';
const expectedResult = 'in 1 second';
const actualResult = generateRelativeTime(value, unit, languageCode);
expect(actualResult).toBe(expectedResult);
});
it('should return a string with the relative time in a different language', () => {
const value = 10;
const unit = 'minute';
const languageCode = 'de-DE';
const expectedResult = 'in 10 Minuten';
const actualResult = generateRelativeTime(value, unit, languageCode);
expect(actualResult).toBe(expectedResult);
});
it('should return a string with the relative time for a different unit', () => {
const value = 1;
const unit = 'hour';
const languageCode = 'en-US';
const expectedResult = 'in 1 hour';
const actualResult = generateRelativeTime(value, unit, languageCode);
expect(actualResult).toBe(expectedResult);
});
it('should throw an error if the value is not a number', () => {
const value = 1;
const unit = 'day';
const languageCode = 'en_US';
const expectedResult = 'tomorrow';
const actualResult = generateRelativeTime(value, unit, languageCode);
expect(actualResult).toBe(expectedResult);
});
it('should throw an error if the value is not a number', () => {
const value = 1;
const unit = 'day';
const languageCode = 'en-US';
const expectedResult = 'tomorrow';
const actualResult = generateRelativeTime(value, unit, languageCode);
expect(actualResult).toBe(expectedResult);
});
});

View File

@@ -1,5 +1,5 @@
shared: &shared
version: '2.17.0'
version: '2.17.1'
development:
<<: *shared

View File

@@ -36,7 +36,7 @@ COPY Gemfile Gemfile.lock ./
# https://github.com/googleapis/google-cloud-ruby/issues/13306
# adding xz as nokogiri was failing to build libxml
# https://github.com/chatwoot/chatwoot/issues/4045
RUN apk update && apk add --no-cache build-base musl ruby-full ruby-dev gcc make musl-dev openssl openssl-dev g++ linux-headers xz
RUN apk update && apk add --no-cache build-base musl ruby-full ruby-dev gcc make musl-dev openssl openssl-dev g++ linux-headers xz vips
RUN bundle config set --local force_ruby_platform true
# Do not install development or test gems in production
@@ -97,6 +97,7 @@ RUN apk update && apk add --no-cache \
postgresql-client \
imagemagick \
git \
vips \
&& gem install bundler
RUN if [ "$RAILS_ENV" != "production" ]; then \

View File

@@ -1,6 +1,6 @@
{
"name": "@chatwoot/chatwoot",
"version": "2.17.0",
"version": "2.17.1",
"license": "MIT",
"scripts": {
"eslint": "eslint app/**/*.{js,vue}",