Skip to content

Commit 821d929

Browse files
authored
Merge pull request #697 from ral-facilities/add-labels-in-channels-for]-vectors
Add labels in channels for vectors
2 parents f312570 + 664d52b commit 821d929

8 files changed

+116
-5
lines changed

e2e/real/channels.spec.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { expect, test } from '@playwright/test';
22

33
test('should be able to view the channel summary', async ({ page }) => {
44
test.skip(
@@ -71,6 +71,49 @@ test('should be able to view the channel summary', async ({ page }) => {
7171
).toHaveScreenshot({
7272
maxDiffPixels: 150,
7373
});
74+
75+
// vectors channel
76+
77+
await page
78+
.getByRole('combobox', { name: 'Search data channels' })
79+
.fill('CM-202-CVC-WFS');
80+
81+
await page.keyboard.press('ArrowDown');
82+
await page.keyboard.press('Enter');
83+
await page
84+
.getByRole('button', { name: 'Compressor output wavefront coefficients' })
85+
.click();
86+
87+
await expect(page.getByText('Channel type: vector')).toBeVisible();
88+
await expect(
89+
page.getByText('First data date: 2023-06-05 08:03:00')
90+
).toBeVisible();
91+
await expect(
92+
page.getByText('Most recent data date: 2023-06-05 08:03:00')
93+
).toBeVisible();
94+
await expect(
95+
await page.getByRole('table', { name: 'recent data' })
96+
).toHaveScreenshot({
97+
maxDiffPixels: 150,
98+
});
99+
100+
// float image channel
101+
await page
102+
.getByRole('button', { name: 'Compressor output wavefront image' })
103+
.click();
104+
105+
await expect(page.getByText('Channel type: float_image')).toBeVisible();
106+
await expect(
107+
page.getByText('First data date: 2023-06-05 08:03:00')
108+
).toBeVisible();
109+
await expect(
110+
page.getByText('Most recent data date: 2023-06-05 08:03:00')
111+
).toBeVisible();
112+
await expect(
113+
await page.getByRole('table', { name: 'recent data' })
114+
).toHaveScreenshot({
115+
maxDiffPixels: 150,
116+
});
74117
});
75118

76119
// don't need to test selecting channels, as that gets tested in most other tests
-5 Bytes
Loading
4.09 KB
Loading
5.23 KB
Loading

src/app.types.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export interface FullFloatImageChannelMetadata
107107

108108
export interface FullVectorChannelMetadata extends FullCommonChannelMetadata {
109109
type: 'vector';
110+
labels?: string[];
110111
units?: string;
111112
}
112113

src/channels/__snapshots__/channelMetadataPanel.component.test.tsx.snap

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,43 @@ exports[`Channel Metadata Panel > should render correctly for vector channel wit
285285
>
286286
Units: cm
287287
</p>
288+
<p
289+
class="MuiTypography-root MuiTypography-body2 MuiTypography-gutterBottom css-ejgmvm-MuiTypography-root"
290+
>
291+
Labels:
292+
</p>
293+
294+
<div
295+
class="MuiBox-root css-1vrkypf"
296+
>
297+
<div
298+
class="MuiChip-root MuiChip-filled MuiChip-sizeSmall MuiChip-colorDefault MuiChip-filledDefault css-sk307n-MuiChip-root"
299+
>
300+
<span
301+
class="MuiChip-label MuiChip-labelSmall css-wjsjww-MuiChip-label"
302+
>
303+
X
304+
</span>
305+
</div>
306+
<div
307+
class="MuiChip-root MuiChip-filled MuiChip-sizeSmall MuiChip-colorDefault MuiChip-filledDefault css-sk307n-MuiChip-root"
308+
>
309+
<span
310+
class="MuiChip-label MuiChip-labelSmall css-wjsjww-MuiChip-label"
311+
>
312+
Y
313+
</span>
314+
</div>
315+
<div
316+
class="MuiChip-root MuiChip-filled MuiChip-sizeSmall MuiChip-colorDefault MuiChip-filledDefault css-sk307n-MuiChip-root"
317+
>
318+
<span
319+
class="MuiChip-label MuiChip-labelSmall css-wjsjww-MuiChip-label"
320+
>
321+
Z
322+
</span>
323+
</div>
324+
</div>
288325
<hr
289326
class="MuiDivider-root MuiDivider-fullWidth css-9mgopn-MuiDivider-root"
290327
/>

src/channels/channelMetadataPanel.component.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('Channel Metadata Panel', () => {
6363
systemName: 'CHANNEL_ABCDE',
6464
type: 'vector',
6565
units: 'cm',
66+
labels: ['X', 'Y', 'Z'],
6667
path: '/test',
6768
description: 'Test description',
6869
};

src/channels/channelMetadataPanel.component.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import AddIcon from '@mui/icons-material/Add';
22
import RemoveIcon from '@mui/icons-material/Remove';
33
import {
4+
Box,
45
Button,
6+
Chip,
57
Divider,
68
Stack,
79
Table,
@@ -122,12 +124,39 @@ const ChannelMetadataPanel = (props: ChannelMetadataPanelProps) => {
122124
displayedChannel.units && (
123125
<Body>Units: {displayedChannel.units}</Body>
124126
)}
127+
{isChannelMetadataVector(displayedChannel) &&
128+
displayedChannel.labels && (
129+
<>
130+
<Body>Labels:</Body>{' '}
131+
{
132+
<Box display="flex" flexWrap="wrap" gap={1} mb={1}>
133+
{displayedChannel.labels.map((value) => {
134+
return (
135+
<Chip
136+
key={value}
137+
label={value}
138+
size="small"
139+
sx={{
140+
fontSize: '0.8125rem',
141+
backgroundColor: 'rgba(0, 0, 0, 0.08)',
142+
}}
143+
/>
144+
);
145+
})}
146+
</Box>
147+
}
148+
</>
149+
)}
125150
{isChannelMetadataWaveform(displayedChannel) && (
126151
<>
127-
<Body gutterBottom={false}>
128-
X Units: {displayedChannel.x_units}
129-
</Body>
130-
<Body>Y Units: {displayedChannel.y_units}</Body>
152+
{displayedChannel.x_units && (
153+
<Body gutterBottom={false}>
154+
X Units: {displayedChannel.x_units}
155+
</Body>
156+
)}
157+
{displayedChannel.y_units && (
158+
<Body>Y Units: {displayedChannel.y_units}</Body>
159+
)}
131160
</>
132161
)}
133162
{displayedChannel?.historical && (

0 commit comments

Comments
 (0)