Skip to content

Commit

Permalink
feat: initial project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sand4rt committed Jun 14, 2024
0 parents commit 75c294b
Show file tree
Hide file tree
Showing 34 changed files with 3,672 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [sand4rt]
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---


10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---


26 changes: 26 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy
on:
release:
types: [created]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: pnpm/action-setup@v2
with:
version: '9.x'

- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
scope: '@sand4rt'

- run: pnpm publish --filter eslint-plugin-playwright-ct --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v2
with:
version: '9.x'

- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build packages
run: pnpm build

- name: Install Playwright Browsers
run: pnpm dlx playwright install --with-deps

- name: Run Playwright tests
run: pnpm test

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./*/**/playwright-report/
retention-days: 30
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*playwright-report
*.cache
*test-results
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 🎭 ESLint Plugin Playwright component testing

> **Note**
> This package is work in progress
## Usage

Install the package with PNPM, NPM or Yarn:

```sh
pnpm add -D eslint-plugin-playwright-ct
```
```sh
npm install -D eslint-plugin-playwright-ct
```
```sh
yarn add -D eslint-plugin-playwright-ct
```

### [Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) _(eslint.config.js)_

TODO

### [Legacy config](https://eslint.org/docs/latest/use/configure/configuration-files) _(.eslintrc)_

TODO
24 changes: 24 additions & 0 deletions ct-react-vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
21 changes: 21 additions & 0 deletions ct-react-vite/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
import { fixupConfigRules } from "@eslint/compat";
import playwright from "eslint-plugin-playwright-ct";

export default [
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.all,
...tseslint.configs.recommended,
{
...playwright,
files: ["tests/**"],
},
{
files: ["**/*.jsx"],
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
},
...fixupConfigRules(pluginReactConfig),
];
13 changes: 13 additions & 0 deletions ct-react-vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions ct-react-vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "ct-react-vite",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"typecheck": "tsc --noEmit",
"eslint": "eslint ."
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.1"
},
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@eslint/js": "^9.5.0",
"@playwright/experimental-ct-react": "^1.44.1",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "9.x",
"eslint-plugin-react": "^7.34.2",
"globals": "^15.4.0",
"typescript": "^5.2.2",
"typescript-eslint": "^7.13.0",
"vite": "^5.2.8"
}
}
52 changes: 52 additions & 0 deletions ct-react-vite/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { defineConfig, devices } from '@playwright/experimental-ct-react';
import { resolve } from 'path';

export default defineConfig({
testDir: 'tests',
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? 'html' : 'line',
use: {
trace: 'on-first-retry',
ctViteConfig: {
build: {
assetsInlineLimit: 0,
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
}
}
}
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});
13 changes: 13 additions & 0 deletions ct-react-vite/playwright/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
1 change: 1 addition & 0 deletions ct-react-vite/playwright/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../src/assets/index.css';
20 changes: 20 additions & 0 deletions ct-react-vite/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Routes, Route, Link } from 'react-router-dom';
import logo from './assets/logo.svg';
import LoginPage from './pages/LoginPage';
import DashboardPage from './pages/DashboardPage';

export default function App() {
return <>
<header>
<img src={logo} alt="logo" width={125} height={125} />
<Link to="/">Login</Link>
<Link to="/dashboard">Dashboard</Link>
</header>
<Routes>
<Route path="/">
<Route index element={<LoginPage />} />
<Route path="dashboard" element={<DashboardPage />} />
</Route>
</Routes>
</>
}
15 changes: 15 additions & 0 deletions ct-react-vite/src/assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ct-react-vite/src/assets/iconfont.woff2
Binary file not shown.
29 changes: 29 additions & 0 deletions ct-react-vite/src/assets/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

@media (prefers-color-scheme: light) {
:root {
color: #e3e3e3;
background-color: #1b1b1d;
}
}

@font-face {
font-family: 'pwtest-iconfont';
/* See tests/assets/webfont/README.md */
src: url('./iconfont.woff2') format('woff2');
font-weight: normal;
font-style: normal;
font-display: swap;
}
7 changes: 7 additions & 0 deletions ct-react-vite/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions ct-react-vite/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ButtonHTMLAttributes } from 'react';

type ButtonProps = {
title: string;
onClick?(props: string): void;
className?: string;
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>;

export default function Button({ onClick, title, ...attributes }: ButtonProps) {
return <button {...attributes} onClick={() => onClick?.('hello')}>
{title}
</button>
}
Loading

0 comments on commit 75c294b

Please sign in to comment.