You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

column.js 2.1 KiB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. describe('Column', function () {
  2. before(function () {
  3. cy.visit('/');
  4. });
  5. it('header dropdown toggles on click', function () {
  6. cy.getColumnCell(2)
  7. .find('.dt-dropdown__toggle')
  8. .as('toggle')
  9. .click();
  10. cy.get('.dt-dropdown__list')
  11. .as('dropdown-list')
  12. .should('be.visible');
  13. cy.getColumnCell(2).click();
  14. cy.get('@dropdown-list').should('not.be.visible');
  15. });
  16. it('sort ascending button should work', function () {
  17. cy.clickDropdown(2);
  18. cy.clickDropdownItem(2, 'Sort Ascending');
  19. cy.window().then(win => win.datatable.getColumn(2))
  20. .its('sortOrder')
  21. .should('eq', 'asc');
  22. cy.window().then(win => win.datatable.datamanager)
  23. .its('currentSort.colIndex')
  24. .should('eq', 2);
  25. cy.get('.dt-scrollable .dt-row:first')
  26. .contains('Airi Satou');
  27. cy.clickDropdownItem(2, 'Reset sorting');
  28. });
  29. it('removes column using dropdown action', function () {
  30. cy.get('.dt-cell--header').should('have.length', 8);
  31. cy.clickDropdown(5);
  32. cy.clickDropdownItem(5, 'Remove column');
  33. cy.get('.dt-cell--header').should('have.length', 7);
  34. });
  35. it('resize column with mouse drag', function () {
  36. cy.get('.dt-cell--header-3 .dt-cell__resize-handle').as('resize-handle');
  37. cy
  38. .get('@resize-handle')
  39. .trigger('mousedown')
  40. .trigger('mousemove', { pageX: 510, pageY: 20, which: 1 })
  41. .trigger('mouseup');
  42. cy.getColumnCell(3)
  43. .should('have.css', 'width')
  44. .and('match', /13\dpx/);
  45. cy.getCell(3, 1)
  46. .should('have.css', 'width')
  47. .and('match', /13\dpx/);
  48. });
  49. it('resize column using double click', function () {
  50. cy.get('.dt-cell--header-4 .dt-cell__resize-handle').trigger('dblclick');
  51. cy.getColumnCell(4).should('have.css', 'width')
  52. .and('match', /9\dpx/);
  53. cy.getCell(4, 1).should('have.css', 'width')
  54. .and('match', /9\dpx/);
  55. });
  56. });