Skip to content

Commit 171cdf0

Browse files
style: update status page styles
1 parent 50c3eed commit 171cdf0

File tree

4 files changed

+312
-78
lines changed

4 files changed

+312
-78
lines changed

src/pages/sidepanel/components/SimpleTable.tsx

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from 'react';
2-
import { Grid, Divider, Typography } from '@mui/material';
2+
3+
import { Circle } from '@mui/icons-material';
4+
import { Grid, Typography } from '@mui/material';
5+
import { styled } from '@mui/material/styles';
6+
import { appColors } from '@root/src/theme/palette';
37

48
interface TableRow {
59
label: string;
@@ -12,33 +16,61 @@ interface SimpleTableProps {
1216
rows: TableRow[];
1317
}
1418

19+
const StyledContainer = styled(Grid)(() => ({
20+
cursor: 'default',
21+
transition: 'none',
22+
'&:hover': {
23+
boxShadow: 'none',
24+
transform: 'none',
25+
},
26+
}));
27+
28+
const StyledLabelTypography = styled(Typography)(() => ({
29+
fontWeight: appColors.common.fontWeight.semiBold,
30+
fontSize: appColors.common.fontSize.baseSmall,
31+
lineHeight: 'normal',
32+
textAlign: 'left',
33+
}));
34+
35+
const StyledValueTypography = styled(Typography)(({ theme }) => ({
36+
whiteSpace: 'nowrap',
37+
overflow: 'hidden',
38+
textOverflow: 'ellipsis',
39+
fontSize: appColors.common.fontSize.baseSmall,
40+
lineHeight: 'normal',
41+
fontWeight: appColors.common.fontWeight.medium,
42+
display: 'flex',
43+
alignItems: 'center',
44+
gap: theme.spacing(0.75),
45+
textAlign: 'left',
46+
}));
47+
48+
const StyledCircle = styled(Circle)(() => ({
49+
fontSize: '0.5rem',
50+
color: appColors.toggle.active,
51+
}));
52+
1553
const SimpleTable: React.FC<SimpleTableProps> = ({ rows }) => {
1654
return (
17-
<Grid container spacing={1} pl={1} pr={1}>
55+
<StyledContainer container spacing={2}>
1856
{rows.map((row, index) => (
1957
<React.Fragment key={index}>
2058
<Grid item xs={row.position === 'top' ? 12 : 3.5}>
21-
<Typography variant="subtitle2" pr={1} align={'left'} sx={{ fontWeight: 600 }}>
22-
{row.label}
23-
</Typography>
59+
<StyledLabelTypography variant="subtitle2">{row.label}</StyledLabelTypography>
2460
</Grid>
2561
<Grid item xs={row.position === 'top' ? 12 : 8.5}>
2662
{row.fancyValue ? (
2763
row.fancyValue
2864
) : (
29-
<Typography variant="body2" align={'left'}>
65+
<StyledValueTypography variant="body2">
66+
<StyledCircle />
3067
{row.value}
31-
</Typography>
68+
</StyledValueTypography>
3269
)}
3370
</Grid>
34-
{index !== rows.length - 1 && ( // Add a divider unless it's the last row
35-
<Grid item xs={12}>
36-
<Divider />
37-
</Grid>
38-
)}
3971
</React.Fragment>
4072
))}
41-
</Grid>
73+
</StyledContainer>
4274
);
4375
};
4476

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import '@testing-library/jest-dom';
2+
3+
import React from 'react';
4+
5+
import { describe, expect, it } from 'vitest';
6+
7+
import { ThemeProvider } from '@mui/material/styles';
8+
import { TagConfigModel } from '@root/src/shared/models/tagConfigModel';
9+
import { appTheme } from '@root/src/theme';
10+
import { render, screen } from '@testing-library/react';
11+
12+
import TagStatus from './TagStatus';
13+
14+
const renderWithTheme = (component: React.ReactElement) => {
15+
return render(<ThemeProvider theme={appTheme}>{component}</ThemeProvider>);
16+
};
17+
18+
describe('TagStatus', () => {
19+
const mockTagConfig: TagConfigModel = {
20+
version: '4.2.1',
21+
cid: ['test-account-123'],
22+
stream: 'production',
23+
cookie: 'seerid',
24+
entity: { byFieldKey: 'email' },
25+
loadid: true,
26+
};
27+
28+
const legacyTagConfig: TagConfigModel = {
29+
version: '2.8.5',
30+
cid: ['legacy-account'],
31+
stream: 'default',
32+
cookie: 'seerid',
33+
entity: { byFieldKey: 'user_id' },
34+
loadid: false,
35+
};
36+
37+
describe('when tag is installed', () => {
38+
it('renders status header correctly', () => {
39+
renderWithTheme(<TagStatus tagIsInstalled={true} tagConfig={mockTagConfig} />);
40+
41+
expect(screen.getByText('Status')).toBeInTheDocument();
42+
expect(screen.getByTestId('MonitorHeartOutlinedIcon')).toBeInTheDocument();
43+
});
44+
45+
it('shows SDK installed message for current version', () => {
46+
renderWithTheme(<TagStatus tagIsInstalled={true} tagConfig={mockTagConfig} />);
47+
48+
expect(screen.getByText('Lytics JavaScript SDK Installed')).toBeInTheDocument();
49+
expect(screen.getByText('v4.2.1')).toBeInTheDocument();
50+
expect(screen.getByTestId('CheckCircleIcon')).toBeInTheDocument();
51+
});
52+
53+
it('shows deprecated version warning for legacy tag', () => {
54+
renderWithTheme(<TagStatus tagIsInstalled={true} tagConfig={legacyTagConfig} />);
55+
56+
expect(screen.getByText('You are using a deprecated version of the Lytics SDK')).toBeInTheDocument();
57+
expect(screen.getByText('v2.8.5')).toBeInTheDocument();
58+
expect(screen.getByTestId('CancelIcon')).toBeInTheDocument();
59+
});
60+
61+
it('renders configuration table with correct data', () => {
62+
renderWithTheme(<TagStatus tagIsInstalled={true} tagConfig={mockTagConfig} />);
63+
64+
expect(screen.getByText('Account ID')).toBeInTheDocument();
65+
expect(screen.getByText('Stream')).toBeInTheDocument();
66+
expect(screen.getByText('Cookie Name')).toBeInTheDocument();
67+
expect(screen.getByText('Profile Key')).toBeInTheDocument();
68+
expect(screen.getByText('3rd Party Cookies')).toBeInTheDocument();
69+
70+
expect(screen.getByText('test-account-123')).toBeInTheDocument();
71+
expect(screen.getByText('production')).toBeInTheDocument();
72+
expect(screen.getByText('seerid')).toBeInTheDocument();
73+
expect(screen.getByText('email')).toBeInTheDocument();
74+
expect(screen.getByText('Enabled')).toBeInTheDocument();
75+
});
76+
77+
it('shows disabled for 3rd party cookies when loadid is false', () => {
78+
const configWithoutLoadid = { ...mockTagConfig, loadid: false };
79+
80+
renderWithTheme(<TagStatus tagIsInstalled={true} tagConfig={configWithoutLoadid} />);
81+
82+
expect(screen.getByText('Disabled')).toBeInTheDocument();
83+
});
84+
});
85+
86+
describe('when tag is not installed', () => {
87+
it('shows loading spinner', () => {
88+
renderWithTheme(<TagStatus tagIsInstalled={false} tagConfig={mockTagConfig} />);
89+
90+
expect(screen.getByRole('progressbar')).toBeInTheDocument();
91+
});
92+
93+
it('shows searching message', () => {
94+
renderWithTheme(<TagStatus tagIsInstalled={false} tagConfig={mockTagConfig} />);
95+
96+
expect(screen.getByText('Searching for Lytics JavaScript SDK')).toBeInTheDocument();
97+
expect(screen.getByTestId('ErrorIcon')).toBeInTheDocument();
98+
});
99+
100+
it('shows installation instructions with documentation link', () => {
101+
renderWithTheme(<TagStatus tagIsInstalled={false} tagConfig={mockTagConfig} />);
102+
103+
expect(screen.getByText(/We have not been able to find the Lytics JavaScript SDK/)).toBeInTheDocument();
104+
105+
const docLink = screen.getByRole('link', { name: 'Lytics JavaScript SDK documentation' });
106+
expect(docLink).toBeInTheDocument();
107+
expect(docLink).toHaveAttribute('href', 'https://docs.lytics.com/docs/lytics-javascript-tag#installation');
108+
expect(docLink).toHaveAttribute('target', '_blank');
109+
expect(docLink).toHaveAttribute('rel', 'noreferrer');
110+
});
111+
});
112+
});

0 commit comments

Comments
 (0)