From 267950bb5480c57b8a63055fe394806e4809c18c Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 23 Apr 2024 20:56:16 +0100 Subject: [PATCH] Refactor Tab component to include countBadge and tabType properties --- CommonUI/src/Components/Tabs/Tab.tsx | 1 + CommonUI/src/Tests/Components/Tabs.test.tsx | 34 +++++++++--------- Nginx/default.conf.template | 39 +++++++++++++++++++++ 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/CommonUI/src/Components/Tabs/Tab.tsx b/CommonUI/src/Components/Tabs/Tab.tsx index ec91aad0ef..a4042764a1 100644 --- a/CommonUI/src/Components/Tabs/Tab.tsx +++ b/CommonUI/src/Components/Tabs/Tab.tsx @@ -28,6 +28,7 @@ const TabElement: FunctionComponent = ( return (
{ const tab1: Tab = { name: 'tab1', - children:
tab1 content
, + children:
tab 1 content
, }; const tab2: Tab = { name: 'tab2', - children:
tab2 content
, + children:
tab 2 content
, }; const tabs: Array = [tab1, tab2]; @@ -22,65 +22,65 @@ describe('Tabs', () => { test('it should render all props passed', () => { const onTabChange: jest.Mock = jest.fn(); - const { getByText } = render( + const { getByTestId } = render( ); - expect(getByText('tab1')).toBeInTheDocument(); - expect(getByText('tab2')).toBeInTheDocument(); + expect(getByTestId('tab-tab1')).toBeInTheDocument(); + expect(getByTestId('tab-tab2')).toBeInTheDocument(); }); test('it should render the first tab as active by default', () => { const onTabChange: jest.Mock = jest.fn(); - const { getByText } = render( + const { getByTestId } = render( ); - expect(getByText('tab1')).toHaveClass(activeClass); + expect(getByTestId('tab-tab1')).toHaveClass(activeClass); }); test('it should call onTabChange with the correct tab when a tab is clicked', () => { const onTabChange: jest.Mock = jest.fn(); - const { getByText } = render( + const { getByTestId } = render( ); - fireEvent.click(getByText('tab1')); + fireEvent.click(getByTestId('tab-tab1')); expect(onTabChange).toHaveBeenCalledWith(tab1); - fireEvent.click(getByText('tab2')); + fireEvent.click(getByTestId('tab-tab2')); expect(onTabChange).toHaveBeenCalledWith(tab2); }); test('it should show the correct tab as active when a tab is clicked', () => { const onTabChange: jest.Mock = jest.fn(); - const { getByText } = render( + const { getByTestId } = render( ); - fireEvent.click(getByText('tab2')); + fireEvent.click(getByTestId('tab-tab2')); - expect(getByText('tab1')).not.toHaveClass(activeClass); - expect(getByText('tab2')).toHaveClass(activeClass); + expect(getByTestId('tab-tab1')).not.toHaveClass(activeClass); + expect(getByTestId('tab-tab2')).toHaveClass(activeClass); }); test('it should handle empty tabs array gracefully', () => { const tabs: Array = []; const onTabChange: jest.Mock = jest.fn(); - const { getByText } = render( + const { getByTestId } = render( ); expect(() => { - return getByText('tab1'); + return getByTestId('tab-tab1'); }).toThrow(); expect(() => { - return getByText('tab2'); + return getByTestId('tab-tab2'); }).toThrow(); }); }); diff --git a/Nginx/default.conf.template b/Nginx/default.conf.template index 6ccc54697f..922326b46b 100644 --- a/Nginx/default.conf.template +++ b/Nginx/default.conf.template @@ -55,6 +55,7 @@ server { fastcgi_buffer_size 32k; location / { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -96,6 +97,7 @@ server { fastcgi_buffer_size 32k; location /logs { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -134,6 +136,7 @@ server { location / { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -152,6 +155,7 @@ server { location /status-page { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -168,6 +172,7 @@ server { } location /status-page-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -183,6 +188,7 @@ server { } location /status-page-sso-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -198,6 +204,7 @@ server { } location /status-page-identity-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -214,6 +221,7 @@ server { # Acme Verification. location /.well-known { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -256,6 +264,7 @@ server { location / { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -273,6 +282,7 @@ server { } location /status-page-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -288,6 +298,7 @@ server { } location /status-page-sso-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -303,6 +314,7 @@ server { } location /status-page-identity-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -318,6 +330,7 @@ server { } location /status-page { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -354,6 +367,7 @@ server { set $billing_enabled ${BILLING_ENABLED}; location / { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $server_name; proxy_set_header X-Real-IP $remote_addr; @@ -377,6 +391,7 @@ server { location /status-page-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -392,6 +407,7 @@ server { } location /status-page-sso-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -407,6 +423,7 @@ server { } location /status-page-identity-api/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -423,6 +440,7 @@ server { location /accounts { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -438,6 +456,7 @@ server { location /otlp/ { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -455,11 +474,13 @@ server { location ~ /opentelemetry.proto.collector* { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; grpc_pass grpc://opentelemetry-collector-grpc; } location /notification { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -474,6 +495,7 @@ server { } location /fluentd/logs { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -489,6 +511,7 @@ server { } location /ingestor { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -505,6 +528,7 @@ server { } location /server-monitor { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -521,6 +545,7 @@ server { } location /dashboard { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -536,6 +561,7 @@ server { location /admin { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -550,6 +576,7 @@ server { } location /isolated-vm { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -564,6 +591,7 @@ server { } location /status-page { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -579,6 +607,7 @@ server { } location /identity { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -593,6 +622,7 @@ server { } location /reference { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -607,6 +637,7 @@ server { } location /docs { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -621,6 +652,7 @@ server { } location /file { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -637,6 +669,7 @@ server { } location /api { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -653,6 +686,7 @@ server { } location /realtime { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -669,6 +703,7 @@ server { } location /analytics-api { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -686,6 +721,7 @@ server { location /heartbeat { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -703,6 +739,7 @@ server { location /workflow { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -719,6 +756,7 @@ server { } location /l/ { # Short URL for Link Shortener + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -735,6 +773,7 @@ server { } location /workers { + # This is for nginx not to crash when service is not available. resolver 127.0.0.1 valid=30s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;