refactor(graph): ♻️ Add Edges table in Typebot
This commit is contained in:
62
apps/builder/cypress/tests/logic/condition.ts
Normal file
62
apps/builder/cypress/tests/logic/condition.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import { preventUserFromRefreshing } from 'cypress/plugins/utils'
|
||||
import { getIframeBody } from 'cypress/support'
|
||||
|
||||
describe('Condition step', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('seed')
|
||||
cy.signOut()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cy.window().then((win) => {
|
||||
win.removeEventListener('beforeunload', preventUserFromRefreshing)
|
||||
})
|
||||
})
|
||||
|
||||
it('options should work', () => {
|
||||
cy.loadTypebotFixtureInDatabase('typebots/logic/condition.json')
|
||||
cy.signIn('test2@gmail.com')
|
||||
cy.visit('/typebots/typebot4/edit')
|
||||
|
||||
cy.findAllByText('Equal to').first().click()
|
||||
|
||||
cy.findByTestId('variables-input').click()
|
||||
cy.findByRole('menuitem', { name: 'Age' }).click()
|
||||
cy.findByRole('button', { name: 'Equal to' }).click()
|
||||
cy.findByRole('menuitem', { name: 'Greater than' }).click()
|
||||
cy.findByPlaceholderText('Type a value...').type('80')
|
||||
|
||||
cy.findByRole('button', { name: 'Add a comparison' }).click()
|
||||
cy.findAllByTestId('variables-input').last().click()
|
||||
cy.findByRole('menuitem', { name: 'Age' }).click()
|
||||
cy.findByRole('button', { name: 'Equal to' }).click()
|
||||
cy.findByRole('menuitem', { name: 'Less than' }).click()
|
||||
cy.findAllByPlaceholderText('Type a value...').last().type('100')
|
||||
|
||||
cy.findAllByText('Equal to').last().click()
|
||||
|
||||
cy.findByTestId('variables-input').click()
|
||||
cy.findByRole('menuitem', { name: 'Age' }).click()
|
||||
cy.findByRole('button', { name: 'Equal to' }).click()
|
||||
cy.findByRole('menuitem', { name: 'Greater than' }).click()
|
||||
cy.findByPlaceholderText('Type a value...').type('20')
|
||||
|
||||
cy.findByRole('button', { name: 'Preview' }).click()
|
||||
getIframeBody()
|
||||
.findByPlaceholderText('Type your answer...')
|
||||
.type('15{enter}')
|
||||
getIframeBody().findByText('You are younger than 20').should('exist')
|
||||
|
||||
cy.findByRole('button', { name: 'Restart' }).click()
|
||||
getIframeBody()
|
||||
.findByPlaceholderText('Type your answer...')
|
||||
.type('45{enter}')
|
||||
getIframeBody().findByText('You are older than 20').should('exist')
|
||||
|
||||
cy.findByRole('button', { name: 'Restart' }).click()
|
||||
getIframeBody()
|
||||
.findByPlaceholderText('Type your answer...')
|
||||
.type('90{enter}')
|
||||
getIframeBody().findByText('You are older than 80').should('exist')
|
||||
})
|
||||
})
|
40
apps/builder/cypress/tests/logic/setVariable.ts
Normal file
40
apps/builder/cypress/tests/logic/setVariable.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { preventUserFromRefreshing } from 'cypress/plugins/utils'
|
||||
import { getIframeBody } from 'cypress/support'
|
||||
|
||||
describe('Set variables', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('seed')
|
||||
cy.signOut()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cy.window().then((win) => {
|
||||
win.removeEventListener('beforeunload', preventUserFromRefreshing)
|
||||
})
|
||||
})
|
||||
|
||||
it('options should work', () => {
|
||||
cy.loadTypebotFixtureInDatabase('typebots/logic/setVariable.json')
|
||||
cy.signIn('test2@gmail.com')
|
||||
cy.visit('/typebots/typebot4/edit')
|
||||
cy.findByText('Type your answer...').click()
|
||||
cy.createVariable('Num')
|
||||
cy.findAllByText('Click to edit...').first().click()
|
||||
cy.createVariable('Total')
|
||||
cy.findByRole('textbox', { name: 'Value / Expression:' }).type(
|
||||
'1000 * {{Num}}',
|
||||
{ parseSpecialCharSequences: false }
|
||||
)
|
||||
cy.findAllByText('Click to edit...').last().click()
|
||||
cy.createVariable('Custom var')
|
||||
cy.findByRole('textbox', { name: 'Value / Expression:' }).type(
|
||||
'Custom value'
|
||||
)
|
||||
cy.findByRole('button', { name: 'Preview' }).click()
|
||||
getIframeBody()
|
||||
.findByPlaceholderText('Type your answer...')
|
||||
.type('365{enter}')
|
||||
getIframeBody().findByText('Total: 365000').should('exist')
|
||||
getIframeBody().findByText('Custom var: Custom value')
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user