Skip to content

Commit 2ed16e9

Browse files
authored
test: Add E2E test for the infrastructure search side panel (#1198)
1 parent ea5d292 commit 2ed16e9

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

packages/app/src/components/DBInfraPanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const InfraSubpanelGroup = ({
6969
}, [dateRange]);
7070

7171
return (
72-
<div>
72+
<div data-testid={`infra-subpanel-${fieldPrefix}`}>
7373
<Group justify="space-between" align="center">
7474
<Group align="center">
7575
<h4 className="text-slate-300 fs-6 m-0">{title}</h4>
@@ -102,7 +102,7 @@ const InfraSubpanelGroup = ({
102102
</Group>
103103
</Group>
104104
<SimpleGrid mt="md" cols={cols}>
105-
<Card p="md">
105+
<Card p="md" data-testid="cpu-usage-card">
106106
<Card.Section p="md" py="xs" withBorder>
107107
CPU Usage (%)
108108
</Card.Section>
@@ -134,7 +134,7 @@ const InfraSubpanelGroup = ({
134134
/>
135135
</Card.Section>
136136
</Card>
137-
<Card p="md">
137+
<Card p="md" data-testid="memory-usage-card">
138138
<Card.Section p="md" py="xs" withBorder>
139139
Memory Used
140140
</Card.Section>
@@ -166,7 +166,7 @@ const InfraSubpanelGroup = ({
166166
/>
167167
</Card.Section>
168168
</Card>
169-
<Card p="md">
169+
<Card p="md" data-testid="disk-usage-card">
170170
<Card.Section p="md" py="xs" withBorder>
171171
Disk Available
172172
</Card.Section>

packages/app/tests/e2e/features/search/search.spec.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ test.describe('Search', { tag: '@search' }, () => {
124124
}) => {
125125
await test.step('Setup and perform search', async () => {
126126
const searchInput = page.locator('[data-testid="search-input"]');
127-
await searchInput.fill('Order');
127+
await searchInput.fill(
128+
'ResourceAttributes.k8s.pod.name:* ResourceAttributes.k8s.node.name:* ',
129+
);
128130

129131
const searchSubmitButton = page.locator(
130132
'[data-testid="search-submit-button"]',
@@ -175,7 +177,51 @@ test.describe('Search', { tag: '@search' }, () => {
175177
await page.waitForTimeout(500);
176178
await expect(tab.locator).toBeVisible();
177179
}
178-
await page.keyboard.press('Escape');
180+
});
181+
182+
await test.step('Verify infrastructure tab content', async () => {
183+
const infrastructureTab = page.locator(
184+
'[data-testid="tab-infrastructure"]',
185+
);
186+
await infrastructureTab.click();
187+
await infrastructureTab.scrollIntoViewIfNeeded();
188+
await page.waitForTimeout(1000);
189+
190+
const podSubpanel = page.getByTestId('infra-subpanel-k8s.pod.');
191+
await expect(podSubpanel).toBeVisible();
192+
193+
const podCpuUsageData = podSubpanel
194+
.getByTestId('cpu-usage-card')
195+
.locator('.recharts-responsive-container');
196+
await expect(podCpuUsageData).toBeVisible();
197+
198+
const podMemoryUsageData = podSubpanel
199+
.getByTestId('memory-usage-card')
200+
.locator('.recharts-responsive-container');
201+
await expect(podMemoryUsageData).toBeVisible();
202+
203+
const podDiskUsageData = podSubpanel
204+
.getByTestId('disk-usage-card')
205+
.locator('.recharts-responsive-container');
206+
await expect(podDiskUsageData).toBeVisible();
207+
208+
const nodeSubpanel = page.getByTestId('infra-subpanel-k8s.node.');
209+
await expect(nodeSubpanel).toBeVisible();
210+
211+
const nodeCpuUsageData = nodeSubpanel
212+
.getByTestId('cpu-usage-card')
213+
.locator('.recharts-responsive-container');
214+
await expect(nodeCpuUsageData).toBeVisible();
215+
216+
const nodeMemoryUsageData = nodeSubpanel
217+
.getByTestId('memory-usage-card')
218+
.locator('.recharts-responsive-container');
219+
await expect(nodeMemoryUsageData).toBeVisible();
220+
221+
const nodeDiskUsageData = nodeSubpanel
222+
.getByTestId('disk-usage-card')
223+
.locator('.recharts-responsive-container');
224+
await expect(nodeDiskUsageData).toBeVisible();
179225
});
180226
});
181227

0 commit comments

Comments
 (0)