Skip to content

Commit

Permalink
ci: create cypress e2e workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiquinho committed Jun 25, 2024
1 parent 82231ae commit 6e233ff
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/run-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Cypress Tests

on: push

jobs:
cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: action/setup-node@v3
with:
node-version: 20

- name: Install PNPM
uses: pnpm/action-setup@v4
with:
version: 8
run_install: false

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

- name: Cypress run
uses: cypress-io/github-action@v6
env:
APP_URL: "http://localhost:3000"
NEXT_PUBLIC_API_BASE_URL: "https://ignite-devstore-api-three-delta.vercel.app"
with:
build: npm run build
start: npm start
6 changes: 6 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
images: {
remotePatterns: [
{
Expand Down
11 changes: 10 additions & 1 deletion src/app/(store)/search/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import { Skeleton } from '@/components/skeleton'
import { useSearchParams } from 'next/navigation'
import { Suspense } from 'react'

export default function SearchLoading() {
function SearchLoadingBase() {
const searchParams = useSearchParams()

const query = searchParams.get('q')
Expand All @@ -25,3 +26,11 @@ export default function SearchLoading() {
</div>
)
}

export default function SearchLoading() {
return (
<Suspense>
<SearchLoadingBase />
</Suspense>
)
}
12 changes: 10 additions & 2 deletions src/components/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { Search } from 'lucide-react'
import { useRouter, useSearchParams } from 'next/navigation'
import { FormEvent } from 'react'
import { FormEvent, Suspense } from 'react'

export function SearchForm() {
function SearchFormBase() {
const router = useRouter()
const searchParams = useSearchParams()

Expand Down Expand Up @@ -41,3 +41,11 @@ export function SearchForm() {
</form>
)
}

export function SearchForm() {
return (
<Suspense>
<SearchFormBase />
</Suspense>
)
}

0 comments on commit 6e233ff

Please sign in to comment.