-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(performance): add performance form
This adds performance check form to check response time for backend to catch regression Signed-off-by: Danil Kostromin <[email protected]>
- Loading branch information
Danil Kostromin
committed
Feb 22, 2024
1 parent
f0da04d
commit 6db5f74
Showing
24 changed files
with
646 additions
and
2 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
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,4 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* SPDX-FileCopyrightText: 2024 OKTET LTD */ | ||
|
||
export * from './performance.page'; |
16 changes: 16 additions & 0 deletions
16
apps/bublik/src/pages/performance-page/performance.page.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,16 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* SPDX-FileCopyrightText: 2024 OKTET LTD */ | ||
|
||
import { PerformanceListContainer } from '@/bublik/features/performance-check'; | ||
|
||
export const PerformancePage = () => { | ||
return ( | ||
<div className="h-screen p-2"> | ||
<div className="h-full flex justify-center items-center"> | ||
<div className="max-w-4xl flex-1 bg-white rounded-lg p-4"> | ||
<PerformanceListContainer /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nx/react/babel", | ||
{ | ||
"runtime": "automatic", | ||
"useBuiltIns": "usage" | ||
} | ||
] | ||
], | ||
"plugins": [] | ||
} |
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,18 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,7 @@ | ||
# performance-check | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test performance-check` to execute the unit tests via [Vitest](https://vitest.dev/). |
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,20 @@ | ||
{ | ||
"name": "performance-check", | ||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/bublik/features/performance-check/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": ["{options.outputFile}"] | ||
}, | ||
"test": { | ||
"executor": "@nx/vite:test", | ||
"outputs": ["{options.reportsDirectory}"], | ||
"options": { | ||
"reportsDirectory": "../../../../coverage/libs/bublik/features/performance-check" | ||
} | ||
} | ||
} | ||
} |
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,3 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* SPDX-FileCopyrightText: 2024 OKTET LTD */ | ||
export * from './lib/performance-list.container'; |
47 changes: 47 additions & 0 deletions
47
...features/performance-check/src/lib/__snapshots__/performance-list.component.spec.tsx.snap
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,47 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`<PerformanceList /> > should match snapshot 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="flex flex-col gap-2" | ||
> | ||
<h2 | ||
class="text-xl font-semibold" | ||
> | ||
Health Check | ||
</h2> | ||
<ul | ||
class="flex flex-col gap-2" | ||
> | ||
<li | ||
class="flex items-center gap-2 justify-between border border-border-primary rounded px-4 py-2" | ||
> | ||
<a | ||
class="flex-1 flex-shrink-0 hover:underline text-primary" | ||
href="https://google.com" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
Google (1s) | ||
</a> | ||
<span | ||
class="tabular-nums w-[8ch] flex-1" | ||
> | ||
<div | ||
class="animate-pulse bg-gray-300 rounded-md h-[16px] w-[8ch] flex-1" | ||
/> | ||
</span> | ||
<div | ||
class="w-3 h-3 rounded-full relative bg-gray-300" | ||
/> | ||
</li> | ||
</ul> | ||
<button | ||
class="inline-flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-all appearance-none select-none disabled:shadow-[inset_0_0_0_1px_hsl(var(--colors-border-primary))] disabled:bg-white disabled:hover:bg-white disabled:text-text-menu px-3 text-[0.875rem] leading-[1.5rem] cursor-not-allowed pointer-events-none rounded-md hover:shadow-[inset_0_0_0_3px_#94b0ff] py-2 shadow-[inset_0_0_0_1px_hsl(var(--colors-border-primary))] bg-white hover:bg-white text-border-primary" | ||
disabled="" | ||
> | ||
Check | ||
</button> | ||
</div> | ||
</DocumentFragment> | ||
`; |
17 changes: 17 additions & 0 deletions
17
libs/bublik/features/performance-check/src/lib/performance-list.component.spec.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,17 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* SPDX-FileCopyrightText: 2024 OKTET LTD */ | ||
import { describe, expect, it } from 'vitest'; | ||
import { render } from '@testing-library/react'; | ||
import { PerformanceList } from './performance-list.component'; | ||
|
||
describe('<PerformanceList />', () => { | ||
it('should match snapshot', () => { | ||
const { asFragment } = render( | ||
<PerformanceList | ||
urls={[{ url: 'https://google.com', timeout: 1, label: 'Google' }]} | ||
/> | ||
); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
87 changes: 87 additions & 0 deletions
87
libs/bublik/features/performance-check/src/lib/performance-list.component.stories.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,87 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* SPDX-FileCopyrightText: 2024 OKTET LTD */ | ||
import { Meta, StoryFn, StoryObj } from '@storybook/react'; | ||
|
||
import { withBackground } from '@/shared/tailwind-ui'; | ||
|
||
import { | ||
PerformanceList, | ||
PerformanceListEmpty, | ||
PerformanceListError, | ||
PerformanceListLoading | ||
} from './performance-list.component'; | ||
|
||
const meta = { | ||
title: 'performance/Performance List', | ||
decorators: [ | ||
withBackground, | ||
(story) => <div className={'min-w-[400px]'}>{story()}</div> | ||
] | ||
} satisfies Meta<typeof PerformanceList>; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof PerformanceList>; | ||
|
||
const Template: StoryFn<typeof PerformanceList> = (args) => ( | ||
<PerformanceList {...args} /> | ||
); | ||
|
||
export const Primary = { | ||
render: Template, | ||
args: { | ||
urls: [ | ||
{ | ||
label: 'Google', | ||
url: 'https://www.google.com/', | ||
timeout: 1 | ||
}, | ||
{ | ||
label: 'GitHub', | ||
url: 'https://github.com/', | ||
timeout: 10 | ||
}, | ||
{ | ||
label: 'Amazon', | ||
url: 'https://www.amazon.com/', | ||
timeout: 10 | ||
}, | ||
{ | ||
label: 'Facebook', | ||
url: 'https://www.facebook.com/', | ||
timeout: 10 | ||
}, | ||
{ | ||
label: 'Twitter', | ||
url: 'https://twitter.com/', | ||
timeout: 10 | ||
}, | ||
{ | ||
label: 'LinkedIn', | ||
url: 'https://www.linkedin.com/', | ||
timeout: 10 | ||
}, | ||
{ | ||
label: 'Wikipedia', | ||
url: 'https://www.wikipedia.org/', | ||
timeout: 10 | ||
}, | ||
{ | ||
label: 'Netflix', | ||
url: 'https://www.netflix.com/', | ||
timeout: 10 | ||
} | ||
] | ||
} | ||
} satisfies Story; | ||
|
||
export const Loading = { | ||
render: () => <PerformanceListLoading /> | ||
} satisfies Story; | ||
|
||
export const Empty = { | ||
render: () => <PerformanceListEmpty /> | ||
} satisfies Story; | ||
|
||
export const Error = { | ||
render: () => <PerformanceListError error={{ status: 404 }} /> | ||
} satisfies Story; |
Oops, something went wrong.