Skip to content

Commit

Permalink
test(e2e): clean up tests thanks to Eriks feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jackw committed Mar 1, 2024
1 parent b677077 commit a99bc54
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/TrafficLightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export function TrafficLightPanel({

if (status === LightsDataResultStatus.nodata) {
return (
<div style={styles.centeredContent}>
<div data-testid="feedback-message-container" style={styles.centeredContent}>
<h4>The query returned no data.</h4>
</div>
);
}

if (status === LightsDataResultStatus.unsupported) {
return (
<div style={styles.centeredContent}>
<div data-testid="feedback-message-container" style={styles.centeredContent}>
<h4>This data format is unsupported.</h4>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions tests/traffic-light.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('Panel displays a traffic light when thresholds are correctly set', async (
await panelEditPage.getByTestIdOrAriaLabel(selectors.components.CodeEditor.container).click();
await page.keyboard.insertText(`time, value
10000000000, 100`);
await panelEditPage.getByTestIdOrAriaLabel('Refresh dashboard').click();
panelEditPage.refreshPanel();
const trafficLightPanel = await page.getByTestId('heywesty-traffic-light');
await expect(trafficLightPanel).toBeVisible();
await expect(trafficLightPanel.getByTestId('traffic-light-go')).toBeVisible();
Expand All @@ -23,14 +23,14 @@ test('Panel displays a traffic light when thresholds are correctly set', async (
await page.keyboard.press('Backspace');
await page.keyboard.insertText(`time, value
10000000000, 85`);
await panelEditPage.getByTestIdOrAriaLabel('Refresh dashboard').click();
panelEditPage.refreshPanel();
await expect(trafficLightPanel.getByTestId('traffic-light-ready')).toBeVisible();

await panelEditPage.getByTestIdOrAriaLabel(selectors.components.CodeEditor.container).click();
await page.keyboard.press('Control+A');
await page.keyboard.press('Backspace');
await page.keyboard.insertText(`time, value
10000000000, 50`);
await panelEditPage.getByTestIdOrAriaLabel('Refresh dashboard').click();
panelEditPage.refreshPanel();
await expect(trafficLightPanel.getByTestId('traffic-light-stop')).toBeVisible();
});
10 changes: 4 additions & 6 deletions tests/unsupported-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ test('Panel displays threshold assistant when thresholds incorrectly set', async
await expect(thresholdsAssistant).toBeVisible();
const invalidThresholds = await thresholdsAssistant.getByText('Threshold not configured');

await expect(await invalidThresholds.count()).toBe(1);
await expect(await invalidThresholds).toHaveCount(1);
await page.getByRole('button', { name: /Remove Threshold 1/i }).click();

await expect(await invalidThresholds.count()).toBe(2);
await expect(await invalidThresholds).toHaveCount(2);
await page.getByRole('button', { name: /add Threshold/i }).click();
await page.getByRole('button', { name: /add Threshold/i }).click();

Expand All @@ -32,8 +32,7 @@ test('Panel displays no data message when no data is returned', async ({ panelEd
await page.keyboard.press('Enter');

await expect(panelEditPage.getVisualizationName()).toHaveText('Traffic Light');
const noDataMessage = await page.getByText('The query returned no data.');
await expect(noDataMessage).toBeVisible();
await expect(await page.getByTestId('feedback-message-container')).toHaveText('The query returned no data.');
await expect(page.getByTestId('heywesty-traffic-light')).not.toBeVisible();
});

Expand All @@ -56,7 +55,6 @@ test('Panel displays unsupported message when data format is unsupported', async
await panelEditPage.getByTestIdOrAriaLabel('Refresh dashboard').click();

await expect(panelEditPage.getVisualizationName()).toHaveText('Traffic Light');
const unsupportedMessage = await page.getByText('This data format is unsupported.');
await expect(unsupportedMessage).toBeVisible();
await expect(await page.getByTestId('feedback-message-container')).toHaveText('This data format is unsupported.');
await expect(page.getByTestId('heywesty-traffic-light')).not.toBeVisible();
});

0 comments on commit a99bc54

Please sign in to comment.