-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 3279: Relative timestamp showing date before yesterday should not…
… error out (#3282) * Fix relative timestamp on date before yesterday * Add test * Update entry
- Loading branch information
Showing
5 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script type="text/babel" data-presets="env,stage-3,react"> | ||
const { conditions, createStore, expect, host, pageObjects, timeouts, token, updateIn } = window.WebChatTest; | ||
|
||
function mapObservable(observable, { next }) { | ||
return new Observable(observer => { | ||
const subscription = observable.subscribe({ | ||
complete: observer.complete.bind(observer), | ||
error: observer.error.bind(observable), | ||
next: value => observer.next(next(value)) | ||
}); | ||
|
||
return subscription.unsubscribe.bind(subscription); | ||
}); | ||
} | ||
|
||
(async function() { | ||
function createDirectLineForTest(options) { | ||
const workingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
...workingDirectLine, | ||
activity$: mapObservable(workingDirectLine.activity$, { | ||
next: value => ({ | ||
...value, | ||
|
||
// Substract 3 days from the timestamp | ||
timestamp: new Date(new Date(value.timestamp).getTime() - 86400000 * 3).toISOString() | ||
}) | ||
}), | ||
postActivity: workingDirectLine.postActivity.bind(workingDirectLine) | ||
}; | ||
} | ||
|
||
window.WebChat.renderWebChat( | ||
{ | ||
directLine: createDirectLineForTest({ token: await token.fetchDirectLineToken() }), | ||
store: createStore(), | ||
styleOptions: { | ||
sendTimeout: 5000 | ||
} | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('echo Hello, World!', { waitForSend: false }); | ||
|
||
await host.done(); | ||
})().catch(async err => { | ||
console.error(err); | ||
|
||
await host.error(err); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js | ||
*/ | ||
|
||
describe('timestamp', () => { | ||
test('showing date before yesterday', () => runHTMLTest('timestamp.beforeYesterday.html')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters