Skip to content

Commit

Permalink
🚧/🔥: Work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
xannyxs committed Jul 9, 2024
1 parent 0d5ebd4 commit 9bb79b1
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 326 deletions.
160 changes: 0 additions & 160 deletions packages/app/.cache-synpress/wallet-setup-dist/basic.setup.mjs

This file was deleted.

4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "next start -H 0.0.0.0 -p 3000",
"lint": "next lint",
"check-types": "tsc --noEmit --incremental",
"test:ui": "playwright test --ui",
"test:ui": "dotenvx run -f test.env -- playwright test --ui",
"test": "dotenvx run -f test.env -- playwright test",
"prettier:fix": "prettier --write './app' './components' './lib' ./tests",
"prettier:check": "prettier --check './app' './components' './lib' ./tests/"
Expand Down Expand Up @@ -100,7 +100,6 @@
"devDependencies": {
"@dotenvx/dotenvx": "^1.0.1",
"@playwright/test": "^1.37.0",
"@synthetixio/synpress": "^3.7.3",
"@tailwindcss/typography": "^0.5.10",
"@types/fluent-ffmpeg": "^2.1.21",
"@types/fuzzy-search": "^2.1.5",
Expand All @@ -112,6 +111,7 @@
"dotenv": "^16.4.5",
"eslint": "8.50.0",
"eslint-config-next": "^14.0.2",
"jose": "^5.6.2",
"next-bundle-analyzer": "^0.6.8",
"tailwind-merge": "^2.2.0",
"tailwindcss": "3.3.2",
Expand Down
63 changes: 0 additions & 63 deletions packages/app/tests/fixtures.ts

This file was deleted.

65 changes: 57 additions & 8 deletions packages/app/tests/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
import { test, expect } from '@playwright/test'
import { getAccessToken } from '@privy-io/react-auth'
import * as jose from 'jose'

test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:3000/studio')
})

test('sign in button exists', async ({ page }) => {
await page.keyboard.press('Escape')
async function generatePrivyJWT() {
const { publicKey, privateKey } = await jose.generateKeyPair(
'ES256'
)

const button = page.getByRole('button')
await expect(button).toBeVisible()
})
console.log(process.env.PRIVY_APP_ID)

const session = 'test-session-' + Date.now()
const subject = 'did:privy:test-' + Date.now()
const issuer = 'privy.io'
const audience = process.env.PRIVY_APP_ID || ''
const expiration = '1h'

const authToken = await new jose.SignJWT({ sid: session })
.setProtectedHeader({ alg: 'ES256', typ: 'JWT' })
.setIssuer(issuer)
.setIssuedAt()
.setAudience(audience)
.setSubject(subject)
.setExpirationTime(expiration)
.sign(privateKey)

try {
const payload = await jose.jwtVerify(authToken, publicKey, {
issuer: 'privy.io',
audience: process.env.PRIVY_APP_ID || '',
})
console.log('JWT verified successfully. Payload:', payload)
} catch (error) {
console.error(`JWT failed to verify with error: ${error}`)
throw error
}

return authToken
}

test('login to studio page with Privy JWT', async ({ page }) => {
const authToken = await generatePrivyJWT()
const accessToken = await getAccessToken()

console.log(accessToken)

await page.goto('http://localhost:3000/studio/create', {
waitUntil: 'networkidle',
})

await page.evaluate((token) => {
localStorage.setItem('privy:auth:token', token)
}, authToken)

await page.reload({ waitUntil: 'networkidle' })

expect(page.url()).toContain('/studio')

test('login with metamask', async ({ page }) => {
const button = page.getByRole('button')
await expect(button).toBeVisible()
await expect(page.locator('text=Studio')).toBeVisible({
timeout: 30000,
})
})
36 changes: 0 additions & 36 deletions packages/app/tests/mock.spec.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/app/tests/synpress.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/app/tests/wallet-setup/basic.setup.ts

This file was deleted.

Loading

0 comments on commit 9bb79b1

Please sign in to comment.