-
Notifications
You must be signed in to change notification settings - Fork 4
DRAFT Julianna/playwright-POC #489
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
Draft
mathematiCode
wants to merge
8
commits into
develop
Choose a base branch
from
Julianna/Playwright
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9dbc9bc
Test: Proof of Concept Playwright Auth
mathematiCode 69968a0
Chore: Delete package.lock
mathematiCode cb511c9
chore: Changed everything to use testId
mathematiCode 74142ba
Delete playwright-report/index.html
mathematiCode 06254e0
test: delete path variable from getSupabaseClient function
mathematiCode 41fe0cc
Merge branch 'develop' into Julianna/Playwright
mathematiCode 756b9fc
chore: remove unnecessary param from JSDoc
mathematiCode e26f801
Merge branch 'develop' into Julianna/Playwright
mathematiCode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Copyright (c) Gridiron Survivor. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { test, expect } from '@playwright/test'; | ||
| import { getSupabaseClient } from '../utils/auth-setup'; | ||
| test('Logged in user who hasn’t completed onboarding sees onboarding', async ({ | ||
| page, | ||
| }) => { | ||
| await getSupabaseClient(page, 'playwrightuser@test.com'); | ||
| await page.goto('/'); | ||
| await expect(page).toHaveURL('/onboarding'); | ||
| await expect(page.getByTestId('onboarding-card')).toBeVisible(); | ||
| await expect( | ||
| page.getByRole('button', { name: 'Next', exact: true }), | ||
| ).toBeVisible(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright (c) Gridiron Survivor. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test('has title', async ({ page }) => { | ||
| await page.goto('/'); | ||
|
|
||
| await expect(page.getByTestId('hero-title')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('has 4 features', async ({ page }) => { | ||
| await page.goto('/'); | ||
|
|
||
| await expect(page.getByTestId('feature')).toHaveCount(4); | ||
| }); | ||
|
|
||
| test('has 3 steps', async ({ page }) => { | ||
| await page.goto('/'); | ||
|
|
||
| await expect(page.getByTestId('step')).toHaveCount(3); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Gridiron Survivor. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { createClient } from '@supabase/supabase-js'; | ||
| import { Page } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * Get a Supabase client with authentication set up for Playwright tests | ||
| * @param page - The Playwright page object | ||
| * @param userEmail - The email of the user to sign in as | ||
| * @returns Promise that resolves when authentication is set up | ||
| */ | ||
| async function getSupabaseClient(page: Page, userEmail: string): Promise<void> { | ||
| const supabaseClient = createClient( | ||
| process.env.NEXT_PUBLIC_SUPABASE_URL!, | ||
| process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, | ||
| ); | ||
|
|
||
| const { data, error } = await supabaseClient.auth.signInWithPassword({ | ||
| email: userEmail, | ||
| password: 'password', | ||
| }); | ||
| if (!data.user) { | ||
| throw Error(error?.message); | ||
| } | ||
|
|
||
| const projectRef = process.env | ||
| .NEXT_PUBLIC_SUPABASE_URL!.split('//')[1] | ||
| .split('.')[0]; | ||
| await page.context().addCookies([ | ||
| { | ||
| name: `sb-${projectRef}-auth-token`, | ||
| value: JSON.stringify({ | ||
| access_token: data.session.access_token, | ||
| refresh_token: data.session.refresh_token, | ||
| expires_in: 3600, | ||
| expires_at: Math.floor(Date.now() / 1000) + 3600, | ||
| token_type: 'bearer', | ||
| user: { | ||
| id: data.user.id, | ||
| email: data.user.email, | ||
| }, | ||
| }), | ||
| domain: 'localhost', | ||
| path: '/', | ||
| httpOnly: false, | ||
| secure: false, | ||
| }, | ||
| ]); | ||
| } | ||
|
|
||
| export { getSupabaseClient }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are the environment variables being setup on the server?