From 3544d4865aa334909f2c7abff06a256d8bdd3e7c Mon Sep 17 00:00:00 2001 From: Tanya Fomina Date: Sat, 23 Mar 2024 18:40:26 +0300 Subject: [PATCH] Add nested popover test --- test/cypress/tests/utils/popover.cy.ts | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/test/cypress/tests/utils/popover.cy.ts b/test/cypress/tests/utils/popover.cy.ts index 3eeeb2dd..296ced9c 100644 --- a/test/cypress/tests/utils/popover.cy.ts +++ b/test/cypress/tests/utils/popover.cy.ts @@ -1,5 +1,6 @@ import Popover from '../../../../src/components/utils/popover'; import { PopoverItem } from '../../../../types'; +import { TunesMenuConfig } from '../../../../types/tools'; /* eslint-disable @typescript-eslint/no-empty-function */ @@ -257,4 +258,79 @@ describe('Popover', () => { cy.get('[data-cy-name=customContent]'); }); }); + + it('should display nested popover', () => { + /** Tool class to test how it is displayed inside block tunes popover */ + class TestTune { + public static isTune = true; + + /** Tool data displayed in block tunes popover */ + public render(): TunesMenuConfig { + return { + icon: 'Icon', + title: 'Title', + toggle: 'key', + name: 'test-item', + children: { + items: [ + { + icon: 'Icon', + title: 'Title', + name: 'nested-test-item', + }, + ], + }, + }; + } + } + + /** Create editor instance */ + cy.createEditor({ + tools: { + testTool: TestTune, + }, + tunes: [ 'testTool' ], + data: { + blocks: [ + { + type: 'paragraph', + data: { + text: 'Hello', + }, + }, + ], + }, + }); + + /** Open block tunes menu */ + cy.get('[data-cy=editorjs]') + .get('.cdx-block') + .click(); + + cy.get('[data-cy=editorjs]') + .get('.ce-toolbar__settings-btn') + .click(); + + /** Check item with children has arrow icon */ + cy.get('[data-cy=editorjs]') + .get('[data-item-name="test-item"]') + .get('.ce-popover-item__icon--chevron-right') + .should('be.visible'); + + /** Click the item */ + cy.get('[data-cy=editorjs]') + .get('[data-item-name="test-item"]') + .click(); + + /** Check nested popover opened */ + cy.get('[data-cy=editorjs]') + .get('.ce-popover--nested .ce-popover__container') + .should('be.visible'); + + /** Check child item displayed */ + cy.get('[data-cy=editorjs]') + .get('.ce-popover--nested .ce-popover__container') + .get('[data-item-name="nested-test-item"]') + .should('be.visible'); + }); });