diff --git a/CHANGELOG.md b/CHANGELOG.md index faf5b3952e..3629a9f230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix [Emulator:#1823](https://github.com/microsoft/BotFramework-Emulator/issues/1823). Fix Sendbox "Type your message" being read twice by AT, by [@corinagum](https://github.com/corinagum) in PR [#2423](https://github.com/microsoft/BotFramework-WebChat/pull/2423) - Fix [#2415](https://github.com/microsoft/BotFramework-WebChat/issues/2415) and [#2416](https://github.com/microsoft/BotFramework-WebChat/issues/2416). Fix receipt card rendering, by [@compulim](https://github.com/compulim) in PR [#2417](https://github.com/microsoft/BotFramework-WebChat/issues/2417) - Fix [#2415](https://github.com/microsoft/BotFramework-WebChat/issues/2415) and [#2416](https://github.com/microsoft/BotFramework-WebChat/issues/2416). Fix Adaptive Cards cannot be disabled on-the-fly, by [@compulim](https://github.com/compulim) in PR [#2417](https://github.com/microsoft/BotFramework-WebChat/issues/2417) +- Fix [#2360](https://github.com/microsoft/BotFramework-WebChat/issues/2360). Timestamp should update on language change, by [@compulim](https://github.com/compulim) in PR [#2414](https://github.com/microsoft/BotFramework-WebChat/pull/2414) ### Added diff --git a/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-1-snap.png b/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-1-snap.png new file mode 100644 index 0000000000..1dec1733fb Binary files /dev/null and b/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-1-snap.png differ diff --git a/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-2-snap.png b/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-2-snap.png new file mode 100644 index 0000000000..dc7ca9bc3e Binary files /dev/null and b/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-2-snap.png differ diff --git a/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-3-snap.png b/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-3-snap.png new file mode 100644 index 0000000000..0b4889bd90 Binary files /dev/null and b/__tests__/__image_snapshots__/chrome-docker/timestamp-js-update-timestamp-on-the-fly-3-snap.png differ diff --git a/__tests__/setup/web/index.html b/__tests__/setup/web/index.html index f8b469d126..fa1d01c04d 100644 --- a/__tests__/setup/web/index.html +++ b/__tests__/setup/web/index.html @@ -145,12 +145,7 @@ ...props }; - renderWebChat = props => { - console.log(props); - - window.WebChat.renderWebChat(props, document.getElementById('webchat')); - }; - + renderWebChat = props => window.WebChat.renderWebChat(props, document.getElementById('webchat')); renderWebChat(props); document.querySelector('#webchat > *').focus(); diff --git a/__tests__/timestamp.js b/__tests__/timestamp.js new file mode 100644 index 0000000000..984864981f --- /dev/null +++ b/__tests__/timestamp.js @@ -0,0 +1,28 @@ +import { imageSnapshotOptions, timeouts } from './constants.json'; + +import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown'; +import uiConnected from './setup/conditions/uiConnected'; + +// selenium-webdriver API doc: +// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html + +jest.setTimeout(timeouts.test); + +test('update timestamp on-the-fly', async () => { + const { driver, pageObjects } = await setupWebDriver(); + + await driver.wait(uiConnected(), timeouts.directLine); + await pageObjects.sendMessageViaSendBox('echo Hello, World!', { waitForSend: true }); + + await driver.wait(minNumActivitiesShown(2), timeouts.directLine); + + expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); + + await pageObjects.updateProps({ locale: 'zh-HK' }); + + expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); + + await pageObjects.updateProps({ locale: 'zh-YUE' }); + + expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); +}); diff --git a/packages/component/src/Utils/RelativeTime.js b/packages/component/src/Utils/RelativeTime.js index f7fa6d6488..5ad0fbdba8 100644 --- a/packages/component/src/Utils/RelativeTime.js +++ b/packages/component/src/Utils/RelativeTime.js @@ -25,16 +25,14 @@ function getText(language, value) { } const RelativeTime = ({ language, value }) => { - const [text, setText] = useState(getText(language, value)); const [timer, setTimer] = useState(nextTimer(value)); - - const localizedAbsoluteTime = localize('SentAt', language) + getLocaleString(value, language); - const handleInterval = useCallback(() => { - setText(getText(language, value)); setTimer(nextTimer(value)); }, [language, value]); + const localizedAbsoluteTime = localize('SentAt', language) + getLocaleString(value, language); + const text = getText(language, value); + return ( diff --git a/packages/playground/src/App.js b/packages/playground/src/App.js index 2c841a6150..969729fa9e 100644 --- a/packages/playground/src/App.js +++ b/packages/playground/src/App.js @@ -243,7 +243,7 @@ const App = ({ store }) => { const handleLanguageChange = useCallback( ({ target: { value } }) => { - setLanguage(!!value); + setLanguage(value); document.querySelector('html').setAttribute('lang', value || window.navigator.language); window.sessionStorage.setItem('PLAYGROUND_LANGUAGE', value); },