Skip to content

Commit

Permalink
clean up constants
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Dec 16, 2024
1 parent 42ed2f0 commit 3838be0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import * as React from 'react';

import { renderWithTheme } from 'src/utilities/testHelpers';

import { ALGORITHM_HELPER_TEXT } from './constants';
import { NodeBalancerConfigPanel } from './NodeBalancerConfigPanel';
import {
LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT,
ROUND_ROBIN_ALGORITHM_HELPER_TEXT,
SOURCE_ALGORITHM_HELPER_TEXT,
} from './utils';

import type {
NodeBalancerConfigNodeFields,
Expand Down Expand Up @@ -225,11 +221,15 @@ describe('NodeBalancerConfigPanel', () => {
<NodeBalancerConfigPanel {...nbConfigPanelMockPropsForTest} />
);

expect(getByText(ROUND_ROBIN_ALGORITHM_HELPER_TEXT)).toBeVisible();
expect(getByText(ALGORITHM_HELPER_TEXT.roundrobin)).toBeVisible();

expect(queryByText(ALGORITHM_HELPER_TEXT.source)).not.toBeInTheDocument();
expect(
queryByText(ALGORITHM_HELPER_TEXT.leastconn)
).not.toBeInTheDocument();
expect(
queryByText(LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT)
queryByText(ALGORITHM_HELPER_TEXT.ring_hash)

Check failure on line 231 in packages/manager/src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx > NodeBalancerConfigPanel > renders the relevant helper text for the Round Robin algorithm

TestingLibraryElementError: Found multiple elements with the text: Here are the matching elements: Ignored nodes: comments, script, style <body> <div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-xs-12 css-16fnxy3-MuiGrid2-root" data-qa-label-header="true" > <div class="MuiGrid2-root MuiGrid2-container MuiGrid2-direction-xs-row MuiGrid2-spacing-xs-2 css-lw2hqn-MuiGrid2-root" > <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Port" for="port" > Port <span class="MuiBox-root css-1exy5ab" > (required) </span> </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-port="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-invalid="false" class="MuiInputBase-input MuiInput-input css-1hp0d5q-MuiInputBase-input-MuiInput-input" data-testid="textfield-input" id="port" type="number" value="80" /> </div> </div> </div> </div> <p class="MuiFormHelperText-root css-oxfge7-MuiFormHelperText-root" > Listen on this port. </p> </div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-1xjzj0c-MuiAutocomplete-root" data-qa-autocomplete="Protocol" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Protocol" for="protocol-0" > Protocol </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-protocol-select="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-autocomplete="list" aria-expanded="false" aria-invalid="false"

Check failure on line 231 in packages/manager/src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/NodeBalancers/NodeBalancerPassiveCheck.test.tsx > NodeBalancerConfigPanel > renders the relevant helper text for the Round Robin algorithm

TestingLibraryElementError: Found multiple elements with the text: Here are the matching elements: Ignored nodes: comments, script, style <body> <div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-xs-12 css-16fnxy3-MuiGrid2-root" data-qa-label-header="true" > <div class="MuiGrid2-root MuiGrid2-container MuiGrid2-direction-xs-row MuiGrid2-spacing-xs-2 css-lw2hqn-MuiGrid2-root" > <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Port" for="port" > Port <span class="MuiBox-root css-1exy5ab" > (required) </span> </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-port="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-invalid="false" class="MuiInputBase-input MuiInput-input css-1hp0d5q-MuiInputBase-input-MuiInput-input" data-testid="textfield-input" id="port" type="number" value="80" /> </div> </div> </div> </div> <p class="MuiFormHelperText-root css-oxfge7-MuiFormHelperText-root" > Listen on this port. </p> </div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-1xjzj0c-MuiAutocomplete-root" data-qa-autocomplete="Protocol" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Protocol" for="protocol-0" > Protocol </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-protocol-select="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-autocomplete="list" aria-expanded="false" aria-invalid="false"
).not.toBeInTheDocument();
expect(queryByText(SOURCE_ALGORITHM_HELPER_TEXT)).not.toBeInTheDocument();
});

it('renders the relevant helper text for the Least Connections algorithm', () => {
Expand All @@ -240,10 +240,14 @@ describe('NodeBalancerConfigPanel', () => {
/>
);

expect(getByText(LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT)).toBeVisible();
expect(queryByText(SOURCE_ALGORITHM_HELPER_TEXT)).not.toBeInTheDocument();
expect(getByText(ALGORITHM_HELPER_TEXT.leastconn)).toBeVisible();

expect(queryByText(ALGORITHM_HELPER_TEXT.source)).not.toBeInTheDocument();
expect(
queryByText(ROUND_ROBIN_ALGORITHM_HELPER_TEXT)
queryByText(ALGORITHM_HELPER_TEXT.ring_hash)

Check failure on line 247 in packages/manager/src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx > NodeBalancerConfigPanel > renders the relevant helper text for the Least Connections algorithm

TestingLibraryElementError: Found multiple elements with the text: Here are the matching elements: Ignored nodes: comments, script, style <body> <div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-xs-12 css-16fnxy3-MuiGrid2-root" data-qa-label-header="true" > <div class="MuiGrid2-root MuiGrid2-container MuiGrid2-direction-xs-row MuiGrid2-spacing-xs-2 css-lw2hqn-MuiGrid2-root" > <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Port" for="port" > Port <span class="MuiBox-root css-1exy5ab" > (required) </span> </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-port="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-invalid="false" class="MuiInputBase-input MuiInput-input css-1hp0d5q-MuiInputBase-input-MuiInput-input" data-testid="textfield-input" id="port" type="number" value="80" /> </div> </div> </div> </div> <p class="MuiFormHelperText-root css-oxfge7-MuiFormHelperText-root" > Listen on this port. </p> </div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-1xjzj0c-MuiAutocomplete-root" data-qa-autocomplete="Protocol" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Protocol" for="protocol-0" > Protocol </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-protocol-select="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-autocomplete="list" aria-expanded="false" aria-invalid="false"

Check failure on line 247 in packages/manager/src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/NodeBalancers/NodeBalancerPassiveCheck.test.tsx > NodeBalancerConfigPanel > renders the relevant helper text for the Least Connections algorithm

TestingLibraryElementError: Found multiple elements with the text: Here are the matching elements: Ignored nodes: comments, script, style <body> <div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-xs-12 css-16fnxy3-MuiGrid2-root" data-qa-label-header="true" > <div class="MuiGrid2-root MuiGrid2-container MuiGrid2-direction-xs-row MuiGrid2-spacing-xs-2 css-lw2hqn-MuiGrid2-root" > <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Port" for="port" > Port <span class="MuiBox-root css-1exy5ab" > (required) </span> </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-port="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-invalid="false" class="MuiInputBase-input MuiInput-input css-1hp0d5q-MuiInputBase-input-MuiInput-input" data-testid="textfield-input" id="port" type="number" value="80" /> </div> </div> </div> </div> <p class="MuiFormHelperText-root css-oxfge7-MuiFormHelperText-root" > Listen on this port. </p> </div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-1xjzj0c-MuiAutocomplete-root" data-qa-autocomplete="Protocol" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Protocol" for="protocol-0" > Protocol </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-protocol-select="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-autocomplete="list" aria-expanded="false" aria-invalid="false"
).not.toBeInTheDocument();
expect(
queryByText(ALGORITHM_HELPER_TEXT.roundrobin)
).not.toBeInTheDocument();
});

Expand All @@ -255,12 +259,16 @@ describe('NodeBalancerConfigPanel', () => {
/>
);

expect(getByText(SOURCE_ALGORITHM_HELPER_TEXT)).toBeVisible();
expect(getByText(ALGORITHM_HELPER_TEXT.source)).toBeVisible();

expect(
queryByText(ALGORITHM_HELPER_TEXT.leastconn)
).not.toBeInTheDocument();
expect(
queryByText(ROUND_ROBIN_ALGORITHM_HELPER_TEXT)
queryByText(ALGORITHM_HELPER_TEXT.ring_hash)

Check failure on line 268 in packages/manager/src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx > NodeBalancerConfigPanel > renders the relevant helper text for the Source algorithm

TestingLibraryElementError: Found multiple elements with the text: Here are the matching elements: Ignored nodes: comments, script, style <body> <div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-xs-12 css-16fnxy3-MuiGrid2-root" data-qa-label-header="true" > <div class="MuiGrid2-root MuiGrid2-container MuiGrid2-direction-xs-row MuiGrid2-spacing-xs-2 css-lw2hqn-MuiGrid2-root" > <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Port" for="port" > Port <span class="MuiBox-root css-1exy5ab" > (required) </span> </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-port="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-invalid="false" class="MuiInputBase-input MuiInput-input css-1hp0d5q-MuiInputBase-input-MuiInput-input" data-testid="textfield-input" id="port" type="number" value="80" /> </div> </div> </div> </div> <p class="MuiFormHelperText-root css-oxfge7-MuiFormHelperText-root" > Listen on this port. </p> </div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-1xjzj0c-MuiAutocomplete-root" data-qa-autocomplete="Protocol" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Protocol" for="protocol-0" > Protocol </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-protocol-select="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-autocomplete="list" aria-expanded="false" aria-invalid="false"

Check failure on line 268 in packages/manager/src/features/NodeBalancers/NodeBalancerConfigPanel.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/NodeBalancers/NodeBalancerPassiveCheck.test.tsx > NodeBalancerConfigPanel > renders the relevant helper text for the Source algorithm

TestingLibraryElementError: Found multiple elements with the text: Here are the matching elements: Ignored nodes: comments, script, style <body> <div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-xs-12 css-16fnxy3-MuiGrid2-root" data-qa-label-header="true" > <div class="MuiGrid2-root MuiGrid2-container MuiGrid2-direction-xs-row MuiGrid2-spacing-xs-2 css-lw2hqn-MuiGrid2-root" > <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Port" for="port" > Port <span class="MuiBox-root css-1exy5ab" > (required) </span> </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-port="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-invalid="false" class="MuiInputBase-input MuiInput-input css-1hp0d5q-MuiInputBase-input-MuiInput-input" data-testid="textfield-input" id="port" type="number" value="80" /> </div> </div> </div> </div> <p class="MuiFormHelperText-root css-oxfge7-MuiFormHelperText-root" > Listen on this port. </p> </div> <div class="MuiGrid2-root MuiGrid2-direction-xs-row MuiGrid2-grid-md-3 MuiGrid2-grid-xs-6 css-1mc87ks-MuiGrid2-root" > <div class="MuiAutocomplete-root MuiAutocomplete-hasPopupIcon css-1xjzj0c-MuiAutocomplete-root" data-qa-autocomplete="Protocol" > <div class="MuiBox-root css-0" > <div class="MuiBox-root css-hpde30" data-testid="inputLabelWrapper" > <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-animated MuiFormLabel-colorPrimary MuiInputLabel-root MuiInputLabel-animated css-17cf11i-MuiFormLabel-root-MuiInputLabel-root" data-qa-textfield-label="Protocol" for="protocol-0" > Protocol </label> </div> <div class="MuiBox-root css-0" > <div class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-1d00hc3-MuiFormControl-root-MuiTextField-root" data-qa-protocol-select="true" > <div class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-eqm01t-MuiInputBase-root-MuiInput-root" > <input aria-autocomplete="list" aria-expanded="false" aria-invalid="false"
).not.toBeInTheDocument();
expect(
queryByText(LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT)
queryByText(ALGORITHM_HELPER_TEXT.roundrobin)
).not.toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
import { Link } from 'src/components/Link';
import { useFlags } from 'src/hooks/useFlags';

import { ALGORITHM_HELPER_TEXT } from './constants';
import { ActiveCheck } from './NodeBalancerActiveCheck';
import { NodeBalancerConfigNode } from './NodeBalancerConfigNode';
import { PassiveCheck } from './NodeBalancerPassiveCheck';
import {
LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT,
ROUND_ROBIN_ALGORITHM_HELPER_TEXT,
SOURCE_ALGORITHM_HELPER_TEXT,
getAlgorithmOptions,
getStickinessOptions,
setErrorMap,
Expand Down Expand Up @@ -192,13 +190,6 @@ export const NodeBalancerConfigPanel = (
return eachAlg.value === algorithm;
});

const algorithmHelperText = {
leastconn: LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT,
ring_hash: '', // @todo Add copy as part of UDP NodeBalancer project
roundrobin: ROUND_ROBIN_ALGORITHM_HELPER_TEXT,
source: SOURCE_ALGORITHM_HELPER_TEXT,
};

const sessionOptions = getStickinessOptions(protocol);

const defaultSession = sessionOptions.find((eachSession) => {
Expand Down Expand Up @@ -347,7 +338,7 @@ export const NodeBalancerConfigPanel = (
size="small"
value={defaultAlg || algOptions[0]}
/>
<FormHelperText>{algorithmHelperText[algorithm]}</FormHelperText>
<FormHelperText>{ALGORITHM_HELPER_TEXT[algorithm]}</FormHelperText>
</Grid>

<Grid md={3} xs={6}>
Expand Down
14 changes: 14 additions & 0 deletions packages/manager/src/features/NodeBalancers/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const ROUND_ROBIN_ALGORITHM_HELPER_TEXT =
'Round robin distributes connection requests to backend servers in weighted circular order.';

const LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT =
'Least connections assigns connections to the backend with the least connections.';

const SOURCE_ALGORITHM_HELPER_TEXT = "Source uses the client's IPv4 address.";

export const ALGORITHM_HELPER_TEXT = {
leastconn: LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT,
ring_hash: '', // @todo M3-9019 - Add copy as part of UDP NodeBalancer project
roundrobin: ROUND_ROBIN_ALGORITHM_HELPER_TEXT,
source: SOURCE_ALGORITHM_HELPER_TEXT,
};
9 changes: 0 additions & 9 deletions packages/manager/src/features/NodeBalancers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,3 @@ export const getStickinessOptions = (
{ label: 'HTTP Cookie', value: 'http_cookie' },
];
};

export const ROUND_ROBIN_ALGORITHM_HELPER_TEXT =
'Round robin distributes connection requests to backend servers in weighted circular order.';

export const LEAST_CONNECTIONS_ALGORITHM_HELPER_TEXT =
'Least connections assigns connections to the backend with the least connections.';

export const SOURCE_ALGORITHM_HELPER_TEXT =
"Source uses the client's IPv4 address.";

0 comments on commit 3838be0

Please sign in to comment.