2025-02-19 17:48:34 +05:30

71 lines
2.2 KiB
JavaScript

describe('Column', function () {
before(function () {
cy.visit('/');
});
it('header dropdown toggles on click', function () {
cy.getColumnCell(2)
.find('.dt-dropdown__toggle')
.as('toggle')
.click();
cy.get('.dt-dropdown__list')
.as('dropdown-list')
.should('be.visible');
cy.getColumnCell(2).click();
cy.get('@dropdown-list').should('not.be.visible');
});
it('sort ascending button should work', function () {
cy.clickDropdown(2);
cy.clickDropdownItem(2, 'Sort Ascending');
cy.window().then(win => win.datatable.getColumn(2))
.its('sortOrder')
.should('eq', 'asc');
cy.window().then(win => win.datatable.datamanager)
.its('currentSort.colIndex')
.should('eq', 2);
cy.get('.dt-scrollable .dt-row:first div:nth-of-type(3)')
.contains('Airi Satou');
cy.clickDropdownItem(2, 'Reset sorting');
});
it('removes column using dropdown action', function () {
cy.get('.dt-cell--header').should('have.length', 12);
cy.clickDropdown(5);
cy.clickDropdownItem(5, 'Remove column');
cy.get('.dt-cell--header').should('have.length', 11);
});
it('resize column with mouse drag', function () {
cy.get('.dt-cell--header-4 .dt-cell__resize-handle').as('resize-handle');
cy
.get('@resize-handle')
.trigger('mousedown')
.trigger('mousemove', { pageX: 700, pageY: 20, which: 1 })
.trigger('mouseup');
cy.getColumnCell(4)
.should('have.css', 'width')
.and('match', /^72\d*(\.\d+)?px$/);
cy.getCell(4, 1)
.should('have.css', 'width')
.and('match', /^72\d*(\.\d+)?px$/);
});
it('resize column using double click', function () {
cy.get('.dt-cell--header-4 .dt-cell__resize-handle').trigger('dblclick');
cy.getColumnCell(4).should('have.css', 'width')
.and('match', /9\dpx/);
cy.getCell(4, 1).should('have.css', 'width')
.and('match', /9\dpx/);
});
});