-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth smoke tests #4673
Auth smoke tests #4673
Conversation
Update fixture
…ecks-smoke-test * 'main' of github.com:redwoodjs/redwood: Clean console.log in dev tools (redwoodjs#4671)
…ecks-smoke-test * 'main' of github.com:redwoodjs/redwood: Update dependency graphql-helix to v1.12.0 (redwoodjs#4692) Update dependency @supabase/supabase-js to v1.31.1 (redwoodjs#4690) Update dependency css-loader to v6.7.1 (redwoodjs#4691) update yarn.lock v0.49.0 Update dependency @azure/msal-browser to v2.22.1 (redwoodjs#4686) Update dependency magic-sdk to v8.1.0 (redwoodjs#4684) run smoke-test on Node 14 and 16 Update typescript-eslint monorepo to v5.14.0 (redwoodjs#4687) Update dependency fastify to v3.27.3 (redwoodjs#4683) Update dependency @supabase/supabase-js to v1.31.0 (redwoodjs#4677) Update dependency @auth0/auth0-spa-js to v1.20.1 (redwoodjs#4682) Codemod for webhook verifier option renaming (redwoodjs#4675)
It's alive! It's alive! |
@thedavidprice do you want to start reviewing? Awaiting merging the other PR (just holding till Rob does a once over) - then will regenerate the fixture. |
|
||
describe('ProfilePage', () => { | ||
it('renders successfully', async () => { | ||
mockCurrentUser({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lets us verify that mockCurrentUser is working
</tr> | ||
</thead> | ||
<tbody> | ||
{Object.keys(currentUser).map((key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just prints the keys from currentUser in useAuth.
// "port" fixture uses a unique value of the worker process index. | ||
await use(9000 + workerInfo.workerIndex) | ||
await use(9000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes here are because we actually don't want to spin up multiple dev servers (because our dev process regenerates some files)
This does not affect running tests in parallel though, because browser contexts are isolated
fs.writeFileSync( | ||
path.join(process.env.PROJECT_PATH, 'scripts/makeAdmin.ts'), | ||
` | ||
import { db } from 'api/src/lib/db' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use rw exec to convert the user to an admin
'<td>EMAIL</td><td>[email protected]</td>' | ||
) | ||
|
||
// const isAdminRow = await page.waitForSelector('*css=tr >> text=Is Admin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will enable once the other PR is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SuperHelpfulReminder™
- do the thing you were waiting to do here
return root | ||
.findJSXElements('Route') | ||
.filter( | ||
j.filters.JSXElement.hasAttributes({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finds the <Route path="/profile"/>
and wraps in a <Private>
component
@thedavidprice ready to merge! ✅✅✅✅✅✅✅ |
…d into feat/auth-checks-smoke-test * 'feat/auth-checks-smoke-test' of github.com:dac09/redwood: fix(deps): update dependency esbuild to v0.14.27 (redwoodjs#4755) chore(deps): update dependency cypress to v9.5.2 (redwoodjs#4754) chore(deps): update dependency @types/lodash to v4.14.180 (redwoodjs#4751) fix(deps): update typescript-eslint monorepo to v5.15.0 (redwoodjs#4752) fix(deps): update dependency esbuild to v0.14.26 (redwoodjs#4747) Setup futureExpiresDate in constructor (redwoodjs#4742) chore(deps): update dependency @clerk/clerk-sdk-node to v2.9.10 (redwoodjs#4746) fix(deps): update dependency eslint-plugin-react to v7.29.4 (redwoodjs#4745)
Use contacts count to have more reliable tests
…d into feat/auth-checks-smoke-test * 'feat/auth-checks-smoke-test' of github.com:dac09/redwood: chore(deps): update dependency @playwright/test to v1.20.0 (redwoodjs#4757)
…ecks-smoke-test * 'main' of github.com:redwoodjs/redwood: ignore @types/lru-cache (redwoodjs#4759) chore(deps): update dependency zx to v5.3.0 (redwoodjs#4758)
I've updated it again. I had some git issues apparently (or just a problem between the keyboard and the chair) - didn't have the latest RBAC tests. I've also updated the auth checks, because I realised that we were getting false positives with the error selectors... painfulllll 😭 |
@dac09 Contacts work looks 🤯
Just so I'm clear, you mean:
Local Test-project dbAuth still not workingI still can't get local dbAuth to work (see previous comment above). I hope it's just because I'm missing something obvious. If I'm reading the auth tests correctly, you're able to create a user and login (note: the login and home redirect should happen at the same time new user successfully created). But I can do that successfully when I try locally. Steps to reproduce:
Working Not working I'm at a loss... something obvious I'm missing? Safari-15Mar22_12-54-22.mp4Testing Main BranchI now believe dbAuth is broken in |
Confirmed this is a bug in main. See #4767 @dac09 Again, I don't know why the auth smoke test is passing if I understand correctly that it's stepping through creating a user and logging in. If the test was failing and/or we confirm the behavior is 1-to-1, it will be helpful to merge this PR in order to resolve #4767 And/or the fix can be applied here. I could be doing something wrong, but right now I can't figure out what that might be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to resolve dbAuth login bug #4767
TBD if we resolve here and then merge or merge and use this to resolve
Issue was specific to Safari. We were missing #4722 I'm will update and rebuild fixture. Then we're gtg 🚀 |
Add Auth smoke tests
This PR does the following:
a) Is wrappedin
<Private>
b) Uses
useAuth
and prints some of the valuesc) Adds signup and login tests
d) Adds playwright tests to check auth props are rendered correctly
e) Adds tests to check for redirects
f) Adds RBAC checks to see
i) If
hasRole("ADMIN")
returns trueii) deleteContact with
@requireAuth(roles: ["ADMIN"])
directive works as expectedg) Adds unit test for ProfilePage, which lets us double check
mockCurrentUser
is working in unit testsTodo:
Closes #4486