diff --git a/apps/e2e/src/e2e/subscription.cy.ts b/apps/e2e/src/e2e/subscription.cy.ts index 26bb45a3..59d8d978 100644 --- a/apps/e2e/src/e2e/subscription.cy.ts +++ b/apps/e2e/src/e2e/subscription.cy.ts @@ -19,9 +19,9 @@ function sendWebhook(payload: Record) { }) return cy - .request({ + .apiRequest({ method: 'POST', - url: `${Cypress.env('API_URL')}/stripe/webhook`, + url: '/stripe/webhook', headers: { ['stripe-signature']: signature, }, diff --git a/apps/e2e/src/support/e2e.ts b/apps/e2e/src/support/e2e.ts index 7794688c..511e46c2 100644 --- a/apps/e2e/src/support/e2e.ts +++ b/apps/e2e/src/support/e2e.ts @@ -1,6 +1,29 @@ import './commands' beforeEach(() => { + authenticateCIUser() + cy.apiRequest({ + method: 'POST', + url: 'e2e/reset', + body: {}, + }).then((response) => { + expect(response.status).to.equal(200) + }) + cy.visit('/') +}) + +after(() => { + authenticateCIUser() + cy.apiRequest({ + method: 'POST', + url: 'e2e/clean', + body: {}, + }).then((response) => { + expect(response.status).to.equal(200) + }) +}) + +function authenticateCIUser() { cy.request({ method: 'GET', url: 'api/auth/csrf', @@ -31,22 +54,4 @@ beforeEach(() => { expect(response.status).to.equal(200) }) }) - cy.apiRequest({ - method: 'POST', - url: 'e2e/reset', - body: {}, - }).then((response) => { - expect(response.status).to.equal(200) - }) - cy.visit('/') -}) - -after(() => { - cy.apiRequest({ - method: 'POST', - url: 'e2e/clean', - body: {}, - }).then((response) => { - expect(response.status).to.equal(200) - }) -}) +}