From 1cf2b5d057e23ebb54beb4cee54ea2bfe47de400 Mon Sep 17 00:00:00 2001 From: Tyler Myracle Date: Mon, 22 Jan 2024 09:31:03 -0600 Subject: [PATCH] clean up --- apps/e2e/src/e2e/subscription.cy.ts | 4 +-- apps/e2e/src/support/e2e.ts | 43 ++++++++++++++++------------- 2 files changed, 26 insertions(+), 21 deletions(-) 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) - }) -}) +}