No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

100 líneas
3.0 KiB

  1. import doctype_with_phone from "../fixtures/doctype_with_phone";
  2. context("Control Phone", () => {
  3. before(() => {
  4. cy.login();
  5. cy.visit("/app/website");
  6. });
  7. afterEach(() => {
  8. cy.clear_dialogs();
  9. });
  10. function get_dialog_with_phone() {
  11. return cy.dialog({
  12. title: "Phone",
  13. fields: [
  14. {
  15. fieldname: "phone",
  16. fieldtype: "Phone",
  17. },
  18. ],
  19. });
  20. }
  21. it("should set flag and data", () => {
  22. get_dialog_with_phone().as("dialog");
  23. cy.get(".selected-phone").click();
  24. cy.wait(100);
  25. cy.get(".phone-picker .phone-wrapper[id='afghanistan']").click();
  26. cy.wait(100);
  27. cy.get(".selected-phone .country").should("have.text", "+93");
  28. cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/af.svg");
  29. cy.get(".selected-phone").click();
  30. cy.wait(100);
  31. cy.get(".phone-picker .phone-wrapper[id='india']").click();
  32. cy.wait(100);
  33. cy.get(".selected-phone .country").should("have.text", "+91");
  34. cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
  35. let phone_number = "9312672712";
  36. cy.get(".selected-phone > img").click().first();
  37. cy.get_field("phone").first().click();
  38. cy.get(".xhiveframework-control[data-fieldname=phone]")
  39. .findByRole("textbox")
  40. .first()
  41. .type(phone_number);
  42. cy.get_field("phone").first().should("have.value", phone_number);
  43. cy.get_field("phone").first().blur();
  44. cy.wait(100);
  45. cy.get("@dialog").then((dialog) => {
  46. let value = dialog.get_value("phone");
  47. expect(value).to.equal("+91-" + phone_number);
  48. });
  49. let search_text = "india";
  50. cy.get(".selected-phone").click().first();
  51. cy.get(".phone-picker").get(".search-phones").click().type(search_text);
  52. cy.get(".phone-section .phone-wrapper:not(.hidden)").then((i) => {
  53. cy.get(`.phone-section .phone-wrapper[id*="${search_text.toLowerCase()}"]`).then(
  54. (countries) => {
  55. expect(i.length).to.equal(countries.length);
  56. }
  57. );
  58. });
  59. });
  60. it("existing document should render phone field with data", () => {
  61. cy.visit("/app/doctype");
  62. cy.insert_doc("DocType", doctype_with_phone, true);
  63. cy.clear_cache();
  64. // Creating custom doctype
  65. cy.insert_doc("DocType", doctype_with_phone, true);
  66. cy.visit("/app/doctype-with-phone");
  67. cy.click_listview_primary_button("Add Doctype With Phone");
  68. // create a record
  69. cy.fill_field("title", "Test Phone 1");
  70. cy.fill_field("phone", "+91-9823341234");
  71. cy.get_field("phone").should("have.value", "9823341234");
  72. cy.click_doc_primary_button("Save");
  73. cy.get_doc("Doctype With Phone", "Test Phone 1").then((doc) => {
  74. let value = doc.data.phone;
  75. expect(value).to.equal("+91-9823341234");
  76. });
  77. // open the doc from list view
  78. cy.go_to_list("Doctype With Phone");
  79. cy.clear_cache();
  80. cy.click_listview_row_item(0);
  81. cy.title().should("eq", "Test Phone 1");
  82. cy.get(".selected-phone .country").should("have.text", "+91");
  83. cy.get(".selected-phone > img").should("have.attr", "src").and("include", "/in.svg");
  84. cy.get_field("phone").should("have.value", "9823341234");
  85. });
  86. });