From 72f96c0edef5383948bbd0bc9de9a32aa813723f Mon Sep 17 00:00:00 2001 From: Raphael Ferrand Date: Tue, 10 Oct 2023 12:47:45 +0200 Subject: [PATCH] SWED-2230 fix tests topbar & routes --- RELEASE_NOTES.md | 2 + .../Topbar/__snapshots__/index.test.js.snap | 556 ++++++++++++++++-- .../Topbar/__snapshots__/index.test.js.snap | 94 +-- src/App/components/Topbar/index.js | 4 +- src/App/routes/all.test.js | 5 +- src/App/routes/components.test.js | 2 +- 6 files changed, 579 insertions(+), 84 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6cd7e5b03f..250fff9681 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,8 @@ ## Component changes +- Topbar - v2 experimental stage - disabled by default (migration involves breaking changes) + ### Non breaking UI changes - add possibility to disable rotation of the dropdown toggle icon on active state diff --git a/src/App/ComponentsDocumentation/components/Topbar/__snapshots__/index.test.js.snap b/src/App/ComponentsDocumentation/components/Topbar/__snapshots__/index.test.js.snap index 74d557872b..f3f020458d 100644 --- a/src/App/ComponentsDocumentation/components/Topbar/__snapshots__/index.test.js.snap +++ b/src/App/ComponentsDocumentation/components/Topbar/__snapshots__/index.test.js.snap @@ -161,6 +161,8 @@ exports[`Components: Topbar DeveloperDocumentation renders 1`] = ` + + @@ -370,6 +374,12 @@ exports[`Components: Topbar DeveloperDocumentation renders 1`] = ` 31 + 32 + + + 33 + + + + @@ -799,6 +1002,126 @@ exports[`Components: Topbar DeveloperDocumentation renders 1`] = ` 33 + 34 + + + 35 + + + 36 + + + 37 + + + 38 + + + 39 + + + 40 + + + 41 + + + 42 + + + 43 + + + 44 + + + 45 + + + 46 + + + 47 + + + 48 + + + 49 + + + 50 + + + 51 + + + 52 + + + 53 + + + 54 + + + 55 + + + 56 + + + 57 + + + 58 + + + 59 + + + 60 + + + 61 + + + 62 + + + 63 + + + 64 + + + 65 + + + 66 + + + 67 + + + 68 + + + 69 + + + 70 + + + 71 + + + 72 + + + 73 + + +
+

+ Migrating to the new Topbar ( ⚠️experimental🧪 ) +

+

+ A future version of the topbar can be used. It is in experimental state. Things can be modified and depending of your use some features might still be missing. +
+ This is done by appending the class + + + .experimental + + to the element with class + + .topbar + + . +

+

+ There is several breaking changes (details are following lower down) +

+ +

+ To do the migration please follow instructions on + + + the migration page + + . +

+

Javascript methods diff --git a/src/App/components/Topbar/__snapshots__/index.test.js.snap b/src/App/components/Topbar/__snapshots__/index.test.js.snap index 977b968290..58ab8135de 100644 --- a/src/App/components/Topbar/__snapshots__/index.test.js.snap +++ b/src/App/components/Topbar/__snapshots__/index.test.js.snap @@ -113,6 +113,8 @@ exports[`Component: Topbar - props topbarContent renders a sidebar in topbar-lin + + @@ -580,6 +584,8 @@ exports[`Component: Topbar - props topbarContent renders a topbar menu without m + + @@ -709,6 +711,8 @@ exports[`Component: Topbar - props topbarContent renders a topbar menuopen and c + + @@ -853,6 +859,8 @@ exports[`Component: Topbar - props topbarContent renders topbar-link-container a + + @@ -1019,6 +1029,8 @@ exports[`Component: Topbar - props topbarContent renders topbar-link-container a + + diff --git a/src/App/components/Topbar/index.js b/src/App/components/Topbar/index.js index da172ee6e9..d020b39dc9 100644 --- a/src/App/components/Topbar/index.js +++ b/src/App/components/Topbar/index.js @@ -242,8 +242,8 @@ const Topbar = ({ ) : ( <> - - {logout ? : null} + + {logout ? legacy ? : : null} )} diff --git a/src/App/routes/all.test.js b/src/App/routes/all.test.js index b18797a44c..4a63007d87 100644 --- a/src/App/routes/all.test.js +++ b/src/App/routes/all.test.js @@ -1,7 +1,10 @@ import allRoutes from "./all"; describe("Routes: all", () => { - const pathFormat = new RegExp("^([a-z]+([-a-z]+)?)+$"); + // match any string that starts with a lowercase letter, + // followed by zero or more lowercase letters or digits, + // followed by an optional hyphen and one or more lowercase letters or digits + const pathFormat = new RegExp("^[a-z][a-z0-9]*([-a-z0-9]+)?$"); it("is defined", () => { expect(allRoutes).toBeDefined(); diff --git a/src/App/routes/components.test.js b/src/App/routes/components.test.js index 55c30f748e..234318b90a 100644 --- a/src/App/routes/components.test.js +++ b/src/App/routes/components.test.js @@ -1,7 +1,7 @@ import componentRoutes from "./components"; describe("Routes: components", () => { - const pathFormat = new RegExp("^([a-z]+([-a-z]+)?)+$"); + const pathFormat = new RegExp("^[a-z][a-z0-9]*([-a-z0-9]+)?$"); it("is defined", () => { expect(componentRoutes).toBeDefined();