test rich text editor
This commit is contained in:
parent
3db7b9d98f
commit
cdc29b795a
2 changed files with 41 additions and 11 deletions
|
|
@ -17,11 +17,9 @@ function fillElementForm(
|
|||
): void {
|
||||
cy.get('[data-cy="admin-element-title"]').clear().type(title)
|
||||
cy.get('[data-cy="admin-element-description"]').clear().type(description)
|
||||
cy.get('[data-cy="admin-element-rich-text"]').clear()
|
||||
clearRichText()
|
||||
if (richText !== '') {
|
||||
cy.get('[data-cy="admin-element-rich-text"]').type(richText, {
|
||||
parseSpecialCharSequences: false,
|
||||
})
|
||||
cy.get('[data-cy="admin-element-rich-text"]').type(richText)
|
||||
}
|
||||
cy.get('[data-cy="admin-element-youtube-url"]').clear()
|
||||
if (youtubeUrl !== '') {
|
||||
|
|
@ -29,6 +27,12 @@ function fillElementForm(
|
|||
}
|
||||
}
|
||||
|
||||
function clearRichText(): void {
|
||||
cy.get('[data-cy="admin-element-rich-text"]')
|
||||
.click()
|
||||
.type('{selectAll}{backspace}')
|
||||
}
|
||||
|
||||
describe('admin element editing', () => {
|
||||
it('does not show the edit link to logged-out users', () => {
|
||||
cy.visit('/element/1')
|
||||
|
|
@ -72,7 +76,6 @@ describe('admin element editing', () => {
|
|||
const originalDescription = 'a structured path for inner and outer growth'
|
||||
const updatedTitle = 'Baderech HaAvodah Updated'
|
||||
const updatedDescription = 'Updated admin description'
|
||||
const updatedRichText = '<p>Updated admin rich text</p>'
|
||||
|
||||
loginAsAdmin()
|
||||
cy.visit('/admin/element/1')
|
||||
|
|
@ -80,9 +83,28 @@ describe('admin element editing', () => {
|
|||
fillElementForm(
|
||||
updatedTitle,
|
||||
updatedDescription,
|
||||
updatedRichText,
|
||||
'',
|
||||
'',
|
||||
)
|
||||
cy.get('[data-cy="admin-element-rich-text"]')
|
||||
.should('have.attr', 'contenteditable', 'true')
|
||||
|
||||
cy.get('[data-cy="admin-rich-text-block-type"]').select('heading-2')
|
||||
cy.get('[data-cy="admin-element-rich-text"]')
|
||||
.type('Updated admin heading{enter}')
|
||||
cy.get('[data-cy="admin-rich-text-bold"]').click()
|
||||
cy.get('[data-cy="admin-element-rich-text"]').type('Strong admin text')
|
||||
cy.get('[data-cy="admin-rich-text-bold"]').click()
|
||||
cy.get('[data-cy="admin-element-rich-text"]').type('{enter}')
|
||||
cy.get('[data-cy="admin-rich-text-bullet-list"]').click()
|
||||
cy.get('[data-cy="admin-element-rich-text"]')
|
||||
.type('First saved item{enter}Second saved item')
|
||||
cy.get('[data-cy="admin-rich-text-bullet-list"]').click()
|
||||
cy.window().then((windowObject) => {
|
||||
cy.stub(windowObject, 'prompt').returns('https://example.com/rich-text')
|
||||
})
|
||||
cy.get('[data-cy="admin-rich-text-link"]').click()
|
||||
cy.get('[data-cy="admin-rich-text-insert-table"]').click()
|
||||
cy.get('[data-cy="admin-element-save"]').click()
|
||||
|
||||
cy.get('[data-cy="admin-element-status"]')
|
||||
|
|
@ -91,8 +113,16 @@ describe('admin element editing', () => {
|
|||
cy.contains('header.site-header a', 'View Element').click()
|
||||
cy.location('pathname').should('eq', '/element/1')
|
||||
cy.contains('h1', updatedTitle).should('be.visible')
|
||||
cy.get('[data-cy="element-rich-text"] h2')
|
||||
.should('contain.text', 'Updated admin heading')
|
||||
cy.get('[data-cy="element-rich-text"] strong')
|
||||
.should('contain.text', 'Strong admin text')
|
||||
cy.get('[data-cy="element-rich-text"]')
|
||||
.should('contain.text', 'Updated admin rich text')
|
||||
.should('contain.text', 'First saved item')
|
||||
.and('contain.text', 'Second saved item')
|
||||
cy.get('[data-cy="element-rich-text"] a')
|
||||
.should('have.attr', 'href', 'https://example.com/rich-text')
|
||||
cy.get('[data-cy="element-rich-text"] table').should('exist')
|
||||
|
||||
cy.visit('/admin/element/1')
|
||||
fillElementForm(
|
||||
|
|
@ -105,6 +135,8 @@ describe('admin element editing', () => {
|
|||
cy.get('[data-cy="admin-element-status"]')
|
||||
.should('be.visible')
|
||||
.and('contain.text', 'Saved')
|
||||
cy.contains('header.site-header a', 'View Element').click()
|
||||
cy.get('[data-cy="element-rich-text"]').should('not.exist')
|
||||
})
|
||||
|
||||
it('uploads icon and pdf files immediately through the UI', () => {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@ describe('cypress database reset', () => {
|
|||
.clear()
|
||||
.type('Dirty Cypress description')
|
||||
cy.get('[data-cy="admin-element-rich-text"]')
|
||||
.clear()
|
||||
.type('<p>Dirty Cypress rich text</p>', {
|
||||
parseSpecialCharSequences: false,
|
||||
})
|
||||
.click()
|
||||
.type('{selectAll}{backspace}Dirty Cypress rich text')
|
||||
cy.get('[data-cy="admin-element-save"]').click()
|
||||
|
||||
cy.get('[data-cy="admin-element-status"]')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue