feat(inputs): ✨ Add Condition step
This commit is contained in:
@ -276,11 +276,11 @@ const createTypebotWithStep = (step: Omit<InputStep, 'id' | 'blockId'>) => {
|
||||
...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'] }
|
||||
? { itemIds: ['item1'] }
|
||||
: undefined,
|
||||
},
|
||||
},
|
||||
|
@ -39,6 +39,60 @@ describe('Set variables', () => {
|
||||
})
|
||||
})
|
||||
|
||||
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.findByTestId('step-condition1').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' }).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.findByTestId('step-condition2').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 age...').type('15{enter}')
|
||||
getIframeBody().findByText('You are younger than 20').should('exist')
|
||||
|
||||
cy.findByRole('button', { name: 'Restart' }).click()
|
||||
getIframeBody().findByPlaceholderText('Type your age...').type('45{enter}')
|
||||
getIframeBody().findByText('Wow you are older than 20').should('exist')
|
||||
|
||||
cy.findByRole('button', { name: 'Restart' }).click()
|
||||
getIframeBody().findByPlaceholderText('Type your age...').type('90{enter}')
|
||||
getIframeBody().findByText('Wow you are older than 80').should('exist')
|
||||
})
|
||||
})
|
||||
|
||||
const createNewVar = (name: string) => {
|
||||
cy.findByTestId('variables-input').type(name)
|
||||
cy.findByRole('menuitem', { name: `Create "${name}"` }).click()
|
||||
|
Reference in New Issue
Block a user