Skip to content

Commit b4cae5e

Browse files
authored
Merge pull request #277 from jadecarino/iss2434-remove-exp-feat-flag
Iss2434 - Remove 'Test Runs' from experimental features
2 parents c738b49 + 0a10843 commit b4cae5e

12 files changed

Lines changed: 103 additions & 84 deletions

File tree

galasa-ui/messages/de.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"title": "Experimentelle Funktionen",
3131
"description": "Früher Zugriff auf neue Funktionen. Diese Funktionen sind experimentell und können sich ändern oder entfernt werden.",
3232
"features": {
33-
"testRunSearch": "Testlauf-Suche und Anzeige",
3433
"graph": "Testlauf-Diagramm"
3534
}
3635
},

galasa-ui/messages/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"title": "Experimental Features",
3131
"description": "Early access to new features. These are experimental and subject to change or removal.",
3232
"features": {
33-
"testRunSearch": "Test Run searching and viewing",
3433
"graph": "Test Run Graphs"
3534
}
3635
},

galasa-ui/src/components/headers/GalasaMenuItems.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@
66
'use client';
77

88
import { HeaderMenuItem } from '@carbon/react';
9-
import { useFeatureFlags } from '@/contexts/FeatureFlagContext';
10-
import { FEATURE_FLAGS } from '@/utils/featureFlags';
119
import { useTranslations } from 'next-intl';
1210

1311
export default function GalasaMenuItems() {
14-
const { isFeatureEnabled } = useFeatureFlags();
1512
const translations = useTranslations('PageHeader');
1613

1714
return (
1815
<>
1916
<HeaderMenuItem href="/users">{translations('users')}</HeaderMenuItem>
20-
{isFeatureEnabled(FEATURE_FLAGS.TEST_RUNS) && (
21-
<HeaderMenuItem href="/test-runs">{translations('testRuns')}</HeaderMenuItem>
22-
)}
17+
<HeaderMenuItem href="/test-runs">{translations('testRuns')}</HeaderMenuItem>
2318
</>
2419
);
2520
}

galasa-ui/src/components/mysettings/ExperimentalFeaturesSection.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ export default function ExperimentalFeaturesSection() {
1616

1717
// Feature configuration for easier management and display
1818
const featureConfig = [
19-
{
20-
key: FEATURE_FLAGS.TEST_RUNS,
21-
label: translations(`features.testRunSearch`),
22-
},
2319
{
2420
key: FEATURE_FLAGS.GRAPH,
2521
label: translations('features.graph'),

galasa-ui/src/components/mysettings/ResultsTablePageSizeSetting.tsx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,30 @@ import { Dropdown } from '@carbon/react';
1010
import { useTranslations } from 'next-intl';
1111
import styles from '@/styles/mysettings/ResultsTablePageSizingSetting.module.css';
1212
import useResultsTablePageSize from '@/hooks/useResultsTablePageSize';
13-
import { useFeatureFlags } from '@/contexts/FeatureFlagContext';
14-
import { FEATURE_FLAGS } from '@/utils/featureFlags';
1513

1614
export default function ResultsTablePageSizingSetting() {
1715
const translations = useTranslations('ResultsTablePageSizingSetting');
18-
const { isFeatureEnabled } = useFeatureFlags();
1916
const { defaultPageSize, setDefaultPageSize } = useResultsTablePageSize();
2017

2118
return (
2219
<>
23-
{isFeatureEnabled(FEATURE_FLAGS.TEST_RUNS) && (
24-
<section className={styles.section}>
25-
<h3 className={styles.heading}>{translations('title')}</h3>
26-
<div>
27-
<p className={styles.title}>{translations('description')}</p>
28-
<div className={styles.dropdownContainer}>
29-
<p>{translations('defaultTestRunsLabel')}</p>
30-
<Dropdown
31-
data-testid="custom-items-per-page-dropdown-test"
32-
items={RESULTS_TABLE_PAGE_SIZES}
33-
itemToString={(item: number) => item.toString()}
34-
selectedItem={defaultPageSize}
35-
onChange={(e: { selectedItem: number }) => setDefaultPageSize(e.selectedItem)}
36-
size="md"
37-
/>
38-
</div>
20+
<section className={styles.section}>
21+
<h3 className={styles.heading}>{translations('title')}</h3>
22+
<div>
23+
<p className={styles.title}>{translations('description')}</p>
24+
<div className={styles.dropdownContainer}>
25+
<p>{translations('defaultTestRunsLabel')}</p>
26+
<Dropdown
27+
data-testid="custom-items-per-page-dropdown-test"
28+
items={RESULTS_TABLE_PAGE_SIZES}
29+
itemToString={(item: number) => item.toString()}
30+
selectedItem={defaultPageSize}
31+
onChange={(e: { selectedItem: number }) => setDefaultPageSize(e.selectedItem)}
32+
size="md"
33+
/>
3934
</div>
40-
</section>
41-
)}
35+
</div>
36+
</section>
4237
</>
4338
);
4439
}

galasa-ui/src/tests/__snapshots__/layout.test.tsx.snap

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ exports[`Layout renders the web UI layout 1`] = `
9494
</span>
9595
</a>
9696
</li>
97+
<li>
98+
<a
99+
class="cds--header__menu-item"
100+
href="/test-runs"
101+
tabindex="0"
102+
>
103+
<span
104+
class="cds--text-truncate--end"
105+
>
106+
Test runs
107+
</span>
108+
</a>
109+
</li>
97110
</ul>
98111
</nav>
99112
<div
@@ -124,6 +137,19 @@ exports[`Layout renders the web UI layout 1`] = `
124137
</span>
125138
</a>
126139
</li>
140+
<li>
141+
<a
142+
class="cds--header__menu-item"
143+
href="/test-runs"
144+
tabindex="0"
145+
>
146+
<span
147+
class="cds--text-truncate--end"
148+
>
149+
Test runs
150+
</span>
151+
</a>
152+
</li>
127153
</ul>
128154
</ul>
129155
</nav>
@@ -411,6 +437,19 @@ exports[`Layout renders the web UI layout 1`] = `
411437
</span>
412438
</a>
413439
</li>
440+
<li>
441+
<a
442+
class="cds--header__menu-item"
443+
href="/test-runs"
444+
tabindex="0"
445+
>
446+
<span
447+
class="cds--text-truncate--end"
448+
>
449+
Test runs
450+
</span>
451+
</a>
452+
</li>
414453
</ul>
415454
</nav>
416455
<div
@@ -441,6 +480,19 @@ exports[`Layout renders the web UI layout 1`] = `
441480
</span>
442481
</a>
443482
</li>
483+
<li>
484+
<a
485+
class="cds--header__menu-item"
486+
href="/test-runs"
487+
tabindex="0"
488+
>
489+
<span
490+
class="cds--text-truncate--end"
491+
>
492+
Test runs
493+
</span>
494+
</a>
495+
</li>
444496
</ul>
445497
</ul>
446498
</nav>

galasa-ui/src/tests/components/headers/PageHeader.test.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { render, screen } from '@testing-library/react';
77
import PageHeader from '@/components/headers/PageHeader';
88
import { FeatureFlagProvider } from '@/contexts/FeatureFlagContext';
99
import { useRouter } from 'next/navigation';
10-
import { FEATURE_FLAGS } from '@/utils/featureFlags';
1110

1211
const mockRouter = {
1312
push: jest.fn(() => useRouter().push),
@@ -51,26 +50,27 @@ test('renders the header containing the header menu', () => {
5150
expect(headerMenu).toBeInTheDocument();
5251
});
5352

54-
test('does NOT render the "Test runs" link by default', () => {
53+
test('renders the "Test runs" link by default', () => {
5554
render(
5655
<FeatureFlagProvider>
5756
<PageHeader galasaServiceName="Galasa Service" />
5857
</FeatureFlagProvider>
5958
);
6059

61-
const testRunsLink = screen.queryByText('Test runs');
62-
expect(testRunsLink).not.toBeInTheDocument();
63-
});
60+
// Verify "Test runs" link appears in both desktop header nav and mobile side nav
61+
const testRunsLinks = screen.getAllByRole('link', { name: 'Test runs' });
62+
expect(testRunsLinks).toHaveLength(2);
6463

65-
test('renders the "Test runs" link when the feature flag is enabled via prop', () => {
66-
const initialFlags = JSON.stringify({ [FEATURE_FLAGS.TEST_RUNS]: true });
64+
// Both links should point to the correct href
65+
testRunsLinks.forEach((link) => {
66+
expect(link).toHaveAttribute('href', '/test-runs');
67+
});
6768

68-
render(
69-
<FeatureFlagProvider initialFlags={initialFlags}>
70-
<PageHeader galasaServiceName="Galasa Service" />
71-
</FeatureFlagProvider>
72-
);
69+
// Verify one is in the header navigation (desktop)
70+
const headerNav = screen.getByRole('navigation', { name: 'Galasa menu bar navigation' });
71+
expect(headerNav).toContainElement(testRunsLinks[0]);
7372

74-
const testRunsLinks = screen.getAllByText('Test runs');
75-
expect(testRunsLinks.length).toBe(2);
73+
// Verify one is in the side navigation (mobile)
74+
const sideNav = screen.getByRole('navigation', { name: 'Side navigation' });
75+
expect(sideNav).toContainElement(testRunsLinks[1]);
7676
});

galasa-ui/src/tests/components/mysettings/ExperimentalFeaturesSection.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ jest.mock('next-intl', () => ({
1414
title: 'Experimental Features',
1515
description:
1616
'Early access to new features. These are experimental and subject to change or removal.',
17-
'features.testRunSearch': 'Test Run searching and viewing',
17+
'features.graph': 'Test Run Graphs',
1818
};
1919
return translations[key] || key;
2020
},
2121
}));
2222

2323
describe('ExperimentalFeaturesSection', () => {
24-
test('Renders correctly when "testRuns" flag is disabled: Checkbox is unchecked', () => {
25-
const mockIsFeatureEnabled = (key: string) => key !== FEATURE_FLAGS.TEST_RUNS;
24+
test('Renders correctly when "graph" flag is disabled: Checkbox is unchecked', () => {
25+
const mockIsFeatureEnabled = (key: string) => key !== FEATURE_FLAGS.GRAPH;
2626

2727
render(
2828
<FeatureFlagContext.Provider
@@ -32,13 +32,13 @@ describe('ExperimentalFeaturesSection', () => {
3232
</FeatureFlagContext.Provider>
3333
);
3434

35-
const checkbox = screen.getByLabelText(/Test Run/i);
35+
const checkbox = screen.getByLabelText(/Test Run Graphs/i);
3636
expect(checkbox).not.toBeChecked();
3737
});
3838

39-
test('Renders correctly when a "testRuns" enabled: Checkbox is checked', () => {
39+
test('Renders correctly when a "graph" enabled: Checkbox is checked', () => {
4040
const mockIsFeatureEnabled = (key: string) => {
41-
return key === FEATURE_FLAGS.TEST_RUNS;
41+
return key === FEATURE_FLAGS.GRAPH;
4242
};
4343

4444
render(
@@ -48,7 +48,7 @@ describe('ExperimentalFeaturesSection', () => {
4848
<ExperimentalFeaturesSection />
4949
</FeatureFlagContext.Provider>
5050
);
51-
const checkbox = screen.getByLabelText(/Test Run/i);
51+
const checkbox = screen.getByLabelText(/Test Run Graphs/i);
5252
expect(checkbox).toBeChecked();
5353
});
5454

@@ -63,10 +63,10 @@ describe('ExperimentalFeaturesSection', () => {
6363
</FeatureFlagContext.Provider>
6464
);
6565

66-
const checkbox = screen.getByRole('checkbox', { name: /Test Run/i });
66+
const checkbox = screen.getByRole('checkbox', { name: /Test Run Graphs/i });
6767
fireEvent.click(checkbox);
6868

6969
expect(mockToggle).toHaveBeenCalledTimes(1);
70-
expect(mockToggle).toHaveBeenCalledWith(FEATURE_FLAGS.TEST_RUNS);
70+
expect(mockToggle).toHaveBeenCalledWith(FEATURE_FLAGS.GRAPH);
7171
});
7272
});

galasa-ui/src/tests/components/mysettings/ResultsTablePageSizingSetting.test.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,4 @@ describe('ResultsTablePageSizingSetting', () => {
7878
expect(mockSetDefaultPageSize).toHaveBeenCalledWith(50);
7979
});
8080
});
81-
82-
describe('when feature flag is disabled', () => {
83-
beforeEach(() => {
84-
mockIsFeatureEnabled.mockReturnValue(false);
85-
});
86-
87-
test('does not render the component', () => {
88-
render(<ResultsTablePageSizingSetting />);
89-
90-
expect(screen.queryByText('Test Run Query Results')).toBeNull();
91-
expect(screen.queryByText('Configure the number of results displayed per page.')).toBeNull();
92-
expect(screen.queryByTestId('custom-items-per-page-dropdown-test')).toBeNull();
93-
});
94-
});
9581
});

galasa-ui/src/tests/contexts/feature-flag-context.test.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const TestComponent = () => {
1515

1616
return (
1717
<div>
18-
<p>Test Runs Enabled: {isFeatureEnabled(FEATURE_FLAGS.TEST_RUNS).toString()}</p>
19-
<button onClick={() => toggleFeatureFlag(FEATURE_FLAGS.TEST_RUNS)}>Toggle Test Runs</button>
18+
<p>Test Run Graphs Enabled: {isFeatureEnabled(FEATURE_FLAGS.GRAPH).toString()}</p>
19+
<button onClick={() => toggleFeatureFlag(FEATURE_FLAGS.GRAPH)}>Toggle Test Run Graphs</button>
2020
</div>
2121
);
2222
};
@@ -39,42 +39,41 @@ describe('Feature Flags Provider and useFeatureFlags Hook', () => {
3939
<TestComponent />
4040
</FeatureFlagProvider>
4141
);
42-
expect(screen.getByText('Test Runs Enabled: false')).toBeInTheDocument();
42+
expect(screen.getByText('Test Run Graphs Enabled: false')).toBeInTheDocument();
4343
});
4444

4545
test('initializes with provided props from the server', () => {
46-
const initialFlags = JSON.stringify({ [FEATURE_FLAGS.TEST_RUNS]: true });
46+
const initialFlags = JSON.stringify({ [FEATURE_FLAGS.GRAPH]: true });
4747
render(
4848
<FeatureFlagProvider initialFlags={initialFlags}>
4949
<TestComponent />
5050
</FeatureFlagProvider>
5151
);
5252

53-
expect(screen.getByText('Test Runs Enabled: true')).toBeInTheDocument();
53+
expect(screen.getByText('Test Run Graphs Enabled: true')).toBeInTheDocument();
5454
});
5555

5656
test('verifies feature flag toggling and updates cookie correctly', () => {
57-
const initialFlags = JSON.stringify({ [FEATURE_FLAGS.TEST_RUNS]: false });
57+
const initialFlags = JSON.stringify({ [FEATURE_FLAGS.GRAPH]: false });
5858
render(
5959
<FeatureFlagProvider initialFlags={initialFlags}>
6060
<TestComponent />
6161
</FeatureFlagProvider>
6262
);
6363

64-
expect(screen.getByText('Test Runs Enabled: false')).toBeInTheDocument();
64+
expect(screen.getByText('Test Run Graphs Enabled: false')).toBeInTheDocument();
6565

6666
// Due to React's strict mode
6767
cookieSpy.mockClear();
6868

69-
const toggleButton = screen.getByText('Toggle Test Runs');
69+
const toggleButton = screen.getByText('Toggle Test Run Graphs');
7070

7171
fireEvent.click(toggleButton);
7272

73-
expect(screen.getByText('Test Runs Enabled: true')).toBeInTheDocument();
73+
expect(screen.getByText('Test Run Graphs Enabled: true')).toBeInTheDocument();
7474

7575
const expectedCookieVal = JSON.stringify({
76-
[FEATURE_FLAGS.TEST_RUNS]: true,
77-
[FEATURE_FLAGS.GRAPH]: false,
76+
[FEATURE_FLAGS.GRAPH]: true,
7877
});
7978

8079
expect(cookieSpy).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)