-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add locale support in DirectLine options #293
Add locale support in DirectLine options #293
Conversation
@timenick I’ll look into this tomorrow, but we likely need changes in the Emulator as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests: 1 happy path, 1+ unhappy paths.
After talking to @timenick, because the service change is not on production yet, thus, he cannot add any tests yet. He will test it manually, then add tests in another PR. |
const body = this.conversationId | ||
? undefined | ||
: { | ||
locale: this.localeOnStartConversation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if conversationStartProperties is not sent in or does not contain a locale, should we still send a body? I would assume not since we dont want to change any existing client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our backend, we are reading from body to get the conversationStartParameters. Because we are not only sending locale in body, we would send more parameters (like userid, username, etc) in the future. The locale parameter is optional, it would not affect any existing client.
timeout: this.timeout, | ||
headers: { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test to make sure adding a Content-Type doesnt affect existing clients that dont send a body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add tests
- DirectLineJS does not receive conversation start parameters (tests that existing clients are not affected)
- DirectLineJS does not receive a locale in the conversation start parameters
- DirectLineJS receives a valid locale in the conversation start parameters
- DirectLineJS receives a invalid locale in the conversation start parameters
Sure. I will update the test bot first. And will sync with William for the tests. |
src/directLine.ts
Outdated
@@ -479,6 +482,12 @@ export class DirectLine implements IBotConnection { | |||
this.token = options.secret || options.token; | |||
this.webSocket = (options.webSocket === undefined ? true : options.webSocket) && typeof WebSocket !== 'undefined' && WebSocket !== undefined; | |||
|
|||
if (options.conversationStartProperties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (options.conversationStartProperties) { | |
if (options.conversationStartProperties && options.conversationStartProperties.locale) { |
Combine two if
s into one.
fixes #292