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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. context("Realtime updates", () => {
  2. before(() => {
  3. cy.login();
  4. });
  5. beforeEach(() => {
  6. cy.visit("/app/todo");
  7. // required because immediately after load socket is still connecting.
  8. // Not a huge deal breaker in prod.
  9. cy.wait(500);
  10. cy.clear_filters();
  11. });
  12. it("Shows version conflict warning", { scrollBehavior: false }, () => {
  13. cy.insert_doc("ToDo", { description: "old" }).then((doc) => {
  14. cy.visit(`/app/todo/${doc.name}`);
  15. // make form dirty
  16. cy.fill_field("status", "Cancelled", "Select");
  17. // update doc using api - simulating parallel change by another user
  18. cy.update_doc("ToDo", doc.name, { status: "Closed" }).then(() => {
  19. cy.findByRole("button", { name: "Refresh" }).click();
  20. cy.get_field("status", "Select").should("have.value", "Closed");
  21. });
  22. });
  23. });
  24. it("List view updates in realtime on insert", { scrollBehavior: false }, () => {
  25. const original = "Added for realtime update";
  26. const updated = "Updated for realtime update";
  27. cy.insert_doc("ToDo", { description: original }).then((doc) => {
  28. cy.contains(original).should("be.visible");
  29. // update doc using api - simulating parallel change by another user
  30. cy.update_doc("ToDo", doc.name, { description: updated }).then(() => {
  31. cy.contains(updated).should("be.visible");
  32. });
  33. });
  34. });
  35. it("Receives msgprint from server", { scrollBehavior: false }, () => {
  36. // required because immediately after load socket is still connecting.
  37. // Not a deal breaker in prod
  38. const msg = "msgprint sent via realtime";
  39. publish_realtime({ event: "msgprint", message: msg }).then(() => {
  40. cy.contains(msg).should("be.visible");
  41. });
  42. });
  43. it("Recieves custom messages from server", { scrollBehavior: false }, () => {
  44. const event = "cypress_event";
  45. let handler = {
  46. handle() {
  47. console.log("clear");
  48. },
  49. };
  50. cy.spy(handler, "handle").as("callback");
  51. cy.window()
  52. .its("xhiveframework")
  53. .then((xhiveframework) => {
  54. xhiveframework.realtime.on(event, () => handler.handle());
  55. });
  56. publish_realtime({ event }).then(() => {
  57. cy.get("@callback").should("be.called");
  58. });
  59. });
  60. it("Progress bar", { scrollBehavior: false }, () => {
  61. const title = "RealTime Progress";
  62. cy.call("xhiveframework.tests.ui_test_helpers.publish_progress", { title }).then(() => {
  63. cy.contains(title).should("be.visible");
  64. });
  65. });
  66. });
  67. function publish_realtime(args) {
  68. return cy.call("xhiveframework.tests.ui_test_helpers.publish_realtime", args);
  69. }