Skip to content

Commit

Permalink
feat: Quiz Landing Page (#1)
Browse files Browse the repository at this point in the history
* ci: trigger

* ci: test deploy

* feat: hero section

* desktop layout done

* install playwright

* set up vitest

* tweak playwright config

* add failing e2e test

* wip: quiz dialog

* basic logic working, requires refactoring for clarity

* fix prettier violations

* remove unused test

* refactor: separate dialog from the quiz itself

* dialog styles

* style the quiz

* fix: question option sourceset urls

* wip: question nav

* wire up new question stepper

* refactor: move nav to its own file

avoids the Next.js RSC boundary warning

* refactoring

* refactor

* style the quiz result

* make two options use a different number of grid columns

* basic animation when a choice is made

* fix test

* add state for quiz result

* normalise the quiz state

* refactor: extract a component for the quiz option

* ensure user feedback even when rejecting

* add custom arePropsEqual function to useMemo

* custom arePropsEqual function causing issues

sometimes the option doesn't get selected

* responsive design for landing page

* responsive styles for the quiz

* docs: add project details

* adjust footer padding on mobile

* adjust colours
  • Loading branch information
aaronmcadam authored Aug 6, 2024
1 parent b8f44ca commit 68030bc
Show file tree
Hide file tree
Showing 29 changed files with 2,770 additions and 63 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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: Build
run: pnpm run build
- name: Install Playwright Browsers
run: pnpm run e2e:install
- name: Run Playwright tests
run: pnpm run e2e
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test

on:
pull_request:

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run tests
run: pnpm test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# MANUAL Quiz Landing Page Case Study

This project implements a landing page and quiz user flow.

![Screenshot](./docs/screenshot.png)

## Designs

The designs for the mobile and desktop experience are here: https://www.figma.com/design/JfC25Hjs0TfhrhW36kQpfA/MANUAL-Landing-Page?node-id=0-1&t=t61nmefRY10vysI8-1

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
## Testing

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
We use Playwright for end to end tests. To run the tests headlessly, run ```pnpm e2e```. To run them with a UI, run `pnpm e2e:ui`.
Binary file added docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
"lint": "next lint",
"prettier": "prettier --check 'src/**/*.{ts,tsx,js,jsx,html,css}'",
"prettier:fix": "prettier --check --write 'src/**/*.{ts,tsx,js,jsx,html,css}'",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"test": "vitest src",
"e2e": "playwright test",
"e2e:install": "playwright install --with-deps chromium",
"e2e:ui": "playwright test --ui"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-slot": "^1.1.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand All @@ -23,6 +28,7 @@
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@playwright/test": "^1.45.3",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand All @@ -31,6 +37,7 @@
"postcss": "^8",
"prettier": "3.3.3",
"tailwindcss": "^3.4.1",
"typescript": "^5"
"typescript": "^5",
"vitest": "^2.0.5"
}
}
70 changes: 70 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { defineConfig, devices } from "@playwright/test";

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

const PORT = process.env.PORT || "3000";

/**
* 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:${PORT}/`,

/* 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"] },
},

/* 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: process.env.CI ? "pnpm start" : "pnpm dev",
port: Number(PORT),
reuseExistingServer: !process.env.CI,
},
});
Loading

0 comments on commit 68030bc

Please sign in to comment.