describe('treeSelect', () => {
    it('searchPosition is trigger', () => {
        cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--search-position&args=&viewMode=story');

        // test trigger focus
        cy.get('input').eq(0).click();
        cy.get('.semi-tree-select-focus').should('exist');

        // test trigger blur
        cy.get('body').click('right');
        cy.get('.semi-tree-select-focus').should('not.exist');
    });

    it('load data', () => {
        cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--load-data&args=&viewMode=story');

        cy.get('.semi-tree-select-selection').click();
        cy.wait(200);
        cy.get('.semi-tree-option-list .semi-icon-tree_triangle_down').eq(0).click();
        cy.wait(1000);
        // assert data had load success
        cy.get('.semi-tree-option-list').contains('Child Node');
    });

    it('clear and close', () => {
        cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--check-relation-demo&args=&viewMode=story');
        cy.viewport(1000, 1000);
        
        // test remove tag
        cy.get('.semi-tag-close').eq(3).click();
        cy.get('.semi-tag-content').contains('Japan').should('not.exist');

        cy.get('.semi-tree-select-selection').eq(8).contains('China');
        cy.get('.semi-tree-select-selection').eq(8).trigger('mouseover');
        cy.get('.semi-tree-select-clearbtn').click();
        cy.get('.semi-tagInput-wrapper .semi-tag').should('not.exist');

        // multiple When triggerSearch, clicking the clear button will trigger to clear Input
        cy.get('input').eq(1).type('dddd');
        cy.get('.semi-tree-select-selection').eq(8).trigger('mouseover');
        cy.get('.semi-tree-select-clearbtn').click();
        cy.get('.semi-tree-select-selection').eq(8).get('input').should('have.value', '');

        cy.get('body').click('right');
        // wait for the panel close
        cy.wait(500);

        // single selection  When triggerSearch, clicking the clear button will trigger to clear Input
        cy.get('input').eq(2).type('dddd');
        cy.get('.semi-tree-select-selection').eq(9).trigger('mouseover');
        cy.get('.semi-tree-select-clearbtn').click();
        cy.get('.semi-tree-select-selection').eq(9).get('input').should('have.value', '');
    });

    it('clear by key press', () => {
        cy.visit('http://127.0.0.1:6006/iframe.html?id=treeselect--check-relation-demo&args=&viewMode=story');
        cy.get('.semi-tree-select-selection').eq(8).contains('China');
        cy.get('.semi-tree-select-selection').eq(8).trigger('mouseover');
        cy.get('.semi-tree-select-clearbtn').focus();
        cy.get('.semi-tree-select-clearbtn').type('{enter}');
        cy.get('.semi-tagInput-wrapper .semi-tag').should('not.exist');
    });

});