Skip to content

Commit

Permalink
test: add platwright test
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar committed Aug 19, 2024
1 parent c74fd59 commit 358de02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/playground.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ test.describe('Playground page', () => {
expect(requestId).toHaveLength(20);
expect(requestId).not.toEqual(oldRequestId);
});

test.only('Clicking JSON link scrolls to appropriate JSON property', async ({ page }) => {
await page.getByText('See the JSON below').click({ force: true });
await expect(page.locator('span.json-view--property:text("rawDeviceAttributes")')).toBeInViewport();
});
});

test.describe('Proxy integration', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/playground/components/ArrowLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Link from 'next/link';
import { FunctionComponent, useRef } from 'react';
import { ExternalLinkArrowSvg } from '../../../client/img/externalLinkArrowSvg';
import styles from '../playground.module.scss';
import { TEST_IDS } from '../../../client/testIDs';

export const DocsLink: FunctionComponent<{ children: string; href: string; style?: React.CSSProperties }> = ({
children,
Expand Down Expand Up @@ -40,6 +41,8 @@ export const JsonLink: FunctionComponent<{
return (
<div
className={styles.jsonLink}
data-testid={TEST_IDS.playground.jsonLink}
data-test-property-name={propertyName}
onClick={() => {
// scroll to property and highlight it
const jsonProperties = document.querySelectorAll('.json-view--property');
Expand Down
1 change: 1 addition & 0 deletions src/client/testIDs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const TEST_IDS = {
agentResponseJSON: 'agentResponseJSON',
serverResponseJSON: 'serverResponseJSON',
refreshButton: 'refreshButton',
jsonLink: 'jsonLink',
},
} as const;

Expand Down

0 comments on commit 358de02

Please sign in to comment.