2blo / before-effects

before-effects.vercel.app
0 stars 0 forks source link

Increase test coverage #68

Open 2blo opened 1 year ago

2blo commented 1 year ago

pages that should not be accessible

we dont care too much about ux, users will just see this page if they try to mess up, dont care about middleware for now.

CI issues

reuse

other

2blo commented 1 year ago
npm run start
npm run cypress -- --e2e

https://nextjs.org/docs/testing

2blo commented 1 year ago

from the twitter thread: use if checks on path, and a global matcher https://nextjs.org/docs/advanced-features/middleware#conditional-statements

can prevent nav to edit page with nextauth middleware, but it seems to show a blank loading state for a while on every nav.

2blo commented 1 year ago

mock vs credentials

access to delete post is gated by userid == session.user.id

progress

if we hardcode post.upload with the users id, it works, still cant delete tho:

the backend context is not the same as the frontend context... thats why we get undefined user constraint, the backend user is different

id we hardcode the id, instead of cuid create + delete works... just need to find out how to sync them..

2blo commented 1 year ago

"When you write Cypress tests for Next.js apps, you can’t mock requests coming from SSR. You can only mock requests coming from the browser via cy.intercept()." https://blog.byndyusoft.com/testing-next-js-website-with-cypress-a8475fd087e2

2blo commented 1 year ago

plan, borrowed from https://dev.to/kuroski/writing-integration-tests-for-nextjs-next-auth-prisma-using-playwright-and-msw-388m

2blo commented 1 year ago

tRPC failed on post.upload: TRPCError: UNAUTHORIZED

2blo commented 1 year ago

https://nextjs.org/docs/advanced-features/ci-build-caching#github-actions cache .npm, + .next/cache, not node_modules, it has some compiled packages, and is not used by npm ci

2blo commented 1 year ago

missing if cache hit https://dev.to/drakulavich/aggressive-dependency-caching-in-github-actions-3c64

also, can we make cache different for .next and .npm

setup node has built in cache https://github.com/actions/setup-node#caching-global-packages-data

there is no native npm build, it just runs next build "build": "next build",