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.

commands.js 9.3 KiB

feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
4 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
feat: Optionally remove seconds from datetime (#8531) * fix: Add updated datepicker; fixed seconds formatting bug. Seconds between 0 and 9 were not zero-padded. * feat: Add framework for time format * feat: datetime server-side formatters. * tests: Added server-side datetime formatter tests * feat: Update client-side datetime formatters * tests: Add Cypress client-side formatting tests. * fix: JSON errors * fix: Update to not hard-code admin password * fix: Change to using bulk_update rather than the REST API * tests: Use Custom doctype for testing, not Standard * fix: Codacy style fixes * fix: Commonify update_datetime_picker in date.js, datetime.js, time.js Fix order of time_format in System Settings Restore get_user_fmt in utils/datetime.js * feat: Drastically reduce scale of Cypress testing (to make tests faster) Full testing is possible by setting 'fast_mode' to false in the spec file. * fix: Fix issues with datepicker/timepicker expansion * fix: typo * style: Various style fixes as requested by DeppSource: Python * fix: Timepicker not hiding on 'now' button. Force hiding on click. * style: Codacy style fixes. * fix: Use datepicker from node_modules * test: Refactor Datetime UI tests - cy.get_field - cy.set_value - cy.insert_doc with ignore_duplicate - Nominal datetime tests to cover most formats - Formatting with prettier * test: Datetime UI tests; wait for cur_frm.doc.datetime to update * tests: Add whitespace to typed input - Clear input only for Time field * test: Wait timeout 200 * test: Fix form test Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
5 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. import 'cypress-file-upload';
  2. import '@testing-library/cypress/add-commands';
  3. import '@4tw/cypress-drag-drop';
  4. // ***********************************************
  5. // This example commands.js shows you how to
  6. // create various custom commands and overwrite
  7. // existing commands.
  8. //
  9. // For more comprehensive examples of custom
  10. // commands please read more here:
  11. // https://on.cypress.io/custom-commands
  12. // ***********************************************
  13. //
  14. //
  15. // -- This is a parent command --
  16. // Cypress.Commands.add("login", (email, password) => { ... });
  17. //
  18. //
  19. // -- This is a child command --
  20. // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... });
  21. //
  22. //
  23. // -- This is a dual command --
  24. // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... });
  25. //
  26. //
  27. // -- This is will overwrite an existing command --
  28. // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... });
  29. Cypress.Commands.add('login', (email, password) => {
  30. if (!email) {
  31. email = 'Administrator';
  32. }
  33. if (!password) {
  34. password = Cypress.env('adminPassword');
  35. }
  36. cy.request({
  37. url: '/api/method/login',
  38. method: 'POST',
  39. body: {
  40. usr: email,
  41. pwd: password
  42. }
  43. });
  44. });
  45. Cypress.Commands.add('call', (method, args) => {
  46. return cy
  47. .window()
  48. .its('frappe.csrf_token')
  49. .then(csrf_token => {
  50. return cy
  51. .request({
  52. url: `/api/method/${method}`,
  53. method: 'POST',
  54. body: args,
  55. headers: {
  56. Accept: 'application/json',
  57. 'Content-Type': 'application/json',
  58. 'X-Frappe-CSRF-Token': csrf_token
  59. }
  60. })
  61. .then(res => {
  62. expect(res.status).eq(200);
  63. return res.body;
  64. });
  65. });
  66. });
  67. Cypress.Commands.add('get_list', (doctype, fields = [], filters = []) => {
  68. filters = JSON.stringify(filters);
  69. fields = JSON.stringify(fields);
  70. let url = `/api/resource/${doctype}?fields=${fields}&filters=${filters}`;
  71. return cy
  72. .window()
  73. .its('frappe.csrf_token')
  74. .then(csrf_token => {
  75. return cy
  76. .request({
  77. method: 'GET',
  78. url,
  79. headers: {
  80. Accept: 'application/json',
  81. 'X-Frappe-CSRF-Token': csrf_token
  82. }
  83. })
  84. .then(res => {
  85. expect(res.status).eq(200);
  86. return res.body;
  87. });
  88. });
  89. });
  90. Cypress.Commands.add('get_doc', (doctype, name) => {
  91. return cy
  92. .window()
  93. .its('frappe.csrf_token')
  94. .then(csrf_token => {
  95. return cy
  96. .request({
  97. method: 'GET',
  98. url: `/api/resource/${doctype}/${name}`,
  99. headers: {
  100. Accept: 'application/json',
  101. 'X-Frappe-CSRF-Token': csrf_token
  102. }
  103. })
  104. .then(res => {
  105. expect(res.status).eq(200);
  106. return res.body;
  107. });
  108. });
  109. });
  110. Cypress.Commands.add('remove_doc', (doctype, name) => {
  111. return cy
  112. .window()
  113. .its('frappe.csrf_token')
  114. .then(csrf_token => {
  115. return cy
  116. .request({
  117. method: 'DELETE',
  118. url: `/api/resource/${doctype}/${name}`,
  119. headers: {
  120. Accept: 'application/json',
  121. 'X-Frappe-CSRF-Token': csrf_token
  122. }
  123. })
  124. .then(res => {
  125. expect(res.status).eq(202);
  126. return res.body;
  127. });
  128. });
  129. });
  130. Cypress.Commands.add('create_records', doc => {
  131. return cy
  132. .call('frappe.tests.ui_test_helpers.create_if_not_exists', {doc: JSON.stringify(doc)})
  133. .then(r => r.message);
  134. });
  135. Cypress.Commands.add('set_value', (doctype, name, obj) => {
  136. return cy.call('frappe.client.set_value', {
  137. doctype,
  138. name,
  139. fieldname: obj
  140. });
  141. });
  142. Cypress.Commands.add('fill_field', (fieldname, value, fieldtype = 'Data') => {
  143. cy.get_field(fieldname, fieldtype).as('input');
  144. if (['Date', 'Time', 'Datetime'].includes(fieldtype)) {
  145. cy.get('@input').click().wait(200);
  146. cy.get('.datepickers-container .datepicker.active').should('exist');
  147. }
  148. if (fieldtype === 'Time') {
  149. cy.get('@input').clear().wait(200);
  150. }
  151. if (fieldtype === 'Select') {
  152. cy.get('@input').select(value);
  153. } else {
  154. cy.get('@input').type(value, {waitForAnimations: false, force: true, delay: 100});
  155. }
  156. return cy.get('@input');
  157. });
  158. Cypress.Commands.add('get_field', (fieldname, fieldtype = 'Data') => {
  159. let field_element = fieldtype === 'Select' ? 'select': 'input';
  160. let selector = `[data-fieldname="${fieldname}"] ${field_element}:visible`;
  161. if (fieldtype === 'Text Editor') {
  162. selector = `[data-fieldname="${fieldname}"] .ql-editor[contenteditable=true]:visible`;
  163. }
  164. if (fieldtype === 'Code') {
  165. selector = `[data-fieldname="${fieldname}"] .ace_text-input`;
  166. }
  167. if (fieldtype === 'Markdown Editor') {
  168. selector = `[data-fieldname="${fieldname}"] .ace-editor-target`;
  169. }
  170. return cy.get(selector).first();
  171. });
  172. Cypress.Commands.add('fill_table_field', (tablefieldname, row_idx, fieldname, value, fieldtype = 'Data') => {
  173. cy.get_table_field(tablefieldname, row_idx, fieldname, fieldtype).as('input');
  174. if (['Date', 'Time', 'Datetime'].includes(fieldtype)) {
  175. cy.get('@input').click().wait(200);
  176. cy.get('.datepickers-container .datepicker.active').should('exist');
  177. }
  178. if (fieldtype === 'Time') {
  179. cy.get('@input').clear().wait(200);
  180. }
  181. if (fieldtype === 'Select') {
  182. cy.get('@input').select(value);
  183. } else {
  184. cy.get('@input').type(value, {waitForAnimations: false, force: true});
  185. }
  186. return cy.get('@input');
  187. });
  188. Cypress.Commands.add('get_table_field', (tablefieldname, row_idx, fieldname, fieldtype = 'Data') => {
  189. let selector = `.frappe-control[data-fieldname="${tablefieldname}"]`;
  190. selector += ` [data-idx="${row_idx}"]`;
  191. if (fieldtype === 'Text Editor') {
  192. selector += ` [data-fieldname="${fieldname}"] .ql-editor[contenteditable=true]`;
  193. } else if (fieldtype === 'Code') {
  194. selector += ` [data-fieldname="${fieldname}"] .ace_text-input`;
  195. } else {
  196. selector += ` [data-fieldname="${fieldname}"]`;
  197. return cy.get(selector).find('.form-control:visible, .static-area:visible').first();
  198. }
  199. return cy.get(selector);
  200. });
  201. Cypress.Commands.add('awesomebar', text => {
  202. cy.get('#navbar-search').type(`${text}{downarrow}{enter}`, {delay: 700});
  203. });
  204. Cypress.Commands.add('new_form', doctype => {
  205. let dt_in_route = doctype.toLowerCase().replace(/ /g, '-');
  206. cy.visit(`/app/${dt_in_route}/new`);
  207. cy.get('body').should('have.attr', 'data-route', `Form/${doctype}/new-${dt_in_route}-1`);
  208. cy.get('body').should('have.attr', 'data-ajax-state', 'complete');
  209. });
  210. Cypress.Commands.add('go_to_list', doctype => {
  211. let dt_in_route = doctype.toLowerCase().replace(/ /g, '-');
  212. cy.visit(`/app/${dt_in_route}`);
  213. });
  214. Cypress.Commands.add('clear_cache', () => {
  215. cy.window()
  216. .its('frappe')
  217. .then(frappe => {
  218. frappe.ui.toolbar.clear_cache();
  219. });
  220. });
  221. Cypress.Commands.add('dialog', opts => {
  222. return cy.window().then(win => {
  223. var d = new win.frappe.ui.Dialog(opts);
  224. d.show();
  225. return d;
  226. });
  227. });
  228. Cypress.Commands.add('get_open_dialog', () => {
  229. return cy.get('.modal:visible').last();
  230. });
  231. Cypress.Commands.add('hide_dialog', () => {
  232. cy.wait(300);
  233. cy.get_open_dialog().find('.btn-modal-close').click();
  234. cy.get('.modal:visible').should('not.exist');
  235. });
  236. Cypress.Commands.add('insert_doc', (doctype, args, ignore_duplicate) => {
  237. return cy
  238. .window()
  239. .its('frappe.csrf_token')
  240. .then(csrf_token => {
  241. return cy
  242. .request({
  243. method: 'POST',
  244. url: `/api/resource/${doctype}`,
  245. body: args,
  246. headers: {
  247. Accept: 'application/json',
  248. 'Content-Type': 'application/json',
  249. 'X-Frappe-CSRF-Token': csrf_token
  250. },
  251. failOnStatusCode: !ignore_duplicate
  252. })
  253. .then(res => {
  254. let status_codes = [200];
  255. if (ignore_duplicate) {
  256. status_codes.push(409);
  257. }
  258. expect(res.status).to.be.oneOf(status_codes);
  259. return res.body.data;
  260. });
  261. });
  262. });
  263. Cypress.Commands.add('add_filter', () => {
  264. cy.get('.filter-section .filter-button').click();
  265. cy.wait(300);
  266. cy.get('.filter-popover').should('exist');
  267. });
  268. Cypress.Commands.add('clear_filters', () => {
  269. let has_filter = false;
  270. cy.intercept({
  271. method: 'POST',
  272. url: 'api/method/frappe.model.utils.user_settings.save'
  273. }).as('filter-saved');
  274. cy.get('.filter-section .filter-button').click({force: true});
  275. cy.wait(300);
  276. cy.get('.filter-popover').should('exist');
  277. cy.get('.filter-popover').then(popover => {
  278. if (popover.find('input.input-with-feedback')[0].value != '') {
  279. has_filter = true;
  280. }
  281. });
  282. cy.get('.filter-popover').find('.clear-filters').click();
  283. cy.get('.filter-section .filter-button').click();
  284. cy.window().its('cur_list').then(cur_list => {
  285. cur_list && cur_list.filter_area && cur_list.filter_area.clear();
  286. has_filter && cy.wait('@filter-saved');
  287. });
  288. });
  289. Cypress.Commands.add('click_modal_primary_button', (btn_name) => {
  290. cy.get('.modal-footer > .standard-actions > .btn-primary').contains(btn_name).trigger('click', {force: true});
  291. });
  292. Cypress.Commands.add('click_sidebar_button', (btn_name) => {
  293. cy.get('.list-group-by-fields .list-link > a').contains(btn_name).click({force: true});
  294. });
  295. Cypress.Commands.add('click_listview_row_item', (row_no) => {
  296. cy.get('.list-row > .level-left > .list-subject > .level-item > .ellipsis').eq(row_no).click({force: true});
  297. });
  298. Cypress.Commands.add('click_filter_button', () => {
  299. cy.get('.filter-selector > .btn').click();
  300. });
  301. Cypress.Commands.add('click_listview_primary_button', (btn_name) => {
  302. cy.get('.primary-action').contains(btn_name).click({force: true});
  303. });
  304. Cypress.Commands.add('click_timeline_action_btn', (btn_name) => {
  305. cy.get('.timeline-message-box .actions .action-btn').contains(btn_name).click();
  306. });
  307. Cypress.Commands.add('select_listview_row_checkbox', (row_no) => {
  308. cy.get('.frappe-list .select-like > .list-row-checkbox').eq(row_no).click();
  309. });