region-index.cy.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { Labels, LabelStudio, Relations, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
  2. import { FF_DEV_3873 } from "../../../../src/utils/feature-flags";
  3. import {
  4. labelStudio_settings,
  5. panelState,
  6. resultWithRelations,
  7. simpleConfig,
  8. simpleData,
  9. } from "../../data/outliner/region-index";
  10. import { RichText } from "@humansignal/frontend-test/helpers/LSF/RichText";
  11. import { Hotkeys } from "@humansignal/frontend-test/helpers/LSF/Hotkeys";
  12. describe("Region Index", () => {
  13. beforeEach(() => {
  14. LabelStudio.addFeatureFlagsOnPageLoad({
  15. [FF_DEV_3873]: true,
  16. });
  17. });
  18. it("should be visible at the outliner", () => {
  19. LabelStudio.params().config(simpleConfig).data(simpleData).withResult(resultWithRelations).init();
  20. LabelStudio.waitForObjectsReady();
  21. Sidebar.findByRegionIndex(1).should("contain", "Label 1");
  22. Sidebar.findByRegionIndex(3).should("contain", "Label 3");
  23. });
  24. it("should depends on the order of the regions", () => {
  25. LabelStudio.params().config(simpleConfig).data(simpleData).withResult(resultWithRelations).init();
  26. LabelStudio.waitForObjectsReady();
  27. Sidebar.toggleOrderByTime();
  28. Sidebar.findByRegionIndex(1).should("contain", "Label 3");
  29. Sidebar.findByRegionIndex(3).should("contain", "Label 1");
  30. });
  31. it("should affect the labels on region on changing order", () => {
  32. LabelStudio.params()
  33. .config(simpleConfig)
  34. .data(simpleData)
  35. .withResult(resultWithRelations)
  36. .withLocalStorageItem("labelStudio:settings", labelStudio_settings)
  37. .init();
  38. LabelStudio.waitForObjectsReady();
  39. Sidebar.toggleOrderByTime();
  40. RichText.hasRegionWithLabel("1:Label 3");
  41. RichText.hasRegionWithLabel("2:Label 2");
  42. RichText.hasRegionWithLabel("3:Label 1");
  43. });
  44. it("should be displayed in region's label", () => {
  45. LabelStudio.params()
  46. .config(simpleConfig)
  47. .data(simpleData)
  48. .withResult(resultWithRelations)
  49. .localStorageItems({
  50. "labelStudio:settings": labelStudio_settings,
  51. })
  52. .init();
  53. RichText.hasRegionWithLabel("1:Label 1");
  54. RichText.hasRegionWithLabel("2:Label 2");
  55. RichText.hasRegionWithLabel("3:Label 3");
  56. });
  57. it("should not depend on the visibility of the region panel", () => {
  58. LabelStudio.params()
  59. .config(simpleConfig)
  60. .data(simpleData)
  61. .withResult(resultWithRelations)
  62. .localStorageItems({
  63. panelState,
  64. "labelStudio:settings": labelStudio_settings,
  65. })
  66. .init();
  67. LabelStudio.waitForObjectsReady();
  68. RichText.hasRegionWithLabel("1:Label 1");
  69. RichText.hasRegionWithLabel("2:Label 2");
  70. RichText.hasRegionWithLabel("3:Label 3");
  71. });
  72. it("should be displayed on relations panel", () => {
  73. LabelStudio.params()
  74. .config(simpleConfig)
  75. .data(simpleData)
  76. .withResult(resultWithRelations)
  77. .localStorageItems({
  78. panelState,
  79. "labelStudio:settings": labelStudio_settings,
  80. })
  81. .init();
  82. LabelStudio.waitForObjectsReady();
  83. Relations.relationRegions.eq(0).contains(".lsf-detailed-region__index", "1").should("exist");
  84. Relations.relationRegions.eq(1).contains(".lsf-detailed-region__index", "3").should("exist");
  85. });
  86. it("should be consistent on region delete / create", () => {
  87. LabelStudio.params()
  88. .config(simpleConfig)
  89. .data(simpleData)
  90. .withResult(resultWithRelations)
  91. .localStorageItems({
  92. panelState,
  93. "labelStudio:settings": labelStudio_settings,
  94. })
  95. .init();
  96. LabelStudio.waitForObjectsReady();
  97. RichText.hasRegionWithLabel("1:Label 1");
  98. RichText.hasRegionWithLabel("2:Label 2");
  99. RichText.hasRegionWithLabel("3:Label 3");
  100. RichText.findRegionWithLabel("2:Label 2").trigger("click");
  101. Hotkeys.deleteRegion();
  102. RichText.hasRegionWithLabel("1:Label 1");
  103. RichText.hasRegionWithLabel("2:Label 3");
  104. Labels.select("Label 2");
  105. RichText.selectText("is");
  106. RichText.hasRegionWithLabel("3:Label 2");
  107. });
  108. it("should be consistent on region delete / create with full list affected by change", () => {
  109. LabelStudio.params()
  110. .config(simpleConfig)
  111. .data(simpleData)
  112. .withResult(resultWithRelations)
  113. .localStorageItems({
  114. panelState,
  115. "labelStudio:settings": labelStudio_settings,
  116. "outliner:sort": "date",
  117. "outliner:sort-direction": "desc",
  118. })
  119. .init();
  120. LabelStudio.waitForObjectsReady();
  121. RichText.hasRegionWithLabel("3:Label 1");
  122. RichText.hasRegionWithLabel("2:Label 2");
  123. RichText.hasRegionWithLabel("1:Label 3");
  124. RichText.findRegionWithLabel("2:Label 2").trigger("click");
  125. Hotkeys.deleteRegion();
  126. RichText.hasRegionWithLabel("2:Label 1");
  127. RichText.hasRegionWithLabel("1:Label 3");
  128. Labels.select("Label 2");
  129. RichText.selectText("is");
  130. RichText.hasRegionWithLabel("3:Label 1");
  131. RichText.hasRegionWithLabel("2:Label 3");
  132. RichText.hasRegionWithLabel("1:Label 2");
  133. });
  134. it("should work with history traveling", () => {
  135. LabelStudio.params()
  136. .config(simpleConfig)
  137. .data(simpleData)
  138. .withResult(resultWithRelations)
  139. .localStorageItems({
  140. "labelStudio:settings": labelStudio_settings,
  141. })
  142. .init();
  143. LabelStudio.waitForObjectsReady();
  144. RichText.findRegionWithLabel("2:Label 2").trigger("click");
  145. Hotkeys.deleteRegion();
  146. cy.wait(1);
  147. Hotkeys.undo();
  148. cy.wait(1);
  149. Hotkeys.redo();
  150. });
  151. });