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.
 
 
 
 
 
 

56 lines
1.3 KiB

  1. context('Control Barcode', () => {
  2. beforeEach(() => {
  3. cy.login();
  4. cy.visit('/app#workspace/Website');
  5. });
  6. function get_dialog_with_barcode() {
  7. return cy.dialog({
  8. title: 'Barcode',
  9. fields: [
  10. {
  11. label: 'Barcode',
  12. fieldname: 'barcode',
  13. fieldtype: 'Barcode'
  14. }
  15. ]
  16. });
  17. }
  18. it('should generate barcode on setting a value', () => {
  19. get_dialog_with_barcode().as('dialog');
  20. cy.get('.frappe-control[data-fieldname=barcode] input')
  21. .focus()
  22. .type('123456789')
  23. .blur();
  24. cy.get('.frappe-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]')
  25. .should('exist');
  26. cy.get('@dialog').then(dialog => {
  27. let value = dialog.get_value('barcode');
  28. expect(value).to.contain('<svg');
  29. expect(value).to.contain('data-barcode-value="123456789"');
  30. });
  31. });
  32. it('should reset when input is cleared', () => {
  33. get_dialog_with_barcode().as('dialog');
  34. cy.get('.frappe-control[data-fieldname=barcode] input')
  35. .focus()
  36. .type('123456789')
  37. .blur();
  38. cy.get('.frappe-control[data-fieldname=barcode] input')
  39. .clear()
  40. .blur();
  41. cy.get('.frappe-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]')
  42. .should('not.exist');
  43. cy.get('@dialog').then(dialog => {
  44. let value = dialog.get_value('barcode');
  45. expect(value).to.equal('');
  46. });
  47. });
  48. });