Skip to content

Commit c8fdef5

Browse files
committed
initial commit
0 parents  commit c8fdef5

40 files changed

+19878
-0
lines changed

.github/workflows/validate.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: deploy
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- 'main'
11+
pull_request:
12+
branches:
13+
- 'main'
14+
jobs:
15+
setup:
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest, macos-latest]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: ⬇️ Checkout repo
22+
uses: actions/checkout@v4
23+
24+
- name: ⎔ Setup node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 23
28+
29+
- name: ▶️ Run setup script
30+
run: npm run setup
31+
32+
# - name: ʦ TypeScript
33+
# run: npm run typecheck
34+
35+
- name: ⬣ ESLint
36+
run: npm run lint
37+
38+
deploy:
39+
name: 🚀 Deploy
40+
runs-on: ubuntu-latest
41+
# only deploy main branch on pushes on non-forks
42+
if:
43+
${{ github.ref == 'refs/heads/main' && github.event_name == 'push' &&
44+
github.repository_owner == 'epicweb-dev' }}
45+
46+
steps:
47+
- name: ⬇️ Checkout repo
48+
uses: actions/checkout@v4
49+
50+
- name: 🎈 Setup Fly
51+
uses: superfly/flyctl-actions/[email protected]
52+
53+
- name: 🚀 Deploy
54+
run: flyctl deploy --remote-only
55+
working-directory: ./epicshop
56+
env:
57+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
node_modules
2+
3+
workspace/
4+
**/.cache/
5+
**/build/
6+
**/dist/
7+
**/public/build
8+
**/playwright-report
9+
data.db
10+
/playground
11+
**/tsconfig.tsbuildinfo
12+
**/*.tsbuildinfo
13+
__screenshots__
14+
*.sqlite
15+
test-profiles
16+
coverage
17+
.vitest-reports
18+
*.DS_Store

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npmjs.org/
2+
legacy-peer-deps=true

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/node_modules/**
2+
**/.cache/**
3+
**/build/**
4+
**/dist/**
5+
**/public/**
6+
**/package-lock.json
7+
**/playwright-report/**
8+
**/.github/workflows/ci.yml

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode",
5+
"neotan.vscode-auto-restart-typescript-eslint-servers",
6+
"qwtel.sqlite-viewer"
7+
]
8+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"typescript.preferences.autoImportFileExcludePatterns": [
3+
"@remix-run/server-runtime",
4+
"@remix-run/router",
5+
"react-router-dom",
6+
"react-router"
7+
],
8+
"workbench.editorAssociations": {
9+
"*.db": "sqlite-viewer.view"
10+
}
11+
}

LICENSE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This material is available for private, non-commercial use under the
2+
[GPL version 3](http://www.gnu.org/licenses/gpl-3.0-standalone.html). If you
3+
would like to use this material to conduct your own workshop, please contact us
4+

README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<div align="center">
2+
<h1><a href="https://www.epicweb.dev/workshops">End-to-end React Application Testing with Playwright</a></h1>
3+
<strong>
4+
</strong>
5+
</div>
6+
7+
<hr />
8+
9+
<div align="center">
10+
<a
11+
alt="Epic Web logo with the words Deployed Version"
12+
href="https://e2e-react-application-testing-with-playwright.epicweb.dev/"
13+
>
14+
<img
15+
width="300px"
16+
src="https://github-production-user-asset-6210df.s3.amazonaws.com/1500684/254000390-447a3559-e7b9-4918-947a-1b326d239771.png"
17+
/>
18+
</a>
19+
</div>
20+
21+
<hr />
22+
23+
<!-- prettier-ignore-start -->
24+
[![Build Status][build-badge]][build]
25+
[![GPL 3.0 License][license-badge]][license]
26+
[![Code of Conduct][coc-badge]][coc]
27+
<!-- prettier-ignore-end -->
28+
29+
## Prerequisites
30+
31+
> TODO
32+
33+
## Pre-workshop Resources
34+
35+
> TODO
36+
37+
## System Requirements
38+
39+
- [git][git] v2.18 or greater
40+
- **[NodeJS][node] v23.11.0 or greater**
41+
- [npm][npm] v8 or greater
42+
43+
All of these must be available in your `PATH`. To verify things are set up
44+
properly, you can run this:
45+
46+
```shell
47+
git --version
48+
node --version
49+
npm --version
50+
```
51+
52+
If you have trouble with any of these, learn more about the PATH environment
53+
variable and how to fix it here for [windows][win-path] or
54+
[mac/linux][mac-path].
55+
56+
## Setup
57+
58+
This is a pretty large project (it's actually many apps in one) so it can take
59+
several minutes to get everything set up the first time. Please have a strong
60+
network connection before running the setup and grab a snack.
61+
62+
> **Warning**: This repo is _very_ large. Make sure you have a good internet
63+
> connection before you start the setup process. The instructions below use
64+
> `--depth` to limit the amount you download, but if you have a slow connection,
65+
> or you pay for bandwidth, you may want to find a place with a better
66+
> connection.
67+
68+
Follow these steps to get this set up:
69+
70+
```sh nonumber
71+
git clone --depth 1 https://github.com/epicweb-dev/e2e-react-application-testing-with-playwright.git
72+
cd e2e-react-application-testing-with-playwright
73+
npm run setup
74+
```
75+
76+
If you experience errors here, please open [an issue][issue] with as many
77+
details as you can offer.
78+
79+
## The Workshop App
80+
81+
Learn all about the workshop app on the
82+
[Epic Web Getting Started Guide](https://www.epicweb.dev/get-started).
83+
84+
[![Kent with the workshop app in the background](https://github-production-user-asset-6210df.s3.amazonaws.com/1500684/280407082-0e012138-e01d-45d5-abf2-86ffe5d03c69.png)](https://www.epicweb.dev/get-started)
85+
86+
<!-- prettier-ignore-start -->
87+
[npm]: https://www.npmjs.com/
88+
[node]: https://nodejs.org
89+
[git]: https://git-scm.com/
90+
[build-badge]: https://img.shields.io/github/actions/workflow/status/epicweb-dev/e2e-react-application-testing-with-playwright/validate.yml?branch=main&logo=github&style=flat-square
91+
[build]: https://github.com/epicweb-dev/e2e-react-application-testing-with-playwright/actions?query=workflow%3Avalidate
92+
[license-badge]: https://img.shields.io/badge/license-GPL%203.0%20License-blue.svg?style=flat-square
93+
[license]: https://github.com/epicweb-dev/e2e-react-application-testing-with-playwright/blob/main/LICENSE
94+
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
95+
[coc]: https://kentcdodds.com/conduct
96+
[win-path]: https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
97+
[mac-path]: http://stackoverflow.com/a/24322978/971592
98+
[issue]: https://github.com/epicweb-dev/e2e-react-application-testing-with-playwright/issues/new
99+
<!-- prettier-ignore-end -->

epicshop/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npmjs.org/
2+
legacy-peer-deps=true

epicshop/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:20-bookworm-slim as base
2+
3+
RUN apt-get update && apt-get install -y git
4+
5+
ENV EPICSHOP_CONTEXT_CWD="/myapp/workshop-content"
6+
ENV EPICSHOP_DEPLOYED="true"
7+
ENV EPICSHOP_DISABLE_WATCHER="true"
8+
ENV FLY="true"
9+
ENV PORT="8080"
10+
ENV NODE_ENV="production"
11+
12+
WORKDIR /myapp
13+
14+
ADD . .
15+
16+
RUN npm install --omit=dev
17+
18+
CMD rm -rf ${EPICSHOP_CONTEXT_CWD} && \
19+
git clone https://github.com/epicweb-dev/e2e-react-application-testing-with-playwright ${EPICSHOP_CONTEXT_CWD} && \
20+
cd ${EPICSHOP_CONTEXT_CWD} && \
21+
npx epicshop start

epicshop/fix-watch.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
import chokidar from 'chokidar'
4+
import { $ } from 'execa'
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7+
const here = (...p) => path.join(__dirname, ...p)
8+
9+
const workshopRoot = here('..')
10+
11+
const watchPath = path.join(workshopRoot, './exercises/*')
12+
const watcher = chokidar.watch(watchPath, {
13+
ignored: /(^|[\/\\])\../, // ignore dotfiles
14+
persistent: true,
15+
ignoreInitial: true,
16+
depth: 2,
17+
})
18+
19+
const debouncedRun = debounce(run, 200)
20+
21+
// Add event listeners.
22+
watcher
23+
.on('addDir', (path) => {
24+
debouncedRun()
25+
})
26+
.on('unlinkDir', (path) => {
27+
// Only act if path contains two slashes (excluding the leading `./`)
28+
debouncedRun()
29+
})
30+
.on('error', (error) => console.log(`Watcher error: ${error}`))
31+
32+
/**
33+
* Simple debounce implementation
34+
*/
35+
function debounce(fn, delay) {
36+
let timer = null
37+
return (...args) => {
38+
if (timer) clearTimeout(timer)
39+
timer = setTimeout(() => {
40+
fn(...args)
41+
}, delay)
42+
}
43+
}
44+
45+
let running = false
46+
47+
async function run() {
48+
if (running) {
49+
console.log('still running...')
50+
return
51+
}
52+
running = true
53+
try {
54+
await $({
55+
stdio: 'inherit',
56+
cwd: workshopRoot,
57+
})`node ./epicshop/fix.js`
58+
} catch (error) {
59+
throw error
60+
} finally {
61+
running = false
62+
}
63+
}
64+
65+
console.log(`watching ${watchPath}`)
66+
67+
// doing this because the watcher doesn't seem to work and I don't have time
68+
// to figure out why 🙃
69+
console.log('Polling...')
70+
setInterval(() => {
71+
run()
72+
}, 1000)
73+
74+
console.log('running fix to start...')
75+
run()

0 commit comments

Comments
 (0)