Skip to content

Commit

Permalink
Merge pull request #19 from mikikiv/replace-cypress-with-playwright
Browse files Browse the repository at this point in the history
Replace cypress with playwright
  • Loading branch information
mikikiv authored Dec 27, 2023
2 parents 495c64b + 08c63ae commit e6bd3d7
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 128 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/main.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .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@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ next-env.d.ts
#extension
/extensionReqs/extension.*
/extension
extension.crx
extension.crx
**/*.zip

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
7 changes: 2 additions & 5 deletions components/AliasedEmails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ import { useEffect, useState } from "react"
import { useAtom } from "jotai"
import { colorSelector } from "@/utils/colorSelector"
import { localCopyHistoryAtom } from "./global/CopyHistory"
import { AliasType } from "@/components/types"

type Props = { extension?: boolean }
type Alias = {
label: string
value: string
}

export default function InputCreator({ extension }: Props) {
const [email, setEmail] = useLocalStorage({ key: "email", defaultValue: "" })
const [aliases, setAliases] = useLocalStorage({
key: "aliases",
defaultValue: [] as Alias[],
defaultValue: [] as AliasType[],
})
const [selectedAlias, setSelectedAlias] = useLocalStorage({
key: "selectedAlias",
Expand Down
24 changes: 7 additions & 17 deletions components/global/CopyHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { IconCopy } from "@tabler/icons-react"
import { colorSelector } from "@/utils/colorSelector"
import { useRouter } from "next/router"
import { CopyHistoryType } from "@/components/types"

type Props = {
type?: "email" | "text"
Expand All @@ -23,20 +24,9 @@ type Props = {
scrollThreshold: number
}

export type CopyHistory = {
id: number
type: string
value: string
timestamp?: number
}

interface GroupedCopyHistory {
[dateKey: number]: CopyHistory[]
}

export const localCopyHistoryAtom = atomWithStorage(
"copyHistory",
[] as CopyHistory[]
[] as CopyHistoryType[]
)

export default function CopyHistory({ type, tooltip, scrollThreshold }: Props) {
Expand Down Expand Up @@ -115,7 +105,7 @@ export default function CopyHistory({ type, tooltip, scrollThreshold }: Props) {
historyItem,
...rest
}: {
historyItem: CopyHistory
historyItem: CopyHistoryType
}) => {
return (
<CopyButton value={historyItem.value} timeout={5000}>
Expand Down Expand Up @@ -176,8 +166,8 @@ export default function CopyHistory({ type, tooltip, scrollThreshold }: Props) {
}
}

const groupedData: { [key: string]: CopyHistory[] } = copyHistory.reduce(
(acc: { [key: string]: CopyHistory[] }, item) => {
const groupedData: { [key: string]: CopyHistoryType[] } = copyHistory.reduce(
(acc: { [key: string]: CopyHistoryType[] }, item) => {
let itemTimestamp = item.timestamp
if (itemTimestamp == undefined || itemTimestamp == null) {
itemTimestamp = new Date(946800000000).getTime()
Expand All @@ -192,7 +182,7 @@ export default function CopyHistory({ type, tooltip, scrollThreshold }: Props) {
}
return groupedData
},
{} as { [key: string]: CopyHistory[] }
{} as { [key: string]: CopyHistoryType[] }
)

const dateKeys = Object.keys(groupedData)
Expand Down Expand Up @@ -260,7 +250,7 @@ export default function CopyHistory({ type, tooltip, scrollThreshold }: Props) {
{groupedData[dates]
.sort()
.reverse()
.map((historyItem: CopyHistory) => (
.map((historyItem: CopyHistoryType) => (
<CopyHistoryItem
historyItem={historyItem}
key={historyItem.id}
Expand Down
19 changes: 19 additions & 0 deletions components/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export type AliasType = {
label: string
value: string
}

export type CopyHistoryType = {
id: number
type: string
value: string
timestamp?: number
}

export type TotalLocalStorage = [
{ name: "selectedAlias"; value: string },
{ name: "email"; value: string },
{ name: "copyHistory"; value: CopyHistoryType[] },
{ name: "aliases"; value: AliasType[] },
{ name: "timestampEnabled"; value: boolean | "true" | "false" }
]
23 changes: 0 additions & 23 deletions cypress/e2e/aliasedEmail.cy.ts

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

37 changes: 0 additions & 37 deletions cypress/support/commands.ts

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/e2e.ts

This file was deleted.

Binary file removed extension.zip
Binary file not shown.
64 changes: 62 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "cypress run",
"test": "playwright test",
"test-dev": "playwright test --ui",
"vercel-build": "next build",
"build:extension": "extensionReqs/build.sh"
},
Expand All @@ -50,6 +51,7 @@
},
"devDependencies": {
"@faker-js/faker": "^8.1.0",
"@playwright/test": "^1.40.1",
"@swc-jotai/react-refresh": "^0.0.8",
"cypress": "^13.6.0"
}
Expand Down
Loading

1 comment on commit e6bd3d7

@vercel
Copy link

@vercel vercel bot commented on e6bd3d7 Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.