Closed codebynao closed 2 years ago
I spent quite some time debugging some tests that were failing because getAssistantSettings
was returning null
instead of the webchat settings for the mock data.
After some time I found out that it was because I was adding the env
query to the chatBubble urls in getAssistantSettingsUrl
In the test file, I had to update the URLs in testAPIUrls
and add the env in the validMockData
for the tests to work again.
I guess that xhr-mock compares the testAPIUrls to the one that is actually called but they were different because one had the env query and the other didn't. However, I have to admit that I don't know what I had to add the env to validMockData
for it to work since the production
env is used by default...
Points to recheck
The code : no more feedback :ok:
Tests : They pass :ok:
Local Tests : see bellow
Will next yelda deploy break existing old chatplugin ?
/assistants/{assistantId}/chatBubble/{locale?}
=> no change on returned format { data: {} }
=> :ok:
example ex https://krds.com/fr/fr/, https://app.yelda.ai/assistants/5c6e75276025a206d537e96f/chatBubble/fr_FR return the same format as https://staging.yelda.ai/assistants/5b7edb2b1060312cfeaa7932/chatBubble/fr_FR/assistants/{assistantId}/chatBubble/{locale?}
see abovePR questions to clarify
chatpluginVersion : an issue is opened for improvement
redis mismatch of env : an issue is opened an issue is opened too
_But should the env from the query overwrite the NODEENV in yelda? NO, we should not be able to fetch prod data in staging env
_we should compare the env from the query with the NODEENV, if they are not the same, we don't return anything? issue opened. Not urgent but good idea. https://github.com/Yeldaai/yelda/issues/5232
I guess that xhr-mock compares the testAPIUrls to the one that is actually called > yes
what I had to add the env to validMockData for it to work since the production env is used by default... > me neither, because it works without it for me :thinking:
Local test in index.html
staging with assistantId
yeldaChat.init({
'assistantSlug': 'fm_logistic',
'assistantId': '5b7edb2c1060312cfeaa7981',
'assistantUrl': 'https://app.yelda.ai',
'chatPath': '/chat',
'locale': 'fr_FR',
'isAdmin': true, // Used to see the NLP logs
'shouldBeOpened': true // open the chat window by default on loading the page if set to true
})
yeldaChat.init({
'env': 'staging',
'assistantSlug': 'fm_logistic',
'assistantId': '5b7edb2c1060312cfeaa7981',
'assistantUrl': 'https://app.yelda.ai',
'chatPath': '/chat',
'locale': 'fr_FR',
'isAdmin': true, // Used to see the NLP logs
'shouldBeOpened': true // open the chat window by default on loading the page if set to true
})
with staging env defined => https://webchat.yelda.ai/webchat/5b7edb2c1060312cfeaa7981/chatBubble/fr_FR?env=staging return the correct data directly
prod with setting id (krds)
yeldaChat.init({
'settingId': '5e7ccb230729870f7921375c',
'isAdmin': true, // Used to see the NLP logs
'shouldBeOpened': true // open the chat window by default on loading the page if set to true
})
no response https://webchat.yelda.ai/webchat/settings/5e7ccb230729870f7921375c/chatBubble?env=production because it has been never used
fallback on good old https://app.yelda.ai/assistants/settings/5e7ccb230729870f7921375c/chatBubble?env=production which works
SO I think we're good, what do you think ?
…int in priority
In
onreadystatechange
, I noticed that we were returningJSON.parse(xhr.responseText).data
but while testing on the demo page, I never got the.data
. I didn't remove it yet because I'm not sure 100% it wouldn't affect prod chats. As I explained in a comment, from my tests, the setting is received directly as{ ...webchatSettings }
from both the external endpoint and the yelda endpoint. But as I didn't work on this part before, I thought that I might miss a case where we get the.data
otherwise we would have some broken cases in prod, no?