Compare commits

...

10 Commits

Author SHA1 Message Date
e15d9eb537 upload artifacts 2024-08-27 00:42:21 +02:00
7fe70a6f3b revert 2024-08-27 00:38:56 +02:00
d86ef79abd use container 2024-08-27 00:36:48 +02:00
23446a4c74
Merge branch 'main' into actix-2-axum 2024-08-27 00:32:28 +02:00
ee92928d1f pipeline 2024-08-27 00:32:17 +02:00
b60a079bbe
Merge pull request #140 from elfakyn/main
Fix typos in english localization
2024-08-27 00:23:28 +02:00
ba474dff31 more robust config 2024-08-27 00:22:41 +02:00
3cb002ee33
Merge branch 'main' into main 2024-08-27 00:10:44 +02:00
a10d8735dd cleanup tests 2024-08-27 00:09:51 +02:00
Arya ';--bscriptalert(":)")/script
8ccfdd6e2e
fix typos in english localization 2024-07-04 18:00:06 -04:00
13 changed files with 60 additions and 48 deletions

View File

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
# Node
- uses: pnpm/action-setup@v3
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
@ -27,13 +27,16 @@ jobs:
- name: Prepare
run: |
pnpm install --frozen-lockfile
pnpm install
pnpm exec playwright install --with-deps
pnpm run test:prepare
- name: Run your tests
run: pnpm test
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: test-results
path: test-results
name: playwright-report
path: test-results/
retention-days: 7

View File

@ -17,5 +17,5 @@
"npm-run-all": "^4.1.5",
"shelljs": "^0.8.5"
},
"packageManager": "pnpm@9.8.0"
"packageManager": "pnpm@9.9.0"
}

View File

@ -25,7 +25,7 @@
"new_note": "new note",
"new_note_notice": "<b>availability:</b><br />the note is not guaranteed to be stored as everything is kept in ram, if it fills up the oldest notes will be removed.<br />(you probably will be fine, just be warned.)",
"errors": {
"note_to_big": "could not create note. note is to big",
"note_to_big": "could not create note. note is too big",
"note_error": "could not create note. please try again.",
"max": "max: {n}",
"empty_content": "note is empty."
@ -44,7 +44,7 @@
"decryption_failed": "wrong password. could not decipher. probably a broken link. note was destroyed.",
"unsupported_type": "unsupported note type."
},
"explanation": "click below to show and delete the note if the counter has reached it's limit",
"explanation": "click below to show and delete the note if the counter has reached its limit",
"show_note": "show note",
"warning_will_not_see_again": "you will <b>not</b> get the chance to see the note again.",
"download_all": "download all",

View File

@ -4,13 +4,12 @@ const config: PlaywrightTestConfig = {
use: {
video: 'retain-on-failure',
baseURL: 'http://localhost:3000',
actionTimeout: 10_000,
actionTimeout: 30_000,
},
outputDir: './test-results',
testDir: './test',
timeout: 30_000,
fullyParallel: true,
webServer: {
command: 'docker compose -f docker-compose.dev.yaml up',

View File

@ -1,7 +1,8 @@
import { test } from '@playwright/test'
import { CLI, checkLinkForDownload, checkLinkForText, createNote, getLinkFromCLI } from '../../utils'
import { Files, getFileChecksum, rm, tmpFile } from '../../files'
import { basename } from 'path'
import { rm } from 'node:fs/promises'
import { basename } from 'node:path'
import { Files, getFileChecksum, tmpFile } from '../../files'
import { CLI, checkLinkForDownload, createNoteSuccessfully, getLinkFromCLI } from '../../utils'
const text = `Endless prejudice endless play derive joy eternal-return selfish burying. Of decieve play pinnacle faith disgust. Spirit reason salvation burying strong of joy ascetic selfish against merciful sea truth. Ubermensch moral prejudice derive chaos mountains ubermensch justice philosophy justice ultimate joy ultimate transvaluation. Virtues convictions war ascetic eternal-return spirit. Ubermensch transvaluation noble revaluation sexuality intentions salvation endless decrepit hope noble fearful. Justice ideal ultimate snare god joy evil sexuality insofar gains oneself ideal.`
const password = 'password'
@ -30,7 +31,7 @@ test.describe('text @cross', () => {
test('web to cli', async ({ page }) => {
const files = [Files.Image]
const checksum = await getFileChecksum(files[0])
const link = await createNote(page, { files })
const link = await createNoteSuccessfully(page, { files })
const filename = basename(files[0])
await CLI('open', link, '--all')
@ -42,7 +43,7 @@ test.describe('text @cross', () => {
test('web to cli with password', async ({ page }) => {
const files = [Files.Image]
const checksum = await getFileChecksum(files[0])
const link = await createNote(page, { files, password })
const link = await createNoteSuccessfully(page, { files, password })
const filename = basename(files[0])
await CLI('open', link, '--all', '--password', password)

View File

@ -1,5 +1,5 @@
import { test } from '@playwright/test'
import { CLI, checkLinkForText, createNote, getLinkFromCLI } from '../../utils'
import { CLI, checkLinkForText, createNoteSuccessfully, getLinkFromCLI } from '../../utils'
const text = `Endless prejudice endless play derive joy eternal-return selfish burying. Of decieve play pinnacle faith disgust. Spirit reason salvation burying strong of joy ascetic selfish against merciful sea truth. Ubermensch moral prejudice derive chaos mountains ubermensch justice philosophy justice ultimate joy ultimate transvaluation. Virtues convictions war ascetic eternal-return spirit. Ubermensch transvaluation noble revaluation sexuality intentions salvation endless decrepit hope noble fearful. Justice ideal ultimate snare god joy evil sexuality insofar gains oneself ideal.`
const password = 'password'
@ -13,7 +13,7 @@ test.describe('text @cross', () => {
})
test('web to cli', async ({ page }) => {
const link = await createNote(page, { text })
const link = await createNoteSuccessfully(page, { text })
const retrieved = await CLI('open', link)
test.expect(retrieved.stdout.trim()).toBe(text)
})
@ -25,7 +25,7 @@ test.describe('text @cross', () => {
})
test('web to cli with password', async ({ page }) => {
const link = await createNote(page, { text, password })
const link = await createNoteSuccessfully(page, { text, password })
const retrieved = await CLI('open', link, '--password', password)
test.expect(retrieved.stdout.trim()).toBe(text)
})

View File

@ -6,17 +6,22 @@ import { getFileChecksum } from './files'
const exec = promisify(execFile)
type CreatePage = {
text?: string
files?: string[]
views?: number
expiration?: number
error?: string
password?: string
}
export async function createNote(page: Page, options: CreatePage): Promise<string> {
} & (
| {
text: string
}
| {
files: string[]
}
)
async function createNote(page: Page, options: CreatePage): Promise<void> {
await page.goto('/')
if (options.text) {
if ('text' in options) {
await page.getByTestId('text-field').fill(options.text)
} else if (options.files) {
await page.getByTestId('switch-file').click()
@ -31,7 +36,8 @@ export async function createNote(page: Page, options: CreatePage): Promise<strin
if (options.views || options.expiration || options.password) await page.getByTestId('switch-advanced').click()
if (options.views) {
await page.getByTestId('field-views').fill(options.views.toString())
} else if (options.expiration) {
}
if (options.expiration) {
await page.getByTestId('switch-advanced-toggle').click()
await page.getByTestId('field-expiration').fill(options.expiration.toString())
}
@ -41,15 +47,18 @@ export async function createNote(page: Page, options: CreatePage): Promise<strin
}
await page.locator('button:has-text("create")').click()
}
if (options.error) {
await expect(page.locator('.error-text')).toContainText(options.error, { timeout: 60_000 })
}
// Return share link
export async function createNoteSuccessfully(page: Page, options: CreatePage): Promise<string> {
await createNote(page, options)
return await page.getByTestId('share-link').inputValue()
}
export async function createNoteError(page: Page, options: CreatePage, error: string): Promise<void> {
await createNote(page, options)
await expect(page.locator('._toastContainer')).toContainText(error)
}
type CheckLinkBase = {
link: string
text: string
@ -69,7 +78,7 @@ export async function checkLinkForDownload(page: Page, options: CheckLinkBase &
const path = await download.path()
if (!path) throw new Error('Download failed')
const cs = await getFileChecksum(path)
await expect(cs).toBe(options.checksum)
expect(cs).toBe(options.checksum)
}
export async function checkLinkForText(page: Page, options: CheckLinkBase) {
@ -78,7 +87,7 @@ export async function checkLinkForText(page: Page, options: CheckLinkBase) {
if (options.password) await page.getByTestId('show-note-password').fill(options.password)
await page.getByTestId('show-note-button').click()
const text = await page.getByTestId('result').locator('.note').innerText()
await expect(text).toContain(options.text)
expect(text).toContain(options.text)
}
export async function checkLinkDoesNotExist(page: Page, link: string) {

View File

@ -1,12 +1,12 @@
import { test } from '@playwright/test'
import { Files, getFileChecksum } from '../../files'
import { checkLinkForDownload, createNote } from '../../utils'
import { checkLinkForDownload, createNoteSuccessfully } from '../../utils'
test.describe('@web', () => {
test('multiple', async ({ page }) => {
const files = [Files.PDF, Files.Image]
const checksums = await Promise.all(files.map(getFileChecksum))
const link = await createNote(page, { files, views: 2 })
const link = await createNoteSuccessfully(page, { files, views: 2 })
await checkLinkForDownload(page, { link, text: 'image.jpg', checksum: checksums[1] })
await checkLinkForDownload(page, { link, text: 'AES.pdf', checksum: checksums[0] })
})

View File

@ -1,11 +1,11 @@
import { test } from '@playwright/test'
import { Files, getFileChecksum } from '../../files'
import { checkLinkDoesNotExist, checkLinkForDownload, checkLinkForText, createNote } from '../../utils'
import { checkLinkDoesNotExist, checkLinkForDownload, checkLinkForText, createNoteSuccessfully } from '../../utils'
test.describe('@web', () => {
test('simple pdf', async ({ page }) => {
const files = [Files.PDF]
const link = await createNote(page, { files })
const link = await createNoteSuccessfully(page, { files })
await checkLinkForText(page, { link, text: 'AES.pdf' })
await checkLinkDoesNotExist(page, link)
})
@ -13,21 +13,21 @@ test.describe('@web', () => {
test('pdf content', async ({ page }) => {
const files = [Files.PDF]
const checksum = await getFileChecksum(files[0])
const link = await createNote(page, { files })
const link = await createNoteSuccessfully(page, { files })
await checkLinkForDownload(page, { link, text: 'AES.pdf', checksum })
})
test('image content', async ({ page }) => {
const files = [Files.Image]
const checksum = await getFileChecksum(files[0])
const link = await createNote(page, { files })
const link = await createNoteSuccessfully(page, { files })
await checkLinkForDownload(page, { link, text: 'image.jpg', checksum })
})
test('simple pdf with password', async ({ page }) => {
const files = [Files.PDF]
const password = 'password'
const link = await createNote(page, { files, password })
const link = await createNoteSuccessfully(page, { files, password })
await checkLinkForText(page, { link, text: 'AES.pdf', password })
await checkLinkDoesNotExist(page, link)
})

View File

@ -1,10 +1,10 @@
import { test } from '@playwright/test'
import { createNote } from '../../utils'
import { Files } from '../../files'
import { createNoteError } from '../../utils'
test.describe('@web', () => {
test('to big zip', async ({ page }) => {
const files = [Files.Zip]
await createNote(page, { files, error: 'note is to big' })
await createNoteError(page, { files }, 'note is to big')
})
})

View File

@ -1,5 +1,5 @@
import { test } from '@playwright/test'
import { checkLinkDoesNotExist, checkLinkForText, createNote } from '../../utils'
import { checkLinkDoesNotExist, checkLinkForText, createNoteSuccessfully } from '../../utils'
test.describe('@web', () => {
test('1 minute', async ({ page }) => {
@ -7,7 +7,7 @@ test.describe('@web', () => {
const minutes = 1
const timeout = minutes * 60_000
test.setTimeout(timeout * 2)
const link = await createNote(page, { text, expiration: minutes })
const link = await createNoteSuccessfully(page, { text, expiration: minutes })
await checkLinkForText(page, { link, text })
await checkLinkForText(page, { link, text })
await page.waitForTimeout(timeout)

View File

@ -1,17 +1,17 @@
import { test } from '@playwright/test'
import { checkLinkForText, createNote } from '../../utils'
import { checkLinkForText, createNoteSuccessfully } from '../../utils'
test.describe('@web', () => {
test('simple', async ({ page }) => {
const text = `Endless prejudice endless play derive joy eternal-return selfish burying. Of deceive play pinnacle faith disgust. Spirit reason salvation burying strong of joy ascetic selfish against merciful sea truth. Ubermensch moral prejudice derive chaos mountains ubermensch justice philosophy justice ultimate joy ultimate transvaluation. Virtues convictions war ascetic eternal-return spirit. Ubermensch transvaluation noble revaluation sexuality intentions salvation endless decrepit hope noble fearful. Justice ideal ultimate snare god joy evil sexuality insofar gains oneself ideal.`
const link = await createNote(page, { text })
const link = await createNoteSuccessfully(page, { text })
await checkLinkForText(page, { link, text })
})
test('simple with password', async ({ page }) => {
const text = 'Foo bar'
const password = '123'
const shareLink = await createNote(page, { text, password })
const shareLink = await createNoteSuccessfully(page, { text, password })
await checkLinkForText(page, { link: shareLink, text, password })
})
})

View File

@ -1,17 +1,17 @@
import { test } from '@playwright/test'
import { checkLinkDoesNotExist, checkLinkForText, createNote } from '../../utils'
import { checkLinkDoesNotExist, checkLinkForText, createNoteSuccessfully } from '../../utils'
test.describe('@web', () => {
test('only shown once', async ({ page }) => {
const text = `Christian victorious reason suicide dead. Right ultimate gains god hope truth burying selfish society joy. Ultimate.`
const link = await createNote(page, { text })
const link = await createNoteSuccessfully(page, { text })
await checkLinkForText(page, { link, text })
await checkLinkDoesNotExist(page, link)
})
test('view 3 times', async ({ page }) => {
const text = `Justice holiest overcome fearful strong ultimate holiest christianity.`
const link = await createNote(page, { text, views: 3 })
const link = await createNoteSuccessfully(page, { text, views: 3 })
await checkLinkForText(page, { link, text })
await checkLinkForText(page, { link, text })
await checkLinkForText(page, { link, text })