Skip to content

Commit

Permalink
Merge pull request #33 from FalkorDB/tests
Browse files Browse the repository at this point in the history
test implementation
  • Loading branch information
Naseem77 authored Jan 22, 2025
2 parents 2f77842 + fe7537e commit 18b2e46
Show file tree
Hide file tree
Showing 17 changed files with 692 additions and 6 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Playwright Tests

on:
push:
branches: master
pull_request:
branches: master

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./ui

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Set up environment and run tests
run: |
npm run build
npm start &
npx playwright test --reporter=dot,list
# Step 6: Upload Playwright report
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: playwright-report
path: ui/playwright-report/
retention-days: 30
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ falkor-results.md
falkor-metrics*.json
neo4j-metrics*.json
html

falkordb.log
.DS_Store
/ui/playwright-report
/ui/test-results
dump.rdb
index.html
queries.json
Expand Down
32 changes: 27 additions & 5 deletions ui/app/components/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ export default function DashBoard() {
: "0.00",
}));


//saving data to window.allChartData
/* eslint-disable */
if (typeof window !== "undefined") {
(window as any).allChartData = (window as any).allChartData || [];
const addOrReplaceChartData = (key: string, value: any) => {
const chartDataArray = (window as any).allChartData;
const existingIndex = chartDataArray.findIndex((entry: any) => entry.key === key);
if (existingIndex !== -1) {
chartDataArray.splice(existingIndex, 1);
}
chartDataArray.push({ key, value });
};

addOrReplaceChartData("throughputData", throughputData);
addOrReplaceChartData("deadlineData", deadlineData);
addOrReplaceChartData("memoryData", memoryData);
addOrReplaceChartData("cpuData", cpuData);
addOrReplaceChartData("latencyData", latencyData);
}


return (
<SidebarProvider className="h-screen w-screen overflow-hidden">
<div className="flex h-full w-full">
Expand All @@ -190,15 +212,15 @@ export default function DashBoard() {
/>
<SidebarInset className="flex-grow h-full min-h-0">
<div className="grid h-full grid-cols-2 grid-rows-[2fr,1fr,1fr,50px] gap-2 p-1">
<div className="col-span-2 bg-muted/50 rounded-xl p-4 min-h-0">
<div className="col-span-2 bg-muted/50 rounded-xl p-4 min-h-0" id="latency-chart">
<VerticalBarChart
data={latencyData}
title="Vendor Latency Metrics"
subTitle="P50, P95, and P99 Latency Comparison (less is better)"
xAxisTitle="Vendors"
/>
</div>
<div className="bg-muted/50 rounded-xl p-4 min-h-0">
<div className="bg-muted/50 rounded-xl p-4 min-h-0" id="throughput-chart">
<HorizontalBarChart
data={throughputData}
dataKey="actualMessagesPerSecond"
Expand All @@ -209,7 +231,7 @@ export default function DashBoard() {
unit=""
/>
</div>
<div className="bg-muted/50 rounded-xl p-4 min-h-0 relative">
<div className="bg-muted/50 rounded-xl p-4 min-h-0 relative" id="deadline-chart">
<HoverCard>
<HoverCardTrigger>
<span
Expand Down Expand Up @@ -237,7 +259,7 @@ export default function DashBoard() {
unit="min"
/>
</div>
<div className="bg-muted/50 rounded-xl p-4 min-h-0">
<div className="bg-muted/50 rounded-xl p-4 min-h-0" id="memory-chart">
<HorizontalBarChart
data={memoryData}
dataKey="memory"
Expand All @@ -248,7 +270,7 @@ export default function DashBoard() {
unit="mb"
/>
</div>
<div className="bg-muted/50 rounded-xl p-4 min-h-0">
<div className="bg-muted/50 rounded-xl p-4 min-h-0" id="cpu-chart">
<HorizontalBarChart
data={cpuData}
dataKey="cpu"
Expand Down
3 changes: 3 additions & 0 deletions ui/app/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const FooterComponent = () => {
<a
href="https://github.com/FalkorDB/benchmark/blob/master/readme.md#data"
className="hover:text-gray-800 flex items-center h-full whitespace-nowrap"
target="_blank"
>
DATASET USED <MoveUpRight size={16} />
</a>
Expand All @@ -23,6 +24,7 @@ const FooterComponent = () => {
<a
href="https://github.com/FalkorDB/benchmark/blob/master/readme.md"
className="hover:text-gray-800 flex items-center h-full whitespace-nowrap"
target="_blank"
>
README <MoveUpRight size={16} />
</a>
Expand All @@ -31,6 +33,7 @@ const FooterComponent = () => {
<a
href="https://github.com/FalkorDB/benchmark/blob/master/readme.md#faq"
className="hover:text-gray-800 flex items-center h-full whitespace-nowrap"
target="_blank"
>
FAQ <MoveUpRight size={16} />
</a>
Expand Down
2 changes: 2 additions & 0 deletions ui/app/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ export function Header() {
<a
href="https://app.falkordb.cloud/signup"
className="h-8 text-black font-medium text-base hover:underline flex text-center justify-center"
target="_blank"
>
Sign up
</a>
<a
href="https://falkordb.com/try-free/"
className="h-10 bg-gradient-to-r from-[#EC806C] via-[#B66EBD] to-[#7568F2] text-white font-medium text-base px-4 py-2 rounded-lg shadow-md hover:opacity-90 transition-all duration-200 flex text-center justify-center"
target="_blank"
>
Start Free
</a>
Expand Down
1 change: 1 addition & 0 deletions ui/components/ui/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const Sidebar = React.forwardRef<
data-collapsible={state === "collapsed" ? collapsible : ""}
data-variant={variant}
data-side={side}
id="sidebar-container"
>
{/* This is what handles the sidebar gap on desktop */}
<div
Expand Down
62 changes: 62 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"clsx": "^2.1.1",
"lucide-react": "^0.469.0",
"next": "15.1.3",
"playwright": "^1.49.1",
"react": "^19.0.0",
"react-chartjs-2": "^5.3.0",
"react-dom": "^19.0.0",
Expand All @@ -36,6 +37,7 @@
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@playwright/test": "^1.49.1",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
Expand Down
47 changes: 47 additions & 0 deletions ui/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests/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 ? 2 : 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://127.0.0.1:3000',

/* 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'] },
},
],
});
28 changes: 28 additions & 0 deletions ui/tests/config/testData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import urls from '../config/urls.json';

export const headerItems: { navItem: string; expectedRes: string }[] = [
{ navItem: "Home", expectedRes: urls.falkorDBUrl },
{ navItem: "Github", expectedRes: urls.benchmarkGithubUrl },
{ navItem: "Discord", expectedRes: urls.falkordbDiscordUrl },
{ navItem: "Sign up", expectedRes: urls.signUpUrl },
{ navItem: "Start Free", expectedRes: urls.startFreeUrl },
];

export const footerItems: { item: string; expectedRes: string }[] = [
{ item: "DATASET USED", expectedRes: urls.DatasetUrl },
{ item: "README", expectedRes: urls.ReadmeUrl },
{ item: "FAQ", expectedRes: urls.FAQUrl },
{ item: "RUN THE BENCHMARK", expectedRes: urls.runBenchmarkWithYourDataUrl },
];

export const sideBarItems: { item: string; expectedRes: boolean }[] = [
{ item: "MacBook", expectedRes: true },
{ item: "1000 m/s", expectedRes: true },
{ item: "40", expectedRes: true },
{ item: "Neo4j", expectedRes: false },
];

export const hoverItems: { item: string; expectedRes: boolean }[] = [
{ item: "MacBook", expectedRes: true },
{ item: "Linux", expectedRes: true },
];
12 changes: 12 additions & 0 deletions ui/tests/config/urls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"baseUrl": "http://localhost:3000/",
"falkorDBUrl": "https://www.falkordb.com/",
"benchmarkGithubUrl": "https://github.com/FalkorDB/benchmark",
"falkordbDiscordUrl": "https://discord.com/invite/99y2Ubh6tg",
"signUpUrl": "https://app.falkordb.cloud/signup",
"startFreeUrl": "https://www.falkordb.com/try-free/",
"DatasetUrl": "https://github.com/FalkorDB/benchmark/blob/master/readme.md#data",
"ReadmeUrl": "https://github.com/FalkorDB/benchmark/blob/master/readme.md",
"FAQUrl": "https://github.com/FalkorDB/benchmark/blob/master/readme.md#faq",
"runBenchmarkWithYourDataUrl": "https://github.com/FalkorDB/benchmark/blob/master/readme.md#installation-steps"
}
Loading

0 comments on commit 18b2e46

Please sign in to comment.