feat(integration): ✨ Add Google Analytics integration
This commit is contained in:
@ -1,10 +1,7 @@
|
||||
import { userIds } from 'cypress/plugins/data'
|
||||
import {
|
||||
parseTestTypebot,
|
||||
preventUserFromRefreshing,
|
||||
} from 'cypress/plugins/utils'
|
||||
import { createTypebotWithStep } from 'cypress/plugins/data'
|
||||
import { preventUserFromRefreshing } from 'cypress/plugins/utils'
|
||||
import { getIframeBody } from 'cypress/support'
|
||||
import { InputStep, InputStepType } from 'models'
|
||||
import { InputStepType } from 'models'
|
||||
|
||||
describe('Text input', () => {
|
||||
beforeEach(() => {
|
||||
@ -262,50 +259,3 @@ describe('Button input', () => {
|
||||
getIframeBody().findByText('Cool!').should('exist')
|
||||
})
|
||||
})
|
||||
|
||||
const createTypebotWithStep = (step: Omit<InputStep, 'id' | 'blockId'>) => {
|
||||
cy.task(
|
||||
'createTypebot',
|
||||
parseTestTypebot({
|
||||
id: 'typebot3',
|
||||
name: 'Typebot #3',
|
||||
ownerId: userIds[1],
|
||||
steps: {
|
||||
byId: {
|
||||
step1: {
|
||||
...step,
|
||||
id: 'step1',
|
||||
blockId: 'block1',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
options:
|
||||
step.type === InputStepType.CHOICE
|
||||
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
{ itemIds: ['item1'] }
|
||||
: undefined,
|
||||
},
|
||||
},
|
||||
allIds: ['step1'],
|
||||
},
|
||||
blocks: {
|
||||
byId: {
|
||||
block1: {
|
||||
id: 'block1',
|
||||
graphCoordinates: { x: 400, y: 200 },
|
||||
title: 'Block #1',
|
||||
stepIds: ['step1'],
|
||||
},
|
||||
},
|
||||
allIds: ['block1'],
|
||||
},
|
||||
choiceItems:
|
||||
step.type === InputStepType.CHOICE
|
||||
? {
|
||||
byId: { item1: { stepId: 'step1', id: 'item1' } },
|
||||
allIds: ['item1'],
|
||||
}
|
||||
: undefined,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
36
apps/builder/cypress/tests/integrations/googleAnalytics.ts
Normal file
36
apps/builder/cypress/tests/integrations/googleAnalytics.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { createTypebotWithStep } from 'cypress/plugins/data'
|
||||
import { preventUserFromRefreshing } from 'cypress/plugins/utils'
|
||||
import { IntegrationStepType } from 'models'
|
||||
|
||||
describe('Google Analytics', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('seed')
|
||||
createTypebotWithStep({ type: IntegrationStepType.GOOGLE_ANALYTICS })
|
||||
cy.signOut()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cy.window().then((win) => {
|
||||
win.removeEventListener('beforeunload', preventUserFromRefreshing)
|
||||
})
|
||||
})
|
||||
|
||||
it.only('can be filled correctly', () => {
|
||||
cy.signIn('test2@gmail.com')
|
||||
cy.visit('/typebots/typebot3/edit')
|
||||
cy.intercept({
|
||||
url: '/g/collect',
|
||||
method: 'POST',
|
||||
}).as('gaRequest')
|
||||
cy.findByTestId('step-step1').click()
|
||||
cy.findByRole('textbox', { name: 'Tracking ID:' }).type('G-VWX9WG1TNS')
|
||||
cy.findByRole('textbox', { name: 'Event category:' }).type('Typebot')
|
||||
cy.findByRole('textbox', { name: 'Event action:' }).type('Submit email')
|
||||
cy.findByRole('button', { name: 'Advanced' }).click()
|
||||
cy.findByRole('textbox', { name: 'Event label Optional :' }).type(
|
||||
'Campaign Z'
|
||||
)
|
||||
cy.findByRole('textbox', { name: 'Event value Optional :' }).type('20')
|
||||
// Not sure how to test if GA integration works correctly in the preview tab
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user