From c7a94996b4405c71a3a00a0f28b7850e1eb375a9 Mon Sep 17 00:00:00 2001 From: Necla Akalin Date: Mon, 16 Dec 2024 16:53:37 +0000 Subject: [PATCH] adding some tests --- src/browser/components/ManualLink.test.tsx | 10 ++++++++++ .../components/VersionConditionalDoc.test.tsx | 16 ++++++++++++++++ src/browser/modules/Sidebar/docsUtils.test.ts | 4 +++- .../modules/Sidebar/static-scripts.test.tsx | 14 ++++++++++++-- .../modules/features/featureDuck.utils.test.ts | 6 +++++- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/browser/components/ManualLink.test.tsx b/src/browser/components/ManualLink.test.tsx index 8f92848fc46..3926b434294 100644 --- a/src/browser/components/ManualLink.test.tsx +++ b/src/browser/components/ManualLink.test.tsx @@ -109,6 +109,16 @@ const movedPages: [ text: 'Indexes', url: 'https://neo4j.com/docs/cypher-manual/4.3/indexes-for-search-performance/' } + ], + [ + { + neo4jVersion: '2025.01.0', + page: '/administration/indexes-for-search-performance/' + }, + { + text: 'Indexes', + url: 'https://neo4j.com/docs/cypher-manual/current/indexes-for-search-performance/' + } ] ] diff --git a/src/browser/components/VersionConditionalDoc.test.tsx b/src/browser/components/VersionConditionalDoc.test.tsx index a7f89308f3b..0c8c135f399 100644 --- a/src/browser/components/VersionConditionalDoc.test.tsx +++ b/src/browser/components/VersionConditionalDoc.test.tsx @@ -46,6 +46,22 @@ const tests: [Omit, boolean][] = [ includeCurrent: false }, true + ], + [ + { + neo4jVersion: '2025.03.0', + versionCondition: '>=4.3', + includeCurrent: false + }, + true + ], + [ + { + neo4jVersion: '2025.03.0', + versionCondition: '<4.3', + includeCurrent: true + }, + false ] ] diff --git a/src/browser/modules/Sidebar/docsUtils.test.ts b/src/browser/modules/Sidebar/docsUtils.test.ts index 91abc10f671..77caf939216 100644 --- a/src/browser/modules/Sidebar/docsUtils.test.ts +++ b/src/browser/modules/Sidebar/docsUtils.test.ts @@ -26,7 +26,9 @@ test('formatDocVersion', () => { { test: '1.1.0', expect: '1.1' }, { test: '1.1.0-beta01', expect: '1.1-preview' }, { test: '1.1.2', expect: '1.1' }, - { test: '2.1.10', expect: '2.1' } + { test: '2.1.10', expect: '2.1' }, + { test: '2025.01.0', expect: 'current' }, + { test: '2024.11.10', expect: 'current' } ] tests.forEach(t => expect(formatDocVersion(t.test)).toEqual(t.expect)) diff --git a/src/browser/modules/Sidebar/static-scripts.test.tsx b/src/browser/modules/Sidebar/static-scripts.test.tsx index f19185539bb..401218a37d6 100644 --- a/src/browser/modules/Sidebar/static-scripts.test.tsx +++ b/src/browser/modules/Sidebar/static-scripts.test.tsx @@ -35,8 +35,8 @@ describe('', () => { content: !script.content.includes('Show meta-graph') ? script.content : script.versionRange === '>=3 <4' - ? script.content.replace('Show meta-graph', 'Show meta-graph v3') - : script.content.replace('Show meta-graph', 'Show meta-graph v4') + ? script.content.replace('Show meta-graph', 'Show meta-graph v3') + : script.content.replace('Show meta-graph', 'Show meta-graph v4') })) const renderWithDBMSVersion = (version: any) => { @@ -83,4 +83,14 @@ describe('', () => { expect(queryByText('Show meta-graph v3')).toBeFalsy() expect(queryByText('Show meta-graph v4')).toBeTruthy() }) + + it('lists examples correctly when using calendar version', () => { + const version = '2025.01.0' + const { queryByText } = renderWithDBMSVersion(version) + + fireEvent.click(queryByText('Common Procedures') as HTMLElement) + + expect(queryByText('Show meta-graph v3')).toBeFalsy() + expect(queryByText('Show meta-graph v4')).toBeTruthy() + }) }) diff --git a/src/shared/modules/features/featureDuck.utils.test.ts b/src/shared/modules/features/featureDuck.utils.test.ts index 375fdcc5253..d90fbc26122 100644 --- a/src/shared/modules/features/featureDuck.utils.test.ts +++ b/src/shared/modules/features/featureDuck.utils.test.ts @@ -29,7 +29,11 @@ describe('guessSemverVersion', () => { ['3.5.3', '3.5.3'], ['3.5', '3.5.0'], ['3.5-test', '3.5.0'], - ['4.0-aura', '4.0.0'] + ['4.0-aura', '4.0.0'], + ['2025.01.0', '2025.1.0'], + ['2025.07.15-1242', '2025.7.15-1242'], + ['2025.12.1', '2025.12.1'], + ['2025.1.1', '2025.1.1'] ] test.each(tests)(