@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.
- package/dist/eox-drawtools.js +544 -516
- package/dist/eox-drawtools.umd.cjs +142 -221
- package/package.json +4 -4
- package/test/_mockMap.js +3 -0
- package/test/cases/click-discard-btn.js +14 -18
- package/test/cases/click-draw-btn.js +12 -16
- package/test/cases/copy-geo-json-editor.js +37 -0
- package/test/cases/index.js +1 -0
- package/test/cases/load-drawtool.js +2 -4
- package/test/general.cy.js +8 -1
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.within(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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;
|
package/test/cases/index.js
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
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;
|
package/test/general.cy.js
CHANGED
|
@@ -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(
|
|
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
|
});
|