選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

control_barcode.js 1.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. context("Control Barcode", () => {
  2. beforeEach(() => {
  3. cy.login();
  4. cy.visit("/app/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.focused().blur();
  21. cy.get(".xhiveframework-control[data-fieldname=barcode]")
  22. .findByRole("textbox")
  23. .type("123456789")
  24. .blur();
  25. cy.get(
  26. '.xhiveframework-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]'
  27. ).should("exist");
  28. cy.get("@dialog").then((dialog) => {
  29. let value = dialog.get_value("barcode");
  30. expect(value).to.contain("<svg");
  31. expect(value).to.contain('data-barcode-value="123456789"');
  32. });
  33. });
  34. it("should reset when input is cleared", () => {
  35. get_dialog_with_barcode().as("dialog");
  36. cy.focused().blur();
  37. cy.get(".xhiveframework-control[data-fieldname=barcode]")
  38. .findByRole("textbox")
  39. .type("123456789")
  40. .blur();
  41. cy.get(".xhiveframework-control[data-fieldname=barcode]").findByRole("textbox").clear().blur();
  42. cy.get(
  43. '.xhiveframework-control[data-fieldname=barcode] svg[data-barcode-value="123456789"]'
  44. ).should("not.exist");
  45. cy.get("@dialog").then((dialog) => {
  46. let value = dialog.get_value("barcode");
  47. expect(value).to.equal("");
  48. });
  49. });
  50. });