-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for RichTextCharacterLimit
- Loading branch information
1 parent
3764b08
commit 52ff503
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/// <reference types="cypress" /> | ||
|
||
context('RichTextCharacterLimit', () => { | ||
|
||
beforeEach(() => { | ||
cy.loginToWordPress(); | ||
cy.createPost({title: 'Rich Text Character Limit'}); | ||
cy.insertBlock('Rich Text Character Limit'); | ||
}); | ||
|
||
it('Allows the user to pick the block and displays it', () => { | ||
cy.get('.wp-block-example-rich-text-character-limit').should('exist'); | ||
cy.get('.wp-block-example-rich-text-character-limit').should('be.visible'); | ||
|
||
cy.savePost(); | ||
}) | ||
|
||
it('Allows text to be entered', () => { | ||
cy.get('.wp-block-example-rich-text-character-limit .block-editor-rich-text__editable').focus().clear().type('This is a test'); | ||
cy.get('.wp-block-example-rich-text-character-limit .block-editor-rich-text__editable').should('have.text', 'This is a test'); | ||
}) | ||
|
||
it('Has the correct starting value', () => { | ||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__count').should('exist'); | ||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__count').should('have.text', '0'); | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__limit').should('exist'); | ||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__limit').should('have.text', '30'); | ||
}) | ||
|
||
it('Updates the count appropriately', () => { | ||
cy.get('.wp-block-example-rich-text-character-limit .block-editor-rich-text__editable').focus().clear().type('This is a test'); | ||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__count').should('have.text', '14'); | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__limit').should('exist'); | ||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__character-count__limit').should('have.text', '30'); | ||
}) | ||
|
||
it('Updates to the approaching limit state appropriately', () => { | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .block-editor-rich-text__editable').focus().clear().type('0123456789012345678901234'); | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__circular-progress').should('have.class', 'is-approaching-limit'); | ||
}) | ||
|
||
it('Updates to the is over limit state appropriately', () => { | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .block-editor-rich-text__editable').focus().clear().type('012345678901234567890123456789'); | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .tenup--block-components__circular-progress').should('have.class', 'is-over-limit'); | ||
}) | ||
|
||
it('Shows the toolbar controls appropriately', () => { | ||
|
||
cy.get('.wp-block-example-rich-text-character-limit .block-editor-rich-text__editable').focus() | ||
|
||
cy.get('.components-toolbar-button[aria-label="Bold"]').should('exist'); | ||
cy.get('.components-toolbar-button[aria-label="Bold"]').should('be.visible'); | ||
|
||
cy.get('.components-toolbar-button[aria-label="Link"]').should('exist'); | ||
cy.get('.components-toolbar-button[aria-label="Link"]').should('be.visible'); | ||
}); | ||
}) |