test files in cli and cross with password

This commit is contained in:
2023-05-25 10:17:01 +02:00
parent b43b802221
commit fb95a68b0d
13 changed files with 225 additions and 62 deletions

View File

@@ -0,0 +1,53 @@
import { test } from '@playwright/test'
import { CLI, checkLinkForDownload, checkLinkForText, createNote, getLinkFromCLI } from '../../utils'
import { Files, getFileChecksum, rm, tmpFile } from '../../files'
import { basename } from 'path'
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'
test.describe('text @cross', () => {
test('cli to web', async ({ page }) => {
const file = await tmpFile(Files.Image)
const checksum = await getFileChecksum(file)
const note = await CLI('send', 'file', file)
const link = getLinkFromCLI(note.stdout)
await rm(file)
await checkLinkForDownload(page, { link, text: basename(file), checksum })
})
test('cli to web with password', async ({ page }) => {
const file = await tmpFile(Files.Image)
const checksum = await getFileChecksum(file)
const note = await CLI('send', 'file', file, '--password', password)
const link = getLinkFromCLI(note.stdout)
await rm(file)
await checkLinkForDownload(page, { link, text: basename(file), checksum, password })
})
test('web to cli', async ({ page }) => {
const files = [Files.Image]
const checksum = await getFileChecksum(files[0])
const link = await createNote(page, { files })
const filename = basename(files[0])
await CLI('open', link, '--all')
const c = await getFileChecksum(filename)
await rm(basename(filename))
test.expect(checksum).toBe(c)
})
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 filename = basename(files[0])
await CLI('open', link, '--all', '--password', password)
const c = await getFileChecksum(filename)
await rm(basename(filename))
test.expect(checksum).toBe(c)
})
})

View File

@@ -1,14 +1,15 @@
import { test } from '@playwright/test'
import { CLI, checkLinkForText, createNote } from '../../utils'
import { CLI, checkLinkForText, createNote, 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'
test.describe('text @cross', () => {
test('cli to web', async ({ page }) => {
const note = await CLI('send', 'text', text)
const link = note.stdout.trim().replace(/(.|\s)*http/g, 'http')
const link = getLinkFromCLI(note.stdout)
await checkLinkForText(page, link, text)
await checkLinkForText(page, { link, text })
})
test('web to cli', async ({ page }) => {
@@ -16,4 +17,16 @@ test.describe('text @cross', () => {
const retrieved = await CLI('open', link)
test.expect(retrieved.stdout.trim()).toBe(text)
})
test('cli to web with password', async ({ page }) => {
const note = await CLI('send', 'text', text, '--password', password)
const link = getLinkFromCLI(note.stdout)
await checkLinkForText(page, { link, text, password })
})
test('web to cli with password', async ({ page }) => {
const link = await createNote(page, { text, password })
const retrieved = await CLI('open', link, '--password', password)
test.expect(retrieved.stdout.trim()).toBe(text)
})
})