@eox/drawtools 0.6.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,25 +7,21 @@ const { drawTools, controller, drawBtn } = TEST_SELECTORS;
7
7
  * Clicks the draw button and verifies the 'drawing' state.
8
8
  */
9
9
  const clickDrawBtnTest = () => {
10
- it("clicks the draw button", () => {
11
- cy.get(drawTools)
12
- .shadow()
13
- .within(() => {
14
- cy.get(controller)
15
- .shadow()
16
- .within(() => {
17
- // Verify the initial state of the draw button
18
- cy.get(drawBtn).contains("draw");
19
- cy.get(drawBtn).should("not.contain", "drawing");
10
+ cy.get(drawTools)
11
+ .shadow()
12
+ .within(() => {
13
+ cy.get(controller).within(() => {
14
+ // Verify the initial state of the draw button
15
+ cy.get(drawBtn).contains("draw");
16
+ cy.get(drawBtn).should("not.contain", "drawing");
20
17
 
21
- // Click the draw button and verify the 'drawing' state
22
- cy.get(drawBtn).click();
23
- cy.get(drawBtn).contains("drawing");
24
- });
18
+ // Click the draw button and verify the 'drawing' state
19
+ cy.get(drawBtn).click();
20
+ cy.get(drawBtn).contains("drawing");
25
21
  });
22
+ });
26
23
 
27
- // TODO: Simulate drawing and add drawn features (not implemented in the current test)
28
- });
24
+ // TODO: Simulate drawing and add drawn features (not implemented in the current test)
29
25
  };
30
26
 
31
27
  export default clickDrawBtnTest;
@@ -0,0 +1,37 @@
1
+ import { DUMMY_GEO_JSON, TEST_SELECTORS } from "../../src/enums";
2
+
3
+ Cypress.Commands.add("getClipboardText", () => {
4
+ return cy.window().then((win) => {
5
+ return win.navigator.clipboard.readText();
6
+ });
7
+ });
8
+
9
+ // Destructure TEST_SELECTORS object
10
+ const { drawTools, controller, copyBtn } = TEST_SELECTORS;
11
+
12
+ /**
13
+ * Check valid geo-json present in the clipboard after copying
14
+ */
15
+ const copyGeoJsonEditorTest = () => {
16
+ cy.get(drawTools)
17
+ .shadow()
18
+ .within(() => {
19
+ cy.get(controller).within(() => {
20
+ cy.window().then((win) => {
21
+ cy.stub(win.navigator.clipboard, "writeText").resolves();
22
+ });
23
+
24
+ // Click copy button in geo json editor
25
+ cy.get(copyBtn).click();
26
+
27
+ // Check whether the copied json matches with `DUMMY_GEO_JSON`
28
+ cy.window().then((win) => {
29
+ expect(win.navigator.clipboard.writeText).to.be.calledWith(
30
+ JSON.stringify(DUMMY_GEO_JSON, undefined, 2)
31
+ );
32
+ });
33
+ });
34
+ });
35
+ };
36
+
37
+ export default copyGeoJsonEditorTest;
@@ -3,3 +3,4 @@
3
3
  export { default as clickDiscardBtnTest } from "./click-discard-btn"; // Test for clicking the discard button
4
4
  export { default as clickDrawBtnTest } from "./click-draw-btn"; // Test for clicking the draw button
5
5
  export { default as loadDrawToolsTest } from "./load-drawtool"; // Test for loading the drawtools component
6
+ export { default as copyGeoJsonEditorTest } from "./copy-geo-json-editor"; // Test to check whether a valid geo-json present in the clipboard
@@ -7,10 +7,8 @@ const { drawTools } = TEST_SELECTORS;
7
7
  * Test to verify if the drawtools component loads successfully.
8
8
  */
9
9
  const loadDrawToolsTest = () => {
10
- it("loads the drawtools", () => {
11
- // Find the drawTools element and access its shadow DOM
12
- cy.get(drawTools).shadow();
13
- });
10
+ // Find the drawTools element and access its shadow DOM
11
+ cy.get(drawTools).shadow();
14
12
  };
15
13
 
16
14
  export default loadDrawToolsTest;
@@ -4,6 +4,7 @@ import "./_mockMap";
4
4
  import {
5
5
  clickDiscardBtnTest,
6
6
  clickDrawBtnTest,
7
+ copyGeoJsonEditorTest,
7
8
  loadDrawToolsTest,
8
9
  } from "./cases";
9
10
  import { TEST_SELECTORS } from "../src/enums";
@@ -17,7 +18,9 @@ describe("Drawtools", () => {
17
18
  beforeEach(() => {
18
19
  // Mounting mock-map and eox-drawtools elements
19
20
  cy.mount("<mock-map></mock-map>").as("mock-map");
20
- cy.mount(`<eox-drawtools for="mock-map"></eox-drawtools>`).as(drawTools);
21
+ cy.mount(
22
+ `<eox-drawtools show-editor import-features for="mock-map"></eox-drawtools>`
23
+ ).as(drawTools);
21
24
  });
22
25
 
23
26
  // Test case to ensure the drawtools component loads successfully
@@ -29,4 +32,8 @@ describe("Drawtools", () => {
29
32
  // Test case to simulate clicking the discard button and clearing drawn features
30
33
  it("clicks the discard button and clears drawn features", () =>
31
34
  clickDiscardBtnTest());
35
+
36
+ // Test case to check whether a valid geo-json present in the clipboard
37
+ it("check valid geo-json present in the clipboard.", () =>
38
+ copyGeoJsonEditorTest());
32
39
  });