diff --git a/backend/push.js b/backend/push.js index e69916bcd..3fa5edfc4 100644 --- a/backend/push.js +++ b/backend/push.js @@ -248,16 +248,15 @@ const encryptPayload = async (subcription: Object, data: string) => { }) } -export const postEvent = async (subscription: Object, event: string): Promise => { +export const postEvent = async (subscription: Object, event: ?string): Promise => { const authorization = await vapidAuthorization(subscription.endpoint) + // Note: web push notifications can be 'bodyless' or they can contain a body + // If there's no body, there isn't anything to encrypt, so we skip both the + // encryption and the encryption headers. const body = event ? await encryptPayload(subscription, event) : undefined - /* if (body) { - body[body.length - 2] = 0 - } */ - const req = await fetch(subscription.endpoint, { method: 'POST', headers: [ diff --git a/test/cypress/support/output-logs.js b/test/cypress/support/output-logs.js index 2c87c73f9..aa5f6ff64 100644 --- a/test/cypress/support/output-logs.js +++ b/test/cypress/support/output-logs.js @@ -68,6 +68,11 @@ Cypress.mocha.getRunner().on('test', () => { // current fail, to the end of the error.stack property. Cypress.on('fail', (error) => { error.stack += '\nConsole Logs:\n========================\n' + // There isn't a 'good' way to capture browser logs from Cypress, so we + // capture them with the handler above. The logs can get pretty big, and this + // interferes with being able to upload test results to Cypress Cloud. Hence, + // the `.slice(-500)` part below to only keep the last 500 lines. + // TODO: Restore the slice part error.stack += '[' + logs./* slice(-500) */join('\n') + ']' // clear logs after fail so we dont see duplicate logs logs = []