Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Quiz Landing Page #1

Merged
merged 36 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5da8944
ci: trigger
aaronmcadam Aug 1, 2024
2800f9c
ci: test deploy
aaronmcadam Aug 1, 2024
ba8ebac
feat: hero section
aaronmcadam Aug 1, 2024
82d9173
desktop layout done
aaronmcadam Aug 1, 2024
f3cd25a
install playwright
aaronmcadam Aug 1, 2024
c8aeaef
set up vitest
aaronmcadam Aug 1, 2024
16320da
tweak playwright config
aaronmcadam Aug 1, 2024
82cf37c
add failing e2e test
aaronmcadam Aug 1, 2024
c80db9e
wip: quiz dialog
aaronmcadam Aug 1, 2024
535d002
basic logic working, requires refactoring for clarity
aaronmcadam Aug 1, 2024
7ece474
fix prettier violations
aaronmcadam Aug 1, 2024
a59535d
remove unused test
aaronmcadam Aug 1, 2024
741eedf
refactor: separate dialog from the quiz itself
aaronmcadam Aug 2, 2024
289549c
dialog styles
aaronmcadam Aug 2, 2024
7c94799
style the quiz
aaronmcadam Aug 2, 2024
d0d7d68
fix: question option sourceset urls
aaronmcadam Aug 2, 2024
7efeafe
wip: question nav
aaronmcadam Aug 2, 2024
fc897e2
wire up new question stepper
aaronmcadam Aug 2, 2024
53f0273
refactor: move nav to its own file
aaronmcadam Aug 2, 2024
204c8a4
refactoring
aaronmcadam Aug 2, 2024
1c9a44f
refactor
aaronmcadam Aug 2, 2024
5cefde0
style the quiz result
aaronmcadam Aug 2, 2024
635d412
make two options use a different number of grid columns
aaronmcadam Aug 2, 2024
3f24b76
basic animation when a choice is made
aaronmcadam Aug 2, 2024
177a61b
fix test
aaronmcadam Aug 5, 2024
d233d52
add state for quiz result
aaronmcadam Aug 5, 2024
90b00b7
normalise the quiz state
aaronmcadam Aug 5, 2024
639d4e4
refactor: extract a component for the quiz option
aaronmcadam Aug 5, 2024
ce1a12c
ensure user feedback even when rejecting
aaronmcadam Aug 5, 2024
0fd7146
add custom arePropsEqual function to useMemo
aaronmcadam Aug 5, 2024
ab0b810
custom arePropsEqual function causing issues
aaronmcadam Aug 5, 2024
4a458bd
responsive design for landing page
aaronmcadam Aug 5, 2024
77297f7
responsive styles for the quiz
aaronmcadam Aug 5, 2024
5368d08
docs: add project details
aaronmcadam Aug 6, 2024
5fe8a31
adjust footer padding on mobile
aaronmcadam Aug 6, 2024
e00f4e6
adjust colours
aaronmcadam Aug 6, 2024
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
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