您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

128 行
3.6 KiB

  1. context('Dynamic Link', () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit('/app/doctype');
  5. return cy.window().its('frappe').then(frappe => {
  6. return frappe.xcall('frappe.tests.ui_test_helpers.create_doctype', {
  7. name: 'Test Dynamic Link',
  8. fields: [
  9. {
  10. "label": "Document Type",
  11. "fieldname": "doc_type",
  12. "fieldtype": "Link",
  13. "options": "DocType",
  14. "in_list_view": 1,
  15. "in_standard_filter": 1,
  16. },
  17. {
  18. "label": "Document ID",
  19. "fieldname": "doc_id",
  20. "fieldtype": "Dynamic Link",
  21. "options": "doc_type",
  22. "in_list_view": 1,
  23. "in_standard_filter": 1,
  24. },
  25. ]
  26. });
  27. });
  28. });
  29. function get_dialog_with_dynamic_link() {
  30. return cy.dialog({
  31. title: 'Dynamic Link',
  32. fields: [{
  33. "label": "Document Type",
  34. "fieldname": "doc_type",
  35. "fieldtype": "Link",
  36. "options": "DocType",
  37. "in_list_view": 1,
  38. },
  39. {
  40. "label": "Document ID",
  41. "fieldname": "doc_id",
  42. "fieldtype": "Dynamic Link",
  43. "options": "doc_type",
  44. "in_list_view": 1,
  45. }]
  46. });
  47. }
  48. function get_dialog_with_dynamic_link_option() {
  49. return cy.dialog({
  50. title: 'Dynamic Link',
  51. fields: [{
  52. "label": "Document Type",
  53. "fieldname": "doc_type",
  54. "fieldtype": "Link",
  55. "options": "DocType",
  56. "in_list_view": 1,
  57. },
  58. {
  59. "label": "Document ID",
  60. "fieldname": "doc_id",
  61. "fieldtype": "Dynamic Link",
  62. "get_options": () => {
  63. return "User";
  64. },
  65. "in_list_view": 1,
  66. }]
  67. });
  68. }
  69. it('Creating a dynamic link by passing option as function and verifying it in a dialog', () => {
  70. get_dialog_with_dynamic_link_option().as('dialog');
  71. cy.get_field('doc_type').clear();
  72. cy.fill_field('doc_type', 'User', 'Link');
  73. cy.get_field('doc_id').click();
  74. //Checking if the listbox have length greater than 0
  75. cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
  76. cy.get('.btn-modal-close').click({force: true});
  77. });
  78. it('Creating a dynamic link and verifying it in a dialog', () => {
  79. get_dialog_with_dynamic_link().as('dialog');
  80. cy.get_field('doc_type').clear();
  81. cy.fill_field('doc_type', 'User', 'Link');
  82. cy.get_field('doc_id').click();
  83. //Checking if the listbox have length greater than 0
  84. cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
  85. cy.get('.btn-modal-close').click({force: true, multiple: true});
  86. });
  87. it('Creating a dynamic link and verifying it', () => {
  88. cy.visit('/app/test-dynamic-link');
  89. //Clicking on the Document ID field
  90. cy.get_field('doc_type').clear();
  91. //Entering User in the Doctype field
  92. cy.fill_field('doc_type', 'User', 'Link', {delay: 500});
  93. cy.get_field('doc_id').click();
  94. //Checking if the listbox have length greater than 0
  95. cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
  96. //Opening a new form for dynamic link doctype
  97. cy.new_form('Test Dynamic Link');
  98. cy.get_field('doc_type').clear();
  99. //Entering User in the Doctype field
  100. cy.fill_field('doc_type', 'User', 'Link', {delay: 500});
  101. cy.get_field('doc_id').click();
  102. //Checking if the listbox have length greater than 0
  103. cy.get('[data-fieldname="doc_id"]').find('.awesomplete').find("li").its('length').should('be.gte', 0);
  104. cy.get_field('doc_type').clear();
  105. //Entering System Settings in the Doctype field
  106. cy.fill_field('doc_type', 'System Settings', 'Link', {delay: 500});
  107. cy.get_field('doc_id').click();
  108. //Checking if the system throws error
  109. cy.get('.modal-title').should('have.text', 'Error');
  110. cy.get('.msgprint').should('have.text', 'System Settings is not a valid DocType for Dynamic Link');
  111. });
  112. });