-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added playwright to test component render time.
- Loading branch information
1 parent
f7f8279
commit 1e5152d
Showing
15 changed files
with
382 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# name: Playwright Tests | ||
# on: | ||
# push: | ||
# branches: [ main, master ] | ||
# pull_request: | ||
# branches: [ main, master ] | ||
# jobs: | ||
# test: | ||
# timeout-minutes: 60 | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: actions/setup-node@v4 | ||
# with: | ||
# node-version: lts/* | ||
# - name: Install dependencies | ||
# run: npm install -g yarn && yarn | ||
# - name: Install Playwright Browsers | ||
# run: yarn playwright install --with-deps | ||
# - name: Run Playwright tests | ||
# run: yarn playwright test | ||
# - uses: actions/upload-artifact@v4 | ||
# if: always() | ||
# with: | ||
# name: playwright-report | ||
# path: playwright-report/ | ||
# retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/twenty-front/src/modules/debug/profiling/components/ProfilerReporter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useRecoilState } from 'recoil'; | ||
|
||
import { profilingSessionState } from '@/debug/profiling/states/profilingSessionState'; | ||
|
||
export const ProfilerReporter = () => { | ||
const [profilingSession] = useRecoilState(profilingSessionState); | ||
|
||
return ( | ||
<div | ||
style={{ width: 0, height: 0, visibility: 'hidden' }} | ||
data-profiling-report={JSON.stringify(profilingSession)} | ||
id="profiling-report" | ||
></div> | ||
); | ||
}; |
39 changes: 39 additions & 0 deletions
39
packages/twenty-front/src/modules/debug/profiling/components/ProfilerWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Profiler, ProfilerOnRenderCallback } from 'react'; | ||
import { useRecoilCallback } from 'recoil'; | ||
|
||
import { profilingSessionState } from '@/debug/profiling/states/profilingSessionState'; | ||
import { ProfilingDataPoint } from '@/debug/profiling/types/ProfilingDataPoint'; | ||
|
||
export const ProfilerWrapper = ({ | ||
id, | ||
componentName, | ||
children, | ||
}: { | ||
id: string; | ||
componentName: string; | ||
children: React.ReactNode; | ||
}) => { | ||
const handleRender: ProfilerOnRenderCallback = useRecoilCallback( | ||
({ set }) => | ||
(id, phase, actualDurationInMs) => { | ||
const newDataPoint: ProfilingDataPoint = { | ||
componentName, | ||
id, | ||
phase, | ||
durationInMs: actualDurationInMs, | ||
}; | ||
|
||
set(profilingSessionState, (currentProfilingSession) => ({ | ||
...currentProfilingSession, | ||
[id]: [...(currentProfilingSession[id] ?? []), newDataPoint], | ||
})); | ||
}, | ||
[componentName], | ||
); | ||
|
||
return ( | ||
<Profiler id={id} onRender={handleRender}> | ||
{children} | ||
</Profiler> | ||
); | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/twenty-front/src/modules/debug/profiling/states/profilingSessionState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { atom } from 'recoil'; | ||
|
||
import { ProfilingDataPoint } from '@/debug/profiling/types/ProfilingDataPoint'; | ||
|
||
export const profilingSessionState = atom<Record<string, ProfilingDataPoint[]>>( | ||
{ | ||
key: 'profilingSessionState', | ||
default: {}, | ||
}, | ||
); |
6 changes: 6 additions & 0 deletions
6
packages/twenty-front/src/modules/debug/profiling/types/ProfilingDataPoint.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type ProfilingDataPoint = { | ||
id: string; | ||
componentName: string; | ||
phase: string; | ||
durationInMs: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/twenty-front/src/modules/ui/theme/components/AppThemeProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://localhost:3001', | ||
|
||
extraHTTPHeaders: { | ||
Authorization: | ||
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyMDIwMjAyMC05ZTNiLTQ2ZDQtYTU1Ni04OGI5ZGRjMmIwMzQiLCJ3b3Jrc3BhY2VJZCI6IjIwMjAyMDIwLTFjMjUtNGQwMi1iZjI1LTZhZWNjZjdlYTQxOSIsImlhdCI6MTcxNDU1OTA2NSwiZXhwIjoxNzIyMzM1MDY1fQ.3OkFv0F9Jp8aSb6esRRzG6s1eb8BRx6ND4pOPpkfOXc', | ||
Check failure Code scanning / CodeQL Hard-coded credentials Critical
The hard-coded value "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyMDIwMjAyMC05ZTNiLTQ2ZDQtYTU1Ni04OGI5ZGRjMmIwMzQiLCJ3b3Jrc3BhY2VJZCI6IjIwMjAyMDIwLTFjMjUtNGQwMi1iZjI1LTZhZWNjZjdlYTQxOSIsImlhdCI6MTcxNDU1OTA2NSwiZXhwIjoxNzIyMzM1MDY1fQ.3OkFv0F9Jp8aSb6esRRzG6s1eb8BRx6ND4pOPpkfOXc" is used as
authorization header Error loading related location |
||
}, | ||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
|
||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] }, | ||
}, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'yarn start', | ||
// url: 'http://127.0.0.1:3001', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
Oops, something went wrong.