Open ear-dev opened 3 years ago
Start with a standalone script that runs non-escalated integration tests with cypress?
I have a selenium script and a spreadsheet which describes our current integration test suite, which I will post later today.
There are salesforce verifications in the escalated integration tests, but we need to determine what is rocketchats responsibility and only test for that. i.e. Do we need SF api's to verify cases created, updated, etc.....
The Goal: test everything Rocketchat related only..... Non-Escalated, Escalated, session closing, etc...
@bhardwajaditya this spreadsheet describes both non-escalated and escalated test cases. At the moment lets focus on the non-escalated cases please. I still need to look over and groom the escalated cases.....
These test cases are all just manipulating the widget and verifying the outcomes against our preprod Dialogflow.agent/fulfillment server. Will you be able to run your cypress scripts against our preprod my.viasat instance while developing?
I am also attaching the selenium script that I have been using to run these tests..... for reference. There are login creds embedded in it for the preprod myViasat instance.
Use Cases: Start with 'Full integration test case'
Current Issue: Cypress does not handle the Oauth.. cross origin cookies...... @bhardwajaditya is still investigating.
@ear-dev Since Cypress does not handle OAuth and does not allow setting cross origin cookies, we need to get the cookie from OAuth server and set it before visiting the target URL.
I need some documentation on how to use Viasat OAuth to get the valid cookie to be used on the pre prod chatbot server. The relevant API link should also work with input parameters required.
Eric will create a new WideChat repo for these tests.... @bhardwajaditya please commit your code when the repo is ready.
@bhardwajaditya please push you tests to this repo: https://github.com/WideChat/Rocket.Chat.IntegrationTests thanks.
@bhardwajaditya if I wanted to point the cypress tests at https://messaging.vega-preprod.viasat.io/livechat
where would I configure that?
@ear-dev there's a test.html file in the root of the project, you can modify that and use it. Or in every test there's a before hook where cy.visit is called, you can change the page URL there currently it opens the test.html
We need some examples of conditional assertions.
cy.get('iframe#rocketchat-iframe').then(($iframe) => {
const $body = $iframe.contents().find('body');
cy.wrap($body).find('button.screen__chat-button__2h7Ad').click();
while not cy.get(..'weclome intent message'.):
cy.wrap($body).find('.footer__1V22a button.button__3e1dX');
//TODO: monitor for welcome intent message, and then verify that the composer is enabled, but not before
});
})
also show us how to use a predetermined cookie so that we can test against myViasat
Eric - needs to talk with SSO team about how to find the right cookie. Also need to figure out how we can use an api for authentication.
@bhardwajaditya when you figure out how to implement my suedo code above, please post a code snippet in this story as well as pushing an example to the repo.
@bhardwajaditya looks like this might work for you to get a valid myViasat token?
$ curl \
--request POST \
--header "Content-Type: application/json" \
--header "X-OpenAM-Username: <username>" \
--header "X-OpenAM-Password: <pwd>" \
--header "Accept-API-Version: resource=2.0, protocol=1.0" \
'https://sso.viasat.com:443/federation/json/realms/root/authenticate'
{
"tokenId":"AQIC5wM...TU3OQ*",
"successUrl":"/openam/console",
"realm":"/"
}
Probably use the test sso: https://mysso.my.test.viasat.com/
@ear-dev the pseudo code is pushed to repo. Implementation is
cy.verifyIfComposerIsDisable = (count) => {
cy.get('iframe#rocketchat-iframe').then(($iframe) => {
const $body = $iframe.contents().find('body');
if (count < 10 && $body.find('.message-list__1jRl9 li.message-container__19jeU').length < 6) {
cy.wrap($body).find('.footer__1V22a button.button__3e1dX').should('be.visible');
cy.wait(1000);
cy.verifyIfComposerIsDisable(++count);
}
});
}
@bhardwajaditya looks like this might work for you to get a valid myViasat token?
$ curl \ --request POST \ --header "Content-Type: application/json" \ --header "X-OpenAM-Username: <username>" \ --header "X-OpenAM-Password: <pwd>" \ --header "Accept-API-Version: resource=2.0, protocol=1.0" \ 'https://sso.viasat.com:443/federation/json/realms/root/authenticate' { "tokenId":"AQIC5wM...TU3OQ*", "successUrl":"/openam/console", "realm":"/" }
Probably use the test sso:
https://mysso.my.test.viasat.com/
@ear-dev this should do the trick, I will try and let you know
@ear-dev this post request returns 401 response using the test credentials.
The test credentials are not working when I enter them manually in the website.
@bhardwajaditya yeah, seems like the test my viasat instance might be broken right now, I can't reach it either. I'll check with the team.
I will also confirm if our test credentials are still good. i.e. we seem to be getting a bad cookie back from sso, with a 401.
@bhardwajaditya two things please:
@bhardwajaditya putting this under review because I have a PR which handles the config file (cypress.json) to pass all the text variables and manage them in one place.
UsRes needs salesforce apis?