From 74c5ba996efef256d563d1b5af06f4cd1f10dff0 Mon Sep 17 00:00:00 2001 From: Elton Sanchez <3165000+sanchezelton@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:32:14 -0700 Subject: [PATCH] main pulled into end-to-end-tests - updated lock file - removed unneeded untypedFn module (and parent folder) and contained waitForEvent fn - added Array check on options.layers[layer].nodeThresholds.steps in MapPanel.resolveNodeThresholds to remove warning in Grafana --- e2e/js/untypedFn.js | 4 ---- e2e/plugin.spec.ts | 17 +++++++++++------ src/MapPanel.tsx | 14 ++++++++------ yarn.lock | 39 ++++++++++++++++++++++++++++++++------- 4 files changed, 51 insertions(+), 23 deletions(-) delete mode 100644 e2e/js/untypedFn.js diff --git a/e2e/js/untypedFn.js b/e2e/js/untypedFn.js deleted file mode 100644 index ff66fa2..0000000 --- a/e2e/js/untypedFn.js +++ /dev/null @@ -1,4 +0,0 @@ - -export const waitForEvent = async (pageInstance, eventName, optionsOrPredicate) => { - return pageInstance.waitForEvent(eventName, optionsOrPredicate); -}; diff --git a/e2e/plugin.spec.ts b/e2e/plugin.spec.ts index 1a48372..32fd95c 100644 --- a/e2e/plugin.spec.ts +++ b/e2e/plugin.spec.ts @@ -14,7 +14,6 @@ import { clearInterval } from 'timers'; import { IFlowSheet } from '../src/types'; import { IThreshold } from './interfaces/Threshold.interface'; import { reverseStr } from '../test/utils'; -import { waitForEvent } from './js/untypedFn'; const PubSub = pubsub.PubSub; @@ -56,8 +55,10 @@ const getCheckStrokeColorFn = (page: Page) => { let edgeCount = edgeNames.length; for (const testEdge of edgeNames) { console.log(`Test Edge: ${testEdge}`); - const edgeLocator: Locator = await page.locator(`.edge > path[text="${testEdge}"]`); - await expect(edgeLocator).toHaveCSS('stroke', colorNameMatcher ?? BasicColorMatcher.GREY); + const edgeLocator: Locator = await page.locator(`.topology > path[class*="edge-az-${testEdge}"]`); + if ((await edgeLocator.all()).length > 0) { + await expect(edgeLocator).toHaveCSS('stroke', colorNameMatcher ?? BasicColorMatcher.GREY); + } } // control paths in orange (always orange, but may not visible depending on enable/disable edge edit mode) @@ -334,10 +335,12 @@ pluginTest.describe("plugin testing", () => { await expect(layer1DefaultColorDropdownSelected).toMatch(BasicColorMatcher.GREY); const topologyNodes = ['A', 'B', 'C']; + // generate all directional edges from topologyNodes const testEdges = topologyNodes.reduce((acc: string[], outNode: string) => { for (const inNode of topologyNodes) { if (inNode !== outNode) { acc.push(`${inNode}--${outNode}`); + acc.push(`${outNode}--${inNode}`); } } return acc; @@ -350,10 +353,11 @@ pluginTest.describe("plugin testing", () => { // step 1: trigger elements to fetch config remote url containing 'normal' topology // enable fetching - const fetchConfigSlideButton = await page.locator('[id="Network Map Panel"] > div > div:nth-child(2) > div label').first(); + const fetchConfigSlideButton = await page.locator('[id="Network Map Panel"] > div > div:nth-child(2) [class*="select-value-container"]').first(); + console.log(`step1: ${(await fetchConfigSlideButton.all()).length}`); await fetchConfigSlideButton.click(); // provide URL - const fetchConfigUrlField = await page.locator('[id="Network Map Panel"]').getByRole('textbox').first(); + const fetchConfigUrlField = await page.locator('[id="Network Map Panel"]').getByRole('combobox').first(); await fetchConfigUrlField.fill(topologyUrl); // trigger the load let hasCompletedMapRender = false; @@ -377,7 +381,8 @@ pluginTest.describe("plugin testing", () => { }, this); makeRenderPromise(); // trigger render - await page.locator('[id="Network Map Panel"]').first().click(); + // await page.locator('[id="Network Map Panel"]').click(); + await fetchConfigUrlField.blur(); // check stroke colors with remotely loaded topology (should populate selected color control) // TODO: @esanchez confer w/ @jkadafer WRT to use case where a choice color is made but a remote URL removes the color control diff --git a/src/MapPanel.tsx b/src/MapPanel.tsx index 6cec596..63651b8 100644 --- a/src/MapPanel.tsx +++ b/src/MapPanel.tsx @@ -187,12 +187,14 @@ class MapPanel extends Component { for(let layer=0; layer{ - layerThresholds.push({ - color: this.theme.visualization.getColorByName(step.color), - value: step.value || 0, - }) - }) + if (Array.isArray(options.layers[layer]?.nodeThresholds?.steps)) { + options.layers[layer]?.nodeThresholds?.steps.forEach((step)=>{ + layerThresholds.push({ + color: this.theme.visualization.getColorByName(step.color), + value: step.value || 0, + }); + }); + } thresholds.push(layerThresholds); } // snapshot the current options. If they're not the same as the last options, update them. diff --git a/yarn.lock b/yarn.lock index 8314324..2bc1b3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10363,7 +10363,16 @@ string-template@~0.2.1: resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add" integrity sha512-Yptehjogou2xm4UJbxJ4CxgZx12HBfeystp0y3x7s4Dj32ltVVG1Gg8YhKjHZkHicuKpZX/ffilA8505VbUbpw== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -10452,7 +10461,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -10990,10 +11006,10 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -underscore@1.13.7: - version "1.13.7" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.7.tgz#970e33963af9a7dda228f17ebe8399e5fbe63a10" - integrity sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g== +underscore@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209" + integrity sha512-cp0oQQyZhUM1kpJDLdGO1jPZHgS/MpzoWYfe9+CM2h/QGDZlqwT2T3YGukuBdaNJ/CAPoeyAZRRHz8JFo176vA== undici-types@~6.19.2: version "6.19.8" @@ -11394,7 +11410,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -11412,6 +11428,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"