Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

58 wiersze
1.9 KiB

  1. context('Control Autocomplete', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app/website');
  5. });
  6. function get_dialog_with_autocomplete(options) {
  7. cy.visit('/app/website');
  8. return cy.dialog({
  9. title: 'Autocomplete',
  10. fields: [
  11. {
  12. 'label': 'Select an option',
  13. 'fieldname': 'autocomplete',
  14. 'fieldtype': 'Autocomplete',
  15. 'options': options || ['Option 1', 'Option 2', 'Option 3'],
  16. }
  17. ]
  18. });
  19. }
  20. it('should set the valid value', () => {
  21. get_dialog_with_autocomplete().as('dialog');
  22. cy.get('.frappe-control[data-fieldname=autocomplete] input').focus().as('input');
  23. cy.wait(1000);
  24. cy.get('@input').type('2', { delay: 300 });
  25. cy.get('.frappe-control[data-fieldname=autocomplete]').findByRole('listbox').should('be.visible');
  26. cy.get('.frappe-control[data-fieldname=autocomplete] input').type('{enter}', { delay: 300 });
  27. cy.get('.frappe-control[data-fieldname=autocomplete] input').blur();
  28. cy.get('@dialog').then(dialog => {
  29. let value = dialog.get_value('autocomplete');
  30. expect(value).to.eq('Option 2');
  31. dialog.clear();
  32. });
  33. });
  34. it('should set the valid value with different label', () => {
  35. const options_with_label = [
  36. { label: "Option 1", value: "option_1" },
  37. { label: "Option 2", value: "option_2" }
  38. ];
  39. get_dialog_with_autocomplete(options_with_label).as('dialog');
  40. cy.get('.frappe-control[data-fieldname=autocomplete] input').focus().as('input');
  41. cy.get('.frappe-control[data-fieldname=autocomplete]').findByRole('listbox').should('be.visible');
  42. cy.get('@input').type('2', { delay: 300 });
  43. cy.get('.frappe-control[data-fieldname=autocomplete] input').type('{enter}', { delay: 300 });
  44. cy.get('.frappe-control[data-fieldname=autocomplete] input').blur();
  45. cy.get('@dialog').then(dialog => {
  46. let value = dialog.get_value('autocomplete');
  47. expect(value).to.eq('option_2');
  48. dialog.clear();
  49. });
  50. });
  51. });