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.
 
 
 
 
 
 

49 lines
1.5 KiB

  1. context('Grid Keyboard Shortcut', () => {
  2. let total_count = 0;
  3. beforeEach(() => {
  4. cy.login();
  5. cy.visit('/app/doctype/User');
  6. });
  7. before(() => {
  8. cy.login();
  9. cy.visit('/app/doctype/User');
  10. return cy.window().its('frappe').then(frappe => {
  11. frappe.db.count('DocField', {
  12. filters: {
  13. 'parent': 'User', 'parentfield': 'fields', 'parenttype': 'DocType'
  14. }
  15. }).then((r) => {
  16. total_count = r;
  17. });
  18. });
  19. });
  20. it('Insert new row at the end', () => {
  21. cy.add_new_row_in_grid('{ctrl}{shift}{downarrow}', (cy, total_count) => {
  22. cy.get('[data-name="new-docfield-1"]').should('have.attr', 'data-idx', `${total_count+1}`);
  23. }, total_count);
  24. });
  25. it('Insert new row at the top', () => {
  26. cy.add_new_row_in_grid('{ctrl}{shift}{uparrow}', (cy) => {
  27. cy.get('[data-name="new-docfield-1"]').should('have.attr', 'data-idx', '1');
  28. });
  29. });
  30. it('Insert new row below', () => {
  31. cy.add_new_row_in_grid('{ctrl}{downarrow}', (cy) => {
  32. cy.get('[data-name="new-docfield-1"]').should('have.attr', 'data-idx', '2');
  33. });
  34. });
  35. it('Insert new row above', () => {
  36. cy.add_new_row_in_grid('{ctrl}{uparrow}', (cy) => {
  37. cy.get('[data-name="new-docfield-1"]').should('have.attr', 'data-idx', '1');
  38. });
  39. });
  40. });
  41. Cypress.Commands.add('add_new_row_in_grid', (shortcut_keys, callbackFn, total_count) => {
  42. cy.get('.frappe-control[data-fieldname="fields"]').as('table');
  43. cy.get('@table').find('.grid-body .col-xs-2').first().click();
  44. cy.get('@table').find('.grid-body .col-xs-2')
  45. .first().type(shortcut_keys);
  46. callbackFn(cy, total_count);
  47. });