diff --git a/gsa/src/web/components/bar/__tests__/__snapshots__/titlebar.js.snap b/gsa/src/web/components/bar/__tests__/__snapshots__/titlebar.js.snap index 8e570151b3..1f9beb3a70 100644 --- a/gsa/src/web/components/bar/__tests__/__snapshots__/titlebar.js.snap +++ b/gsa/src/web/components/bar/__tests__/__snapshots__/titlebar.js.snap @@ -85,7 +85,9 @@ exports[`Titlebar tests should not render content if user is logged out 1`] = ` src="/img/gsa.svg" /> -
+
+ Vendor Version +
diff --git a/gsa/src/web/components/bar/__tests__/progressbar.js b/gsa/src/web/components/bar/__tests__/progressbar.js index ce56549513..2e1400cf20 100644 --- a/gsa/src/web/components/bar/__tests__/progressbar.js +++ b/gsa/src/web/components/bar/__tests__/progressbar.js @@ -48,7 +48,34 @@ describe('ProgressBar tests', () => { expect(progress).toHaveStyleRule('width', '90%'); }); - test('should render background', () => { + test('should not render progress > 100', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('width', '100%'); + }); + + test('should not render progress < 0', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('width', '0%'); + }); + + test('should render background = warn', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('background', '#F0A519'); + }); + + test('should render background = error', () => { const {getByTestId} = render( , ); @@ -56,4 +83,40 @@ describe('ProgressBar tests', () => { expect(progress).toHaveStyleRule('background', '#C83814'); }); + + test('should render background = low', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('background', '#4F91C7'); + }); + + test('should render background = new', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('background', '#99BE48'); + }); + + test('should render background = run', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('background', '#70C000'); + }); + + test('should render background = log', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('background', 'gray'); + }); }); diff --git a/gsa/src/web/components/bar/__tests__/severitybar.js b/gsa/src/web/components/bar/__tests__/severitybar.js index 04efc1c5f5..bd0cc7616d 100644 --- a/gsa/src/web/components/bar/__tests__/severitybar.js +++ b/gsa/src/web/components/bar/__tests__/severitybar.js @@ -48,10 +48,32 @@ describe('SeverityBar tests', () => { expect(progress).toHaveStyleRule('width', '95%'); }); + test('should not render progress > 100', () => { + const {getByTestId} = render(); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('width', '100%'); + }); + + test('should not render progress < 0', () => { + const {getByTestId} = render(); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('width', '0%'); + }); + test('should render background', () => { const {getByTestId} = render(); const progress = getByTestId('progress'); expect(progress).toHaveStyleRule('background', '#C83814'); }); + + test('should render without severity prop', () => { + const {getByTestId} = render(); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('background', '#4F91C7'); + expect(progress).toHaveStyleRule('width', '0%'); + }); }); diff --git a/gsa/src/web/components/bar/__tests__/statusbar.js b/gsa/src/web/components/bar/__tests__/statusbar.js index 0894c6d42d..52e934ef32 100644 --- a/gsa/src/web/components/bar/__tests__/statusbar.js +++ b/gsa/src/web/components/bar/__tests__/statusbar.js @@ -56,6 +56,24 @@ describe('StatusBar tests', () => { expect(progress).toHaveStyleRule('width', '90%'); }); + test('should not render progress > 100', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('width', '100%'); + }); + + test('should not render progress < 0', () => { + const {getByTestId} = render( + , + ); + const progress = getByTestId('progress'); + + expect(progress).toHaveStyleRule('width', '0%'); + }); + test('should render background', () => { const {getByTestId} = render( , diff --git a/gsa/src/web/components/bar/__tests__/titlebar.js b/gsa/src/web/components/bar/__tests__/titlebar.js index b870349d44..bde6f8b755 100644 --- a/gsa/src/web/components/bar/__tests__/titlebar.js +++ b/gsa/src/web/components/bar/__tests__/titlebar.js @@ -38,11 +38,14 @@ describe('Titlebar tests', () => { expect(baseElement).toMatchSnapshot(); expect(isLoggedIn).toHaveBeenCalled(); + const links = baseElement.querySelectorAll('a'); + expect(links[1]).toHaveTextContent('username'); + expect(baseElement).not.toHaveTextContent('Vendor Version'); }); test('should not render content if user is logged out', () => { const isLoggedIn = jest.fn().mockReturnValue(false); - const gmp = {isLoggedIn, settings: {vendorVersion: ''}}; + const gmp = {isLoggedIn, settings: {vendorVersion: 'Vendor Version'}}; const {render, store} = rendererWith({gmp, router: true, store: true}); store.dispatch(setUsername('username')); @@ -50,5 +53,7 @@ describe('Titlebar tests', () => { expect(baseElement).toMatchSnapshot(); expect(isLoggedIn).toHaveBeenCalled(); + expect(baseElement).not.toHaveTextContent('username'); + expect(baseElement).toHaveTextContent('Vendor Version'); }); }); diff --git a/gsa/src/web/components/bar/progressbar.js b/gsa/src/web/components/bar/progressbar.js index 3cf287ab39..d7f1418fb5 100644 --- a/gsa/src/web/components/bar/progressbar.js +++ b/gsa/src/web/components/bar/progressbar.js @@ -80,6 +80,9 @@ const Progress = styled.div` if (progress > 100) { progress = 100; } + if (progress < 0) { + progress = 0; + } return { width: progress + '%', background,