-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support callout pick icon (#24)
- Loading branch information
Showing
7 changed files
with
181 additions
and
32 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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
src/components/editor/__tests__/blocks/CalloutBlock.cy.tsx
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,77 @@ | ||
import { BlockType } from '@/application/types'; | ||
import { initialEditorTest } from '@/components/editor/__tests__/mount'; | ||
import { FromBlockJSON } from 'cypress/support/document'; | ||
|
||
const initialData: FromBlockJSON[] = [{ | ||
type: BlockType.CalloutBlock, | ||
data: {}, | ||
text: [{ insert: 'Hello Callout' }], | ||
children: [], | ||
}]; | ||
|
||
const { assertJSON, initializeEditor } = initialEditorTest(); | ||
|
||
describe('CalloutBlock', () => { | ||
beforeEach(() => { | ||
cy.viewport(1280, 720); | ||
Object.defineProperty(window.navigator, 'language', { value: 'en-US' }); | ||
initializeEditor(initialData); | ||
const selector = '[role="textbox"]'; | ||
|
||
cy.get(selector).as('editor'); | ||
|
||
cy.wait(1000); | ||
|
||
cy.get(selector).focus(); | ||
}); | ||
|
||
it('should show callout icon popover when clicking icon button', () => { | ||
cy.get('@editor').get('[data-block-type="callout"]').as('callout'); | ||
cy.get('@callout').find('[data-testid="callout-icon-button"]').click(); | ||
cy.get('[data-testid="change-icon-popover"]').should('exist'); | ||
}); | ||
|
||
it('should display `📌` emoji as default icon', () => { | ||
cy.get('@editor').get('[data-block-type="callout"]').as('callout'); | ||
cy.get('@callout').find('[data-testid="callout-icon-button"]').should('have.text', '📌'); | ||
}); | ||
|
||
it('should add child block when pressing enter', () => { | ||
cy.selectMultipleText(['Hello Callout']); | ||
cy.wait(100); | ||
|
||
cy.get('@editor').realPress('ArrowRight'); | ||
cy.get('@editor').realPress('Enter'); | ||
cy.get('@editor').type('Hello World'); | ||
assertJSON([ | ||
{ | ||
type: BlockType.CalloutBlock, | ||
data: {}, | ||
children: [{ | ||
type: BlockType.Paragraph, | ||
data: {}, | ||
children: [], | ||
text: [{ insert: 'Hello World' }], | ||
}], | ||
text: [{ insert: 'Hello Callout' }], | ||
}, | ||
]); | ||
}); | ||
|
||
it('should turn to paragraph block when pressing backspace at the beginning of the block', () => { | ||
cy.selectMultipleText(['Hello Callout']); | ||
cy.wait(100); | ||
|
||
cy.get('@editor').realPress('ArrowLeft'); | ||
|
||
cy.get('@editor').realPress('Backspace'); | ||
assertJSON([ | ||
{ | ||
type: BlockType.Paragraph, | ||
data: {}, | ||
children: [], | ||
text: [{ insert: 'Hello Callout' }], | ||
}, | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.