Skip to content

Commit

Permalink
chore: run test with production env (#782)
Browse files Browse the repository at this point in the history
* chore: run e2e test with production environment

* chore: update github action

* chore: update default test env file
  • Loading branch information
embbnux authored Mar 20, 2024
1 parent a07872b commit c841b81
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.test.default
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ TEST_HOST_URI=http://localhost:8080
TEST_JWT_TOKEN=
TEST_HEADLESS=false
TEST_THIRD_PARTY_URI=
TEST_SMS_RECEIVER_NUMBER=
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
_HOST_URI__: true,
__JWT_TOKEN__: true,
__THIRD_PARTY_URI__: true,
__TEST_SMS_RECEIVER_NUMBER__: true,
},
overrides: [
// js ts files
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
TEST_HOST_URI: http://localhost:8080
TEST_JWT_TOKEN: ${{ secrets.TEST_JWT_TOKEN }}
TEST_THIRD_PARTY_URI: https://ringcentral-tutorials.github.io/ringcentral-embeddable-demos/
TEST_SMS_RECEIVER_NUMBER: ${{ secrets.TEST_SMS_RECEIVER_NUMBER }}
API_KEY: ${{ secrets.TEST_API_KEY }}
API_SECRET: ${{ secrets.TEST_API_SECRET }}
API_SERVER: ${{ secrets.API_SERVER }}
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
__HOST_URI__: process.env.TEST_HOST_URI,
__JWT_TOKEN__: process.env.TEST_JWT_TOKEN,
__THIRD_PARTY_URI__: process.env.TEST_THIRD_PARTY_URI,
__TEST_SMS_RECEIVER_NUMBER__: process.env.TEST_SMS_RECEIVER_NUMBER,
},
testMatch: [
'**/test/**/*.test.js'
Expand Down
1 change: 1 addition & 0 deletions test/steps/IframeWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class IframeWidget {

async typeSMSRecipientAndText({ recipientNumber, text}) {
await this._widgetIframe.type('input[name="receiver"]', recipientNumber);
await this._widgetIframe.waitForTimeout(1000);
await this._widgetIframe.type('textarea[data-sign="messageInput"]', text);
}

Expand Down
8 changes: 4 additions & 4 deletions test/steps/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export async function getLoginedWidget(jwtToken) {
const widgetIframe = new IframeWidget();
await widgetIframe.loadElement();
await widgetIframe.waitForLoginPage();
const envButton = await page.$('#setEnvironment');
await envButton.evaluate(b => b.click());
await widgetIframe.enableSandboxEnvironment();
await widgetIframe.waitForLoginPage();
// const envButton = await page.$('#setEnvironment');
// await envButton.evaluate(b => b.click());
// await widgetIframe.enableSandboxEnvironment();
// await widgetIframe.waitForLoginPage();
await widgetIframe.loginWithCallbackUri(`${__HOST_URI__}/redirect.html?jwt=${jwtToken}`);
await page.waitForTimeout(1000);
return widgetIframe;
Expand Down
2 changes: 1 addition & 1 deletion test/widget.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ conditionalDescribe('widget page test', () => {
const recipientPlaceholder = await widgetIframe.getSMSRecipientInputPlaceholder();
expect(recipientPlaceholder).toEqual('Enter name or number');
const text = `text ${Date.now()}`;
await widgetIframe.typeSMSRecipientAndText({ recipientNumber: '101', text });
await widgetIframe.typeSMSRecipientAndText({ recipientNumber: __TEST_SMS_RECEIVER_NUMBER__, text });
await widgetIframe.clickSMSSendButton();
const lastTextInConversation = await widgetIframe.getLastTextAtConversation();
expect(lastTextInConversation).toEqual(text);
Expand Down

0 comments on commit c841b81

Please sign in to comment.