Skip to content

Add Foreground Message Send/Receive Integration Tests #3216

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

Merged
merged 43 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dde3bfd
Enable the FCM integration test (IT) for Chrome.
Apr 14, 2020
099c76a
[AUTOMATED]: License Headers
Apr 14, 2020
14d38bc
Enable integration test (IT) for FCM.
zwu52 May 13, 2020
910e6a1
Correct int syntax
zwu52 May 13, 2020
b46f232
This file wasn't auto-saved
zwu52 May 13, 2020
1e68ca5
Trigger FCM IT
zwu52 May 15, 2020
b8ed1ba
Test Secrets can be accessed w/o dotenv
zwu52 May 15, 2020
37fb7c9
Add fcm sercret to workflow
zwu52 May 18, 2020
8d3e700
Update test-changed.yml
zwu52 May 18, 2020
cac7b80
test send (background only)
zwu52 May 18, 2020
5909104
remove dotenv
zwu52 May 18, 2020
2df79b5
feed secrest into test:all workflow
zwu52 May 19, 2020
fccb108
Update test-all.yml
zwu52 May 19, 2020
3ea2c73
background messaging checking
zwu52 May 21, 2020
81a84f0
[AUTOMATED]: License Headers
zwu52 May 21, 2020
9038d1a
rerun
zwu52 May 21, 2020
a1345e7
added waiting
zwu52 May 26, 2020
1bcab1c
wait
zwu52 May 26, 2020
75b5ba6
Update test-send.js
zwu52 May 26, 2020
36d2272
Update test-send.js
zwu52 May 26, 2020
8e7c27d
Examine wrong sercret
zwu52 May 27, 2020
976d3cd
Update sendMessage.js
zwu52 May 30, 2020
343af85
Update sendMessage.js
zwu52 Jun 1, 2020
0750f00
Update sendMessage.js
zwu52 Jun 1, 2020
068b173
Update sendMessage.js
zwu52 Jun 1, 2020
e3fcea3
Update sendMessage.js
zwu52 Jun 1, 2020
fdb4ca2
Merge branch 'master' into test
zwu52 Jun 2, 2020
b60d010
update fcm project
zwu52 Jun 2, 2020
3acc255
Update package.json
zwu52 Jun 2, 2020
4f12ef8
Update test-send.js
zwu52 Jun 3, 2020
1d2368c
open new tab for backgournd receive
zwu52 Jun 8, 2020
6ab745f
removed test-send
zwu52 Jun 9, 2020
4c5e360
Adding Reties
zwu52 Jun 10, 2020
2f9b9bc
Change timeout limit
zwu52 Jun 10, 2020
4775b91
retry 3 times
zwu52 Jun 10, 2020
1e54408
adjust mocha setting
zwu52 Jun 11, 2020
5753fa5
update
zwu52 Jun 11, 2020
dc4cca8
Enable foreground tesing
zwu52 Jun 15, 2020
fc3a3fb
Merge branch 'master' into test
zwu52 Jun 15, 2020
150c1de
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 Jun 26, 2020
bce88f1
Add emtpy changeset
zwu52 Jun 26, 2020
8598b8a
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 Jun 26, 2020
fd7d493
Merge branch 'master' of https://github.com/firebase/firebase-js-sdk …
zwu52 Jul 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/tender-hounds-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
112 changes: 112 additions & 0 deletions integration/messaging/test/test-send.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const sendMessage = require('./utils/sendMessage');
const retrieveToken = require('./utils/retrieveToken');
const seleniumAssistant = require('selenium-assistant');
const getReceivedBackgroundMessages = require('./utils/getReceivedBackgroundMessages');
const getReceivedForegroundMessages = require('./utils/getReceivedForegroundMessages');
const openNewTab = require('./utils/openNewTab');
const createPermittedWebDriver = require('./utils/createPermittedWebDriver');

Expand All @@ -35,6 +36,8 @@ const FIELD_NOTIFICATION = 'notification';
// 4 minutes. The fact that the flow includes making a request to the Send Service, storing/retrieving form indexedDb asynchronously makes these test units to have a execution time variance. Therefore, allowing these units to have a longer time to work is crucial.
const TIMEOUT_BACKGROUND_MESSAGE_TEST_UNIT_MILLISECONDS = 240000;

const TIMEOUT_FOREGROUND_MESSAGE_TEST_UNIT_MILLISECONDS = 120000;

// 1 minute. Wait for object store to be created and received message to be stored in idb. This waiting time MUST be longer than the wait time for adding to db in the sw.
const WAIT_TIME_BEFORE_RETRIEVING_BACKGROUND_MESSAGES_MILLISECONDS = 60000;

Expand Down Expand Up @@ -122,6 +125,115 @@ describe('Starting Integration Test > Sending and Receiving ', function() {
/* expectedDataPayload= */ getTestDataPayload()
);
});

it('Foreground app can receive a {} empty message in onMessage', async function() {
this.timeout(TIMEOUT_FOREGROUND_MESSAGE_TEST_UNIT_MILLISECONDS);

await seleniumAssistant.killWebDriver(globalWebDriver);

globalWebDriver = createPermittedWebDriver(
/* browser= */ assistantBrowser.getId()
);

await globalWebDriver.get(
`${testServer.serverAddress}/${TEST_DOMAIN}/`
);

let token = await retrieveToken(globalWebDriver);
checkSendResponse(
await sendMessage({
to: token
})
);

await checkMessageReceived(
await getReceivedForegroundMessages(globalWebDriver),
/* expectedNotificationPayload= */ null,
/* expectedDataPayload= */ null
);
});

it('Foreground app can receive a {"notification"} message in onMessage', async function() {
this.timeout(TIMEOUT_FOREGROUND_MESSAGE_TEST_UNIT_MILLISECONDS);

await seleniumAssistant.killWebDriver(globalWebDriver);

globalWebDriver = createPermittedWebDriver(
/* browser= */ assistantBrowser.getId()
);

await globalWebDriver.get(
`${testServer.serverAddress}/${TEST_DOMAIN}/`
);

checkSendResponse(
await sendMessage({
to: await retrieveToken(globalWebDriver),
notification: getTestNotificationPayload()
})
);

await checkMessageReceived(
await getReceivedForegroundMessages(globalWebDriver),
/* expectedNotificationPayload= */ getTestNotificationPayload(),
/* expectedDataPayload= */ null
);
});

it('Foreground app can receive a {"data"} message in onMessage', async function() {
this.timeout(TIMEOUT_FOREGROUND_MESSAGE_TEST_UNIT_MILLISECONDS);

await seleniumAssistant.killWebDriver(globalWebDriver);

globalWebDriver = createPermittedWebDriver(
/* browser= */ assistantBrowser.getId()
);

await globalWebDriver.get(
`${testServer.serverAddress}/${TEST_DOMAIN}/`
);

checkSendResponse(
await sendMessage({
to: await retrieveToken(globalWebDriver),
data: getTestDataPayload()
})
);

await checkMessageReceived(
await getReceivedForegroundMessages(globalWebDriver),
/* expectedNotificationPayload= */ null,
/* expectedDataPayload= */ getTestDataPayload()
);
});

it('Foreground app can receive a {"notification", "data"} message in onMessage', async function() {
this.timeout(TIMEOUT_FOREGROUND_MESSAGE_TEST_UNIT_MILLISECONDS);

await seleniumAssistant.killWebDriver(globalWebDriver);

globalWebDriver = createPermittedWebDriver(
/* browser= */ assistantBrowser.getId()
);

await globalWebDriver.get(
`${testServer.serverAddress}/${TEST_DOMAIN}/`
);

checkSendResponse(
await sendMessage({
to: await retrieveToken(globalWebDriver),
data: getTestDataPayload(),
notification: getTestNotificationPayload()
})
);

await checkMessageReceived(
await getReceivedForegroundMessages(globalWebDriver),
/* expectedNotificationPayload= */ getTestNotificationPayload(),
/* expectedDataPayload= */ getTestDataPayload()
);
});
});
});
});
Expand Down