Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions apps/web/.github/workflows/playwright.yml
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 pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
10 changes: 9 additions & 1 deletion apps/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

qodana.yaml
qodana.yaml

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
12 changes: 6 additions & 6 deletions apps/web/components/ui/resizable-navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import {
import React, { useRef, useState } from "react";


interface NavbarProps {
export interface NavbarProps {
children: React.ReactNode;
className?: string;
}

interface NavBodyProps {
export interface NavBodyProps {
children: React.ReactNode;
className?: string;
visible?: boolean;
}

interface NavItemsProps {
export interface NavItemsProps {
items: {
name: string;
href: string;
Expand All @@ -31,18 +31,18 @@ interface NavItemsProps {
onItemClick?: () => void;
}

interface MobileNavProps {
export interface MobileNavProps {
children: React.ReactNode;
className?: string;
visible?: boolean;
}

interface MobileNavHeaderProps {
export interface MobileNavHeaderProps {
children: React.ReactNode;
className?: string;
}

interface MobileNavMenuProps {
export interface MobileNavMenuProps {
children: React.ReactNode;
className?: string;
isOpen: boolean;
Expand Down
34 changes: 34 additions & 0 deletions apps/web/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const nextJest = require('next/jest')

const createJestConfig = nextJest({
dir: './',
})

const config = {
coverageProvider: 'v8',
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^@repo/ui$': '<rootDir>/__mocks__/repo-ui.ts',
},
testMatch: [
'**/__tests__/**/*.test.[jt]s?(x)',
'**/*.test.[jt]s?(x)',
],
testPathIgnorePatterns: [
'/node_modules/',
'/tests/e2e/',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
collectCoverageFrom: [
'components/**/*.{js,jsx,ts,tsx}',
'!components/**/*.stories.{js,jsx,ts,tsx}',
'!components/**/*.test.{js,jsx,ts,tsx}',
],
transformIgnorePatterns: [
'node_modules/(?!(motion|@tabler/icons-react)/)',
],
}

module.exports = createJestConfig(config)
35 changes: 35 additions & 0 deletions apps/web/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import '@testing-library/jest-dom'

// Mock window.matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})

// Mock IntersectionObserver
global.IntersectionObserver = class IntersectionObserver {
constructor() {}
disconnect() {}
observe() {}
takeRecords() {
return []
}
unobserve() {}
}

// Mock ResizeObserver
global.ResizeObserver = class ResizeObserver {
constructor() {}
disconnect() {}
observe() {}
unobserve() {}
}
19 changes: 16 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"type-check": "tsc --noEmit"
"type-check": "tsc --noEmit",
"test": "jest",
"test:unit": "jest",
"test:e2e": "playwright test" ,
"test:e2e-ui": "playwright test --ui"
},
"dependencies": {
"@ai-sdk/openai": "^1.3.23",
Expand Down Expand Up @@ -92,14 +96,23 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@playwright/test": "^1.56.1",
"@repo/config": "workspace:*",
"@repo/jest-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
"@types/jest": "^30.0.0",
"@types/node": "^22",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react": "^19.1.9",
"@types/react-dom": "^19.1.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^30.2.0",
"msw": "^2.11.6",
"postcss": "^8.5",
"tailwindcss": "^3.4.17",
"ts-node": "^10.9.2",
"typescript": "^5"
}
}
87 changes: 87 additions & 0 deletions apps/web/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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/e2e',
/* 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:3000',
baseURL: 'http://localhost:3000',
headless: true,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

webServer: {
command: 'npm run dev', // or "next start" for production build
port: 3000,
reuseExistingServer: !process.env.CI, // speeds up local runs
timeout: 120_000, // 2 minutes to start server
},

/* 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: 'npm run start',
// url: 'http://localhost:3000',
// reuseExistingServer: !process.env.CI,
// },
});
42 changes: 42 additions & 0 deletions apps/web/tests/e2e/homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { test, expect } from '@playwright/test';

test.describe('Script AI front-page', () => {

test('should load the homepage and show main sections', async ({ page,baseURL }) => {
await page.goto(baseURL!);

// Check title contains expected text
await expect(page).toHaveTitle(/Script AI/i);


// Check β€œGet Started” button exists
const btnGetStarted = page.locator('a', { hasText: /Get Started/i });
await expect(btnGetStarted).toBeVisible();

// Scroll to pricing section
await page.locator('text=Pricing').scrollIntoViewIfNeeded();
const pricingHeading = page.locator('h3', { hasText: /Starter/i });
await expect(pricingHeading).toBeVisible();

// Check that Starter plan displays $0/mo
const starterPlan = page.locator('text=Starter').locator('..').locator('text=$0/mo');
await expect(starterPlan).toBeVisible();
});

// test('should navigate to login page when clicking β€œLog In”', async ({ page }) => {
// await page.goto(baseURL);

// const loginLink = page.locator('a', { hasText: /Log in/i });
// await expect(loginLink).toBeVisible();
// await loginLink.click();

// // Expect URL to change (adjust path as appropriate)
// await expect(page).toHaveURL(/login/i);

// // Optionally check login form fields
// const emailField = page.locator('input[type="email"]');
// await expect(emailField).toBeVisible();
// const passwordField = page.locator('input[type="password"]');
// await expect(passwordField).toBeVisible();
// });
});
Loading
Loading