Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Playground redesign #144

Merged
merged 56 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4dab39b
chore: move playground to app router
JuroUhlar May 22, 2024
de97c63
feat: add hero section
JuroUhlar May 22, 2024
c859699
feat: visitorId box
JuroUhlar May 22, 2024
41e814d
chore: move components into playground
JuroUhlar May 22, 2024
8adc44b
Merge branch 'main' into feat/playground-redesign
JuroUhlar May 23, 2024
be4ccf8
feat: style table v1
JuroUhlar May 23, 2024
d042049
feat: table link, prevent icon wrapping to a separate line
JuroUhlar May 23, 2024
923951b
Merge branch 'main' into feat/playground-redesign
JuroUhlar Jun 4, 2024
242afb3
feat: fix external link icon color and location text
JuroUhlar Jun 4, 2024
2d4686e
feat: nicer map
JuroUhlar Jun 4, 2024
2cda22d
feat: fix map height, suspect score n/a
JuroUhlar Jun 4, 2024
ace75b8
feat: analyze again button
JuroUhlar Jun 4, 2024
076505f
feat: accordion wip
JuroUhlar Jun 6, 2024
c819b6e
feat: improve accordion
JuroUhlar Jun 11, 2024
dd29ee3
feat: finish how to use this playground
JuroUhlar Jun 12, 2024
d767f71
chore: update Next
JuroUhlar Jun 12, 2024
7613f13
feat: finish how to use this playground
JuroUhlar Jun 12, 2024
76d15f0
feat: json section
JuroUhlar Jun 12, 2024
d5125da
ci: fix report status job
JuroUhlar Jun 13, 2024
b01180c
feat: layout fix
JuroUhlar Jun 13, 2024
9f69b22
feat: Learn more section
JuroUhlar Jun 13, 2024
4c6f33d
feat: scrolly scroll
JuroUhlar Jun 13, 2024
98589ec
feat: improve scrollbar position
JuroUhlar Jun 13, 2024
a35d4f7
feat: finally fix scroll area
JuroUhlar Jun 13, 2024
e52d275
feat: basic copy button
JuroUhlar Jun 13, 2024
e87dfe4
feat: copied state for copy button
JuroUhlar Jun 14, 2024
28fa95f
styles: running intelligence padding
JuroUhlar Jun 14, 2024
715ebf9
styles: responsiveness whitespace
JuroUhlar Jun 14, 2024
ff55ef6
styles: responsiveness font-size
JuroUhlar Jun 14, 2024
80d9251
styles: more responsiveness
JuroUhlar Jun 14, 2024
f9a36de
feat: make signal table collapsible
JuroUhlar Jun 14, 2024
fcd8215
feat: finalize open-close chevron
JuroUhlar Jun 17, 2024
76448f7
fix tests
JuroUhlar Jun 17, 2024
e7db839
feat: try @microlink/react-json-view, does not work
JuroUhlar Jun 18, 2024
9c585c6
try react18-json-viewer, much better
JuroUhlar Jun 18, 2024
b6d1447
feat: improve json viewer
JuroUhlar Jun 18, 2024
bf07e5f
feat: use json viewer
JuroUhlar Jun 18, 2024
524c252
improve copy function, organize styles
JuroUhlar Jun 18, 2024
57985a5
fix build
JuroUhlar Jun 19, 2024
56dbb70
fix map
JuroUhlar Jun 19, 2024
732091a
ci: fix e2e tests
JuroUhlar Jun 28, 2024
2151d78
styles: update minor styles
JuroUhlar Jun 28, 2024
b4977e6
styles: learn more section horizontal scroll on mobile
JuroUhlar Jul 1, 2024
4cbedb1
styles: update padding
JuroUhlar Jul 1, 2024
eee5a08
feat: use accuracyRadius
JuroUhlar Jul 1, 2024
4d5ea8a
fix build
JuroUhlar Jul 1, 2024
3eb73cd
styles: fix chevron visibility
JuroUhlar Jul 2, 2024
682315e
chore: simplify accordion implementation
JuroUhlar Jul 2, 2024
430be7c
chore: self review fixes
JuroUhlar Jul 2, 2024
db199aa
chore: fix build
JuroUhlar Jul 2, 2024
a174103
chore: fix build
JuroUhlar Jul 2, 2024
92cd7af
chore: review fixes
JuroUhlar Jul 8, 2024
21f46bd
Update src/client/components/common/componentUtils.tsx
JuroUhlar Jul 8, 2024
b6c845b
fix lint
JuroUhlar Jul 8, 2024
5049a57
Feat/final redesign touches (#147)
JuroUhlar Jul 12, 2024
f96d384
Playground Layout: Put visitor ID in Identification column (#148)
JuroUhlar Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/production_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
retention-days: 30
report-status:
needs: e2e
if: ${{ needs.e2e.result == 'failure' }}
if: failure()
uses: fingerprintjs/dx-team-toolkit/.github/workflows/report-workflow-status.yml@v1
with:
notification_title: 'Hey, <@U04GNKK5ZTQ>! Production e2e tests on demo.fingerprint.com have {status_message}'
Expand Down
52 changes: 36 additions & 16 deletions e2e/playground.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import { Page, expect, test } from '@playwright/test';
import { PLAYGROUND_TAG } from '../src/client/components/playground/playgroundTags';
import { isAgentResponse, isServerResponse } from './zodUtils';
import { blockGoogleTagManager } from './e2eTestUtils';
import { TEST_IDS } from '../src/client/testIDs';

const TEST_ID = TEST_IDS.playground;

const getAgentResponse = async (page: Page) => {
const agentResponse =
(await (await page.getByTestId(PLAYGROUND_TAG.agentResponseJSON)).textContent()) ?? 'Agent response not found';
return JSON.parse(agentResponse);
(await (await page.getByTestId(TEST_ID.agentResponseJSON)).textContent()) ?? 'Agent response not found';
return agentResponse;
};

const getServerResponse = async (page: Page) => {
const serverResponse =
(await (await page.getByTestId(PLAYGROUND_TAG.serverResponseJSON)).textContent()) ?? 'Server response not found';
return JSON.parse(serverResponse);
(await (await page.getByTestId(TEST_ID.serverResponseJSON)).textContent()) ?? 'Server response not found';
return serverResponse;
TheUnderScorer marked this conversation as resolved.
Show resolved Hide resolved
};

function parseRequestId(inputString: string) {
const regex = /requestId:\s*"([^"]+)"/;
const match = inputString.match(regex);

if (match && match[1]) {
return match[1];
} else {
return null;
}
TheUnderScorer marked this conversation as resolved.
Show resolved Hide resolved
}

const clickPlaygroundRefreshButton = async (page: Page) => {
await page.getByTestId(PLAYGROUND_TAG.refreshButton).first().click();
await page.getByTestId(TEST_ID.refreshButton).first().click();
// Artificial wait necessary to make sure you get the updated response every time
await page.waitForTimeout(3000);
};
Expand All @@ -29,8 +41,8 @@ test.beforeEach(async ({ page }) => {
test.describe('Playground page', () => {
test('Page renders basic skeleton elements', async ({ page }) => {
await page.getByText('Fingerprint Pro Playground', { exact: true }).waitFor();
await page.getByText('Welcome, your visitor ID is').waitFor();
await page.getByTestId(PLAYGROUND_TAG.refreshButton).first().waitFor();
await page.getByText('Welcome, this is your visitor ID').waitFor();
await page.getByTestId(TEST_ID.refreshButton).first().waitFor();

await page.getByText('Identification', { exact: true }).waitFor();
await page.getByText('Smart signals', { exact: true }).waitFor();
Expand All @@ -41,7 +53,6 @@ test.describe('Playground page', () => {
});

test('Page renders signal tables', async ({ page }) => {
await page.getByText('Visitor ID', { exact: true }).waitFor();
await page.getByText('Last seen', { exact: true }).waitFor();
await page.getByText('Confidence Score', { exact: true }).waitFor();

Expand All @@ -54,28 +65,37 @@ test.describe('Playground page', () => {

test('Page renders agent response', async ({ page }) => {
const agentResponse = await getAgentResponse(page);
expect(isAgentResponse(agentResponse)).toBe(true);
expect(agentResponse).toContain('requestId');
expect(agentResponse).toContain('browserName');
expect(agentResponse).toContain('browserVersion');
expect(agentResponse).toContain('visitorId');
});

test('Page renders server response', async ({ page }) => {
const serverResponse = await getServerResponse(page);
expect(isServerResponse(serverResponse)).toBe(true);

expect(serverResponse).toContain('requestId');
expect(serverResponse).toContain('visitorId');
expect(serverResponse).toContain('incognito');
expect(serverResponse).toContain('botd');
expect(serverResponse).toContain('vpn');
expect(serverResponse).toContain('privacySettings');
});

test('Reload button updates agent response', async ({ page }) => {
const { requestId: oldRequestId } = await getAgentResponse(page);
const oldRequestId = parseRequestId(await getAgentResponse(page));
await clickPlaygroundRefreshButton(page);
const { requestId } = await getAgentResponse(page);
const requestId = parseRequestId(await getAgentResponse(page));

expect(oldRequestId).toHaveLength(20);
expect(requestId).toHaveLength(20);
expect(requestId).not.toEqual(oldRequestId);
});

test('Reload button updates server response', async ({ page }) => {
const oldRequestId = (await getServerResponse(page)).products.botd.data.requestId;
const oldRequestId = parseRequestId(await getServerResponse(page));
await clickPlaygroundRefreshButton(page);
const requestId = (await getServerResponse(page)).products.botd.data.requestId;
const requestId = parseRequestId(await getServerResponse(page));

expect(oldRequestId).toHaveLength(20);
expect(requestId).toHaveLength(20);
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"@fingerprintjs/fingerprintjs-pro-server-api": "^3.1.0",
"@mui/icons-material": "^5.15.11",
"@mui/material": "^5.15.11",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slider": "^1.1.2",
Expand All @@ -37,7 +39,7 @@
"framer-motion": "^11.0.8",
"is-ip": "^5.0.1",
"leaflet": "^1.9.4",
"next": "^14.1.1",
"next": "^14.2.4",
"next-usequerystate": "^1.17.0",
"notistack": "^3.0.1",
"prismjs": "^1.29.0",
Expand All @@ -47,6 +49,7 @@
"react-query": "^3.39.3",
"react-syntax-highlighter": "^15.5.0",
"react-use": "^17.5.0",
"react18-json-view": "^0.2.9-canary.0",
"sequelize": "^6.37.1",
"sharp": "^0.33.2",
"twilio": "^5.0.1"
Expand Down
2 changes: 1 addition & 1 deletion src/app/appLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { Layout } from '../Layout';

export default function LayoutUiInsideApp({ children }: { children: React.ReactNode }) {
const segments = useSelectedLayoutSegments();
return <Layout embed={segments.includes('embed')}>{children}</Layout>;
return <Layout embed={Boolean(segments?.includes('embed'))}>{children}</Layout>;
}
Loading
Loading