cryptgeon/test/cli/file/simple.spec.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

import { test } from '@playwright/test'
import { basename } from 'node:path'
2024-08-25 20:21:45 +00:00
import { rm } from 'node:fs/promises'
import { Files, getFileChecksum, tmpFile } from '../../files'
import { CLI, getLinkFromCLI } from '../../utils'
test.describe('file @cli', () => {
2024-08-25 20:21:45 +00:00
test('simple', async () => {
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 CLI('open', link, '--all')
const c = await getFileChecksum(basename(file))
await rm(basename(file))
test.expect(checksum).toBe(c)
})
2024-08-25 20:21:45 +00:00
test('simple with password', async () => {
const file = await tmpFile(Files.Image)
const password = 'password'
const checksum = await getFileChecksum(file)
const note = await CLI('send', 'file', file, '--password', password)
const link = getLinkFromCLI(note.stdout)
await rm(file)
await CLI('open', link, '--all', '--password', password)
const c = await getFileChecksum(basename(file))
await rm(basename(file))
test.expect(checksum).toBe(c)
})
})