Skip to content

Commit 7d1aeac

Browse files
committed
Move encryption spec to Playwright
1 parent 761f2fb commit 7d1aeac

File tree

5 files changed

+48
-45
lines changed

5 files changed

+48
-45
lines changed

components/CoreInput.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ onMounted(() => {
132132
:value="modelProxy"
133133
class="unset-all cursor-text block min-h-0 overflow-hidden resize-none placeholder-muted"
134134
:class="{ 'whitespace-nowrap': !multiline }"
135+
data-core-input
135136
@input="modelProxy = $event.target.value"
136137
@keypress.enter="handleEnter"
137138
/>

test/cypress/e2e/encryption.cy.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

test/e2e/encryption.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { readFileSync } from 'node:fs'
2+
import { expect, test } from '@playwright/test'
3+
4+
const publicKey = readFileSync('./test/fixtures/encryption/test-key.public').toString()
5+
const privateKey = readFileSync('./test/fixtures/encryption/test-key.private').toString()
6+
7+
test.describe('encryption', () => {
8+
test.beforeEach(async ({ page }) => {
9+
await page.goto('/')
10+
await page.evaluate(async () => {
11+
// Allow the file to be processed by Vite.
12+
await import('/_nuxt/test/e2e/seed-encrypted-docs')
13+
})
14+
})
15+
16+
test('does not show docs that cannot be decrypted', async ({ page }) => {
17+
await page.goto('/docs')
18+
await page.waitForSelector('[data-is-mounted="true"]')
19+
20+
expect(await page.locator('[data-test-doc]').count()).toEqual(0)
21+
})
22+
23+
test('shows docs that can be decrypted', async ({ page }) => {
24+
await page.goto('/settings')
25+
await page.waitForSelector('[data-is-mounted="true"]')
26+
27+
await page.locator('[data-test-public-key] [data-core-input]').fill(publicKey.trim())
28+
await page.locator('[data-test-private-key] [data-core-input]').fill(privateKey.trim())
29+
await page.locator('[data-test-toggle-crypto]:not([disabled])').click()
30+
31+
await page.goto('/docs')
32+
await page.waitForSelector('[data-is-mounted="true"]')
33+
34+
expect(await page.locator('[data-test-doc]').count()).toEqual(3)
35+
})
36+
})

test/e2e/seed-encrypted-docs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { db } from '/src/db'
2+
import docs from '/test/fixtures/encryption/docs.json' with { type: 'json' }
3+
4+
await Promise.all(
5+
docs.map(async (doc: any) => {
6+
await db.docs.put(doc, doc.id)
7+
}),
8+
)

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
"/*": [
5252
"./*"
5353
],
54+
"/_nuxt/*": [
55+
"./*"
56+
],
5457
"#components": [
5558
"./components"
5659
],

0 commit comments

Comments
 (0)