From 68c6d98435055c4ee18542bdce7183eb7a28e537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:06:38 +0000 Subject: [PATCH] Add comments --- backend/push.js | 9 ++++----- test/cypress/support/output-logs.js | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) 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 = []