Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove cypress log noise #1086

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/capture.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ describe('Event capture', () => {

// the code below is going to trigger an event capture
// we want to assert on the request
cy.intercept('POST', '**/e/*', async (request) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I could tell from testing

**/blah matches something/blah but not /blah so wasn't matching all requests the tests were making

cy.intercept('POST', '/e/*', async (request) => {
expect(request.headers['content-type']).to.eq('text/plain')
const captures = await getGzipEncodedPayload(request)
expect(captures.map(({ event }) => event)).to.deep.equal(['$autocapture', 'custom-event'])
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/opting-out.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { assertWhetherPostHogRequestsWereCalled } from '../support/assertions'
describe('opting out', () => {
describe('session recording', () => {
beforeEach(() => {
cy.intercept('POST', '**/decide/*', {
cy.intercept('POST', '/decide/*', {
config: { enable_collect_everything: false },
editorParams: {},
featureFlags: ['session-recording-player'],
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/session-recording.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { _isNull } from '../../src/utils/type-utils'
import { start } from '../support/setup'

function ensureRecordingIsStopped() {
cy.resetPhCaptures()

cy.get('[data-cy-input]')
.type('hello posthog!')
.wait(250)
Expand All @@ -16,6 +18,8 @@ function ensureRecordingIsStopped() {
}

function ensureActivitySendsSnapshots() {
cy.resetPhCaptures()

cy.get('[data-cy-input]')
.type('hello posthog!')
.wait('@session-recording')
Expand Down
34 changes: 25 additions & 9 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,41 @@ Cypress.on('window:before:load', (win) => {
})

beforeEach(() => {
cy.intercept('POST', '**/decide/*').as('decide')
cy.intercept('POST', '**/e/*').as('capture')
cy.intercept('POST', '**/ses/*').as('session-recording')
cy.intercept('GET', '**/surveys/*').as('surveys')
cy.intercept('POST', '/decide/*').as('decide')
cy.intercept('POST', '/e/*', { status: 1 }).as('capture')
cy.intercept('POST', '/ses/*', { status: 1 }).as('session-recording')
Comment on lines +13 to +14
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json response so that rate limiter doesn't log an error

cy.intercept('GET', '/surveys/*').as('surveys')

cy.readFile('dist/array.full.js').then((body) => {
cy.intercept('**/static/array.full.js', { body })
cy.intercept('/static/array.full.js', { body })
})

cy.readFile('dist/array.js').then((body) => {
cy.intercept('**/static/array.js', { body })
cy.intercept('/static/array.js', { body })
})

cy.readFile('dist/array.full.js.map').then((body) => {
cy.intercept('/static/array.full.js.map', { body })
})
Comment on lines +25 to +27
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map file intercepts so we're serving the correct file when the browser requests it and not complaining in the logs


cy.readFile('dist/array.js.map').then((body) => {
cy.intercept('/static/array.js.map', { body })
})

cy.readFile('dist/recorder.js').then((body) => {
cy.intercept('**/static/recorder.js*', { body }).as('recorder')
cy.intercept('**/static/recorder-v2.js*', { body }).as('recorder')
cy.intercept('/static/recorder.js*', { body }).as('recorder')
cy.intercept('/static/recorder-v2.js*', { body }).as('recorder')
})

cy.readFile('dist/recorder.js.map').then((body) => {
cy.intercept('/static/recorder.js.map', { body })
})

cy.readFile('dist/surveys.js').then((body) => {
cy.intercept('**/static/surveys.js*', { body })
cy.intercept('/static/surveys.js*', { body })
})

cy.readFile('dist/surveys.js.map').then((body) => {
cy.intercept('/static/surveys.js.map', { body })
})
})
2 changes: 1 addition & 1 deletion cypress/support/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const start = ({
...decideResponseOverrides,
config: { enable_collect_everything: true, ...decideResponseOverrides.config },
}
cy.intercept('POST', '**/decide/*', decideResponse).as('decide')
cy.intercept('POST', '/decide/*', decideResponse).as('decide')

cy.visit(url)

Expand Down
Loading