2022-01-12 09:57:00 +01:00
|
|
|
import { userIds } from 'cypress/plugins/data'
|
2022-01-08 08:38:39 +01:00
|
|
|
import {
|
|
|
|
parseTestTypebot,
|
|
|
|
preventUserFromRefreshing,
|
|
|
|
} from 'cypress/plugins/utils'
|
2022-01-08 07:40:55 +01:00
|
|
|
import { BubbleStepType } from 'models'
|
2022-01-07 07:33:01 +01:00
|
|
|
|
|
|
|
describe('Text bubbles', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.task('seed')
|
|
|
|
cy.task(
|
|
|
|
'createTypebot',
|
|
|
|
parseTestTypebot({
|
|
|
|
id: 'typebot3',
|
|
|
|
name: 'Typebot #3',
|
2022-01-12 09:57:00 +01:00
|
|
|
ownerId: userIds[1],
|
2022-01-07 07:33:01 +01:00
|
|
|
steps: {
|
|
|
|
byId: {
|
|
|
|
step1: {
|
|
|
|
id: 'step1',
|
|
|
|
blockId: 'block1',
|
2022-01-08 07:40:55 +01:00
|
|
|
type: BubbleStepType.TEXT,
|
2022-01-07 07:33:01 +01:00
|
|
|
content: { html: '', plainText: '', richText: [] },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
allIds: ['step1'],
|
|
|
|
},
|
|
|
|
blocks: {
|
|
|
|
byId: {
|
|
|
|
block1: {
|
|
|
|
id: 'block1',
|
|
|
|
graphCoordinates: { x: 400, y: 200 },
|
|
|
|
title: 'Block #1',
|
|
|
|
stepIds: ['step1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
allIds: ['block1'],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
)
|
|
|
|
cy.signOut()
|
|
|
|
})
|
|
|
|
|
2022-01-08 08:38:39 +01:00
|
|
|
afterEach(() => {
|
|
|
|
cy.window().then((win) => {
|
|
|
|
win.removeEventListener('beforeunload', preventUserFromRefreshing)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-01-07 07:33:01 +01:00
|
|
|
it('rich text features should work', () => {
|
|
|
|
cy.signIn('test2@gmail.com')
|
|
|
|
cy.visit('/typebots/typebot3/edit')
|
|
|
|
cy.findByTestId('bold-button').click()
|
|
|
|
cy.findByRole('textbox', { name: 'Text editor' }).type('Bold text{enter}')
|
|
|
|
cy.findByTestId('bold-button').click()
|
|
|
|
cy.findByTestId('italic-button').click()
|
|
|
|
cy.findByRole('textbox', { name: 'Text editor' }).type('Italic text{enter}')
|
|
|
|
cy.findByTestId('italic-button').click()
|
|
|
|
cy.findByTestId('underline-button').click()
|
|
|
|
cy.findByRole('textbox', { name: 'Text editor' }).type(
|
|
|
|
'Underlined text{enter}'
|
|
|
|
)
|
|
|
|
cy.findByTestId('bold-button').click()
|
|
|
|
cy.findByTestId('italic-button').click()
|
|
|
|
cy.findByRole('textbox', { name: 'Text editor' }).type('Everything text')
|
|
|
|
cy.findByRole('button', { name: 'Preview' }).click()
|
|
|
|
getIframeBody()
|
|
|
|
.get('span.slate-bold')
|
|
|
|
.should('exist')
|
|
|
|
.should('contain.text', 'Bold text')
|
|
|
|
getIframeBody()
|
|
|
|
.get('span.slate-italic')
|
|
|
|
.should('exist')
|
|
|
|
.should('contain.text', 'Italic text')
|
|
|
|
getIframeBody()
|
|
|
|
.get('span.slate-underline')
|
|
|
|
.should('exist')
|
|
|
|
.should('contain.text', 'Underlined text')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const getIframeBody = () => {
|
|
|
|
return cy
|
|
|
|
.get('#typebot-iframe')
|
|
|
|
.its('0.contentDocument.body')
|
|
|
|
.should('not.be.empty')
|
|
|
|
.then(cy.wrap)
|
|
|
|
}
|