Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Nov 28, 2024
1 parent 3e67bee commit 68c6d98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 4 additions & 5 deletions backend/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,15 @@ const encryptPayload = async (subcription: Object, data: string) => {
})
}

export const postEvent = async (subscription: Object, event: string): Promise<void> => {
export const postEvent = async (subscription: Object, event: ?string): Promise<void> => {
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: [
Expand Down
5 changes: 5 additions & 0 deletions test/cypress/support/output-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 68c6d98

Please sign in to comment.