Laurent Nguyen bcd8b7229f
Upgrade typescript to 4.9.5 and jest to 29.7.0 (and related packages) (#1884)
* Upgrade typescript to 4.9.5

* Fix compile issue and put back files in tsconfig.strict.json

* Update test snapshots

* Fix jest tests by upgrading jest and other related packages.

* Attempt to fix playwright test

* Revert "Attempt to fix playwright test"

This reverts commit 8293f34c9ce3901eb160a56526c59e3d3e1e343e.

* 2nd attempt to fix example test

* fix waitFor in playwright

* Remove unused describe section

* Attempt to fix e2e test

* Revert "Attempt to fix e2e test"

This reverts commit 9745bcd2efccf92e33e62e4563349cb76e6236de.

* Upgrade playwright to latest

* Revert "Upgrade playwright to latest"

This reverts commit e2ea1d01895f9db157a92a5167a7865b7cc43266.

* Error test on e2e

* Revert "Error test on e2e"

This reverts commit 124e3764f72fff70df9cc1a2e93d12faa7b507e9.

* Try to select dropdown item by xpath selector

* Revert "Try to select dropdown item by xpath selector"

This reverts commit 8eb42a64e23cee589a7c0a809c039ecc7867b7ba.

* Attempt to wait until page is fully loaded

* Revert "Attempt to wait until page is fully loaded"

This reverts commit bb43fcea6e71e593f7d1a3e374e9f1d57052ab70.

* Use playwright selectOption to select dropdown option

* Revert "Use playwright selectOption to select dropdown option"

This reverts commit daa8cd09304f68093df2d94f4bd1139cb367465a.

* Select dropdown option with playwright api instead of manual click

* c7ab4c7ecf7b05f32a85568bce1a667ad8c62703Revert "Select dropdown option with playwright api instead of manual click"

This reverts commit c7ab4c7ecf7b05f32a85568bce1a667ad8c62703.

* Wait for 5s after dropdown click

* Revert "Wait for 5s after dropdown click"

This reverts commit 847e9ad33fbfac99a947fc088e1c8c1c14c57853.

* Try forcing click

* Revert "Try forcing click"

This reverts commit 29b9fa1bda18dd3aba7853b20c6215d971bc826a.

* Force click on the dropdown and set viewport size bigger.

* Force click on the dropdown and set viewport size bigger.

* try force clicking option

* Skip container test on webkit

* Add branded browsers to e2e tests

---------

Co-authored-by: Ashley Stanton-Nurse <ashleyst@microsoft.com>
2024-07-30 15:41:41 -07:00

113 lines
3.0 KiB
TypeScript

import { GraphData, GremlinEdge, GremlinVertex } from "./GraphData";
describe("Graph Data", () => {
it("should set only one node as root", () => {
const graphData = new GraphData<GremlinVertex, GremlinEdge>();
const v1: GremlinVertex = { id: "1", label: null };
const v2: GremlinVertex = { id: "2", label: null };
const v3: GremlinVertex = { id: "3", label: null };
v3._isRoot = true;
graphData.addVertex(v1);
graphData.addVertex(v2);
graphData.addVertex(v3);
graphData.setAsRoot("2");
graphData.setAsRoot("1");
// Count occurences of roots
const roots = graphData.vertices.filter((v: any) => {
return v._isRoot;
});
expect(roots.length).toBe(1);
expect(graphData.getVertexById("1")._isRoot).toBeDefined();
expect(graphData.getVertexById("2")._isRoot).not.toBeDefined();
expect(graphData.getVertexById("3")._isRoot).not.toBeDefined();
});
it("should properly find root id", () => {
const graphData = new GraphData();
const v1: GremlinVertex = { id: "1", label: null };
const v2: GremlinVertex = { id: "2", label: null };
const v3: GremlinVertex = { id: "3", label: null };
graphData.addVertex(v1);
graphData.addVertex(v2);
graphData.addVertex(v3);
graphData.setAsRoot("1");
expect(graphData.findRootNodeId()).toBe("1");
});
it("should remove edge from graph", () => {
const graphData = new GraphData();
graphData.addVertex({ id: "v1", label: null });
graphData.addVertex({ id: "v2", label: null });
graphData.addVertex({ id: "v3", label: null });
graphData.addEdge({ id: "e1", inV: "v1", outV: "v2", label: null });
graphData.addEdge({ id: "e2", inV: "v1", outV: "v3", label: null });
// in edge
graphData.removeEdge("e1", false);
expect(graphData.edges.length).toBe(1);
expect(graphData).not.toContainEqual({ id: "e1" });
// out edge
graphData.removeEdge("e2", false);
expect(graphData.edges.length).toBe(0);
expect(graphData).not.toContainEqual({ id: "e2" });
});
it("should get string node property", () => {
const stringValue = "blah";
const value = GraphData.getNodePropValue(
{
id: "id",
label: "label",
properties: {
testString: [{ id: "123", value: stringValue }],
},
},
"testString",
);
expect(value).toEqual(stringValue);
});
it("should get number node property", () => {
const numberValue = 2;
const value = GraphData.getNodePropValue(
{
id: "id",
label: "label",
properties: {
testString: [{ id: "123", value: numberValue }],
},
},
"testString",
);
expect(value).toEqual(numberValue);
});
it("should get boolean node property", () => {
const booleanValue = true;
const value = GraphData.getNodePropValue(
{
id: "id",
label: "label",
properties: {
testString: [{ id: "123", value: booleanValue }],
},
},
"testString",
);
expect(value).toEqual(booleanValue);
});
});