Compare commits

..

1 Commits

Author SHA1 Message Date
49a44f6a1a Merge c3794fa2b6 into 2006be0434 2024-08-25 20:59:38 +02:00
28 changed files with 97 additions and 113 deletions

View File

View File

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

View File

@@ -9,7 +9,7 @@ services:
app: app:
build: . build: .
env_file: .env.dev env_file: .dev.env
depends_on: depends_on:
- redis - redis
restart: unless-stopped restart: unless-stopped

View File

@@ -5,8 +5,8 @@
"dev": "run-p dev:*", "dev": "run-p dev:*",
"docker:up": "docker compose -f docker-compose.dev.yaml up", "docker:up": "docker compose -f docker-compose.dev.yaml up",
"docker:build": "docker compose -f docker-compose.dev.yaml build", "docker:build": "docker compose -f docker-compose.dev.yaml build",
"test": "playwright test --project=chrome --project=firefox --project=safari", "test": "playwright test --project chrome firefox safari",
"test:local": "playwright test --project=chrome", "test:local": "playwright test --project chrome",
"test:server": "run-s docker:up", "test:server": "run-s docker:up",
"test:prepare": "run-p build docker:build", "test:prepare": "run-p build docker:build",
"build": "pnpm run --recursive --filter=!@cryptgeon/backend build" "build": "pnpm run --recursive --filter=!@cryptgeon/backend build"
@@ -17,5 +17,5 @@
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"shelljs": "^0.8.5" "shelljs": "^0.8.5"
}, },
"packageManager": "pnpm@9.9.0" "packageManager": "pnpm@9.8.0"
} }

View File

@@ -261,7 +261,7 @@ dependencies = [
[[package]] [[package]]
name = "cryptgeon" name = "cryptgeon"
version = "2.8.0" version = "2.7.0"
dependencies = [ dependencies = [
"axum", "axum",
"bs62", "bs62",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cryptgeon" name = "cryptgeon"
version = "2.8.0" version = "2.7.0"
authors = ["cupcakearmy <hi@nicco.io>"] authors = ["cupcakearmy <hi@nicco.io>"]
edition = "2021" edition = "2021"
rust-version = "1.80" rust-version = "1.80"

View File

@@ -38,6 +38,10 @@ pub static ref ALLOW_FILES: bool = std::env::var("ALLOW_FILES")
.unwrap_or("true".to_string()) .unwrap_or("true".to_string())
.parse() .parse()
.unwrap(); .unwrap();
pub static ref THEME_NEW_NOTE_NOTICE: bool = std::env::var("THEME_NEW_NOTE_NOTICE")
.unwrap_or("true".to_string())
.parse()
.unwrap();
} }
// THEME // THEME
@@ -58,8 +62,4 @@ lazy_static! {
.unwrap_or("".to_string()) .unwrap_or("".to_string())
.parse() .parse()
.unwrap(); .unwrap();
pub static ref THEME_NEW_NOTE_NOTICE: bool = std::env::var("THEME_NEW_NOTE_NOTICE")
.unwrap_or("true".to_string())
.parse()
.unwrap();
} }

View File

@@ -1,5 +1,5 @@
use axum::{ use axum::{
extract::{DefaultBodyLimit, Request}, extract::Request,
routing::{delete, get, post}, routing::{delete, get, post},
Router, ServiceExt, Router, ServiceExt,
}; };
@@ -7,6 +7,7 @@ use dotenv::dotenv;
use tower::Layer; use tower::Layer;
use tower_http::{ use tower_http::{
compression::CompressionLayer, compression::CompressionLayer,
limit::RequestBodyLimitLayer,
normalize_path::NormalizePathLayer, normalize_path::NormalizePathLayer,
services::{ServeDir, ServeFile}, services::{ServeDir, ServeFile},
}; };
@@ -46,14 +47,14 @@ async fn main() {
let app = Router::new() let app = Router::new()
.nest("/api", api_routes) .nest("/api", api_routes)
.fallback_service(serve_dir) .fallback_service(serve_dir)
.layer(DefaultBodyLimit::max(*config::LIMIT))
.layer( .layer(
CompressionLayer::new() CompressionLayer::new()
.br(true) .br(true)
.deflate(true) .deflate(true)
.gzip(true) .gzip(true)
.zstd(true), .zstd(true),
); )
.layer(RequestBodyLimitLayer::new(*config::LIMIT));
let app = NormalizePathLayer::trim_trailing_slash().layer(app); let app = NormalizePathLayer::trim_trailing_slash().layer(app);
@@ -61,7 +62,9 @@ async fn main() {
.await .await
.unwrap(); .unwrap();
println!("listening on {}", listener.local_addr().unwrap()); println!("listening on {}", listener.local_addr().unwrap());
println!("Config {}", *config::LIMIT);
axum::serve(listener, ServiceExt::<Request>::into_make_service(app)) axum::serve(listener, ServiceExt::<Request>::into_make_service(app))
// axum::serve(listener, app)
.await .await
.unwrap(); .unwrap();
} }

View File

@@ -1,9 +1,7 @@
use axum::{ use axum::extract::Path;
extract::Path, use axum::http::StatusCode;
http::StatusCode, use axum::response::{IntoResponse, Response};
response::{IntoResponse, Response}, use axum::Json;
Json,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::time::SystemTime; use std::time::SystemTime;

View File

@@ -1,5 +1,6 @@
use crate::config; use crate::config;
use axum::{http::StatusCode, Json}; use axum::http::StatusCode;
use axum::Json;
use serde::Serialize; use serde::Serialize;
#[derive(Serialize)] #[derive(Serialize)]
@@ -12,12 +13,12 @@ pub struct Status {
pub max_expiration: u32, pub max_expiration: u32,
pub allow_advanced: bool, pub allow_advanced: bool,
pub allow_files: bool, pub allow_files: bool,
pub theme_new_note_notice: bool,
// Theme // Theme
pub theme_image: String, pub theme_image: String,
pub theme_text: String, pub theme_text: String,
pub theme_page_title: String, pub theme_page_title: String,
pub theme_favicon: String, pub theme_favicon: String,
pub theme_new_note_notice: bool,
} }
pub async fn get_status() -> (StatusCode, Json<Status>) { pub async fn get_status() -> (StatusCode, Json<Status>) {

View File

@@ -1,6 +1,6 @@
{ {
"name": "cryptgeon", "name": "cryptgeon",
"version": "2.8.0", "version": "2.7.0",
"homepage": "https://github.com/cupcakearmy/cryptgeon", "homepage": "https://github.com/cupcakearmy/cryptgeon",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -25,7 +25,7 @@
"new_note": "new note", "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.)", "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": { "errors": {
"note_to_big": "could not create note. note is too big", "note_to_big": "could not create note. note is to big",
"note_error": "could not create note. please try again.", "note_error": "could not create note. please try again.",
"max": "max: {n}", "max": "max: {n}",
"empty_content": "note is empty." "empty_content": "note is empty."
@@ -44,7 +44,7 @@
"decryption_failed": "wrong password. could not decipher. probably a broken link. note was destroyed.", "decryption_failed": "wrong password. could not decipher. probably a broken link. note was destroyed.",
"unsupported_type": "unsupported note type." "unsupported_type": "unsupported note type."
}, },
"explanation": "click below to show and delete the note if the counter has reached its limit", "explanation": "click below to show and delete the note if the counter has reached it's limit",
"show_note": "show note", "show_note": "show note",
"warning_will_not_see_again": "you will <b>not</b> get the chance to see the note again.", "warning_will_not_see_again": "you will <b>not</b> get the chance to see the note again.",
"download_all": "download all", "download_all": "download all",

View File

@@ -18,19 +18,19 @@
export let icon: keyof typeof map export let icon: keyof typeof map
</script> </script>
<button on:click {...$$restProps}> <div on:click {...$$restProps}>
{#if map[icon]} {#if map[icon]}
<svelte:component this={map[icon]} /> <svelte:component this={map[icon]} />
{/if} {/if}
</button> </div>
<style> <style>
button { div {
display: inline-block; display: inline-block;
contain: strict; contain: strict;
box-sizing: content-box; box-sizing: content-box;
} }
button > :global(svg) { div > :global(svg) {
display: block; display: block;
fill: currentColor; fill: currentColor;
} }

View File

@@ -39,23 +39,13 @@
<input bind:value {...$$restProps} class:valid={valid === true} /> <input bind:value {...$$restProps} class:valid={valid === true} />
<div class="icons"> <div class="icons">
{#if isPassword} {#if isPassword}
<Icon <Icon class="icon" icon={hidden ? 'eye' : 'eye-off'} on:click={toggle} />
disabled={$$restProps.disabled}
class="icon"
icon={hidden ? 'eye' : 'eye-off'}
on:click={toggle}
/>
{/if} {/if}
{#if random} {#if random}
<Icon disabled={$$restProps.disabled} class="icon" icon="dice" on:click={randomFN} /> <Icon class="icon" icon="dice" on:click={randomFN} />
{/if} {/if}
{#if copy} {#if copy}
<Icon <Icon class="icon" icon="copy" on:click={() => copyFN(value.toString())} />
disabled={$$restProps.disabled}
class="icon"
icon="copy"
on:click={() => copyFN(value.toString())}
/>
{/if} {/if}
</div> </div>
</label> </label>

View File

@@ -116,7 +116,6 @@ export type Status = {
theme_text: string theme_text: string
theme_favicon: string theme_favicon: string
theme_page_title: string theme_page_title: string
theme_new_note_notice: boolean
} }
export async function status() { export async function status() {

View File

@@ -4,17 +4,16 @@ const config: PlaywrightTestConfig = {
use: { use: {
video: 'retain-on-failure', video: 'retain-on-failure',
baseURL: 'http://localhost:3000', baseURL: 'http://localhost:3000',
actionTimeout: 30_000, actionTimeout: 10_000,
}, },
outputDir: './test-results', outputDir: './test-results',
testDir: './test', testDir: './test',
timeout: 30_000, timeout: 10_000,
fullyParallel: true, fullyParallel: true,
retries: 2,
webServer: { webServer: {
command: 'pnpm run docker:up', command: 'docker compose -f docker-compose.dev.yaml up',
port: 3000, port: 3000,
reuseExistingServer: true, reuseExistingServer: true,
}, },
@@ -23,6 +22,10 @@ const config: PlaywrightTestConfig = {
{ name: 'chrome', use: { ...devices['Desktop Chrome'] } }, { name: 'chrome', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } }, { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'safari', use: { ...devices['Desktop Safari'] } }, { name: 'safari', use: { ...devices['Desktop Safari'] } },
{ name: 'cli', use: { ...devices['Desktop Chrome'] }, grep: [/@cli/] },
{ name: 'web', use: { ...devices['Desktop Chrome'] }, grep: [/@web/] },
{ name: 'cross', use: { ...devices['Desktop Chrome'] }, grep: [/@cross/] },
], ],
} }

View File

@@ -1,11 +1,10 @@
import { test } from '@playwright/test' import { test } from '@playwright/test'
import { basename } from 'node:path' import { basename } from 'node:path'
import { rm } from 'node:fs/promises' import { Files, getFileChecksum, rm, tmpFile } from '../../files'
import { Files, getFileChecksum, tmpFile } from '../../files'
import { CLI, getLinkFromCLI } from '../../utils' import { CLI, getLinkFromCLI } from '../../utils'
test.describe('file @cli', () => { test.describe('file @cli', () => {
test('simple', async () => { test('simple', async ({ page }) => {
const file = await tmpFile(Files.Image) const file = await tmpFile(Files.Image)
const checksum = await getFileChecksum(file) const checksum = await getFileChecksum(file)
const note = await CLI('send', 'file', file) const note = await CLI('send', 'file', file)
@@ -18,7 +17,7 @@ test.describe('file @cli', () => {
test.expect(checksum).toBe(c) test.expect(checksum).toBe(c)
}) })
test('simple with password', async () => { test('simple with password', async ({ page }) => {
const file = await tmpFile(Files.Image) const file = await tmpFile(Files.Image)
const password = 'password' const password = 'password'
const checksum = await getFileChecksum(file) const checksum = await getFileChecksum(file)

View File

@@ -2,7 +2,7 @@ import { test } from '@playwright/test'
import { CLI, getLinkFromCLI } from '../../utils' import { CLI, getLinkFromCLI } from '../../utils'
test.describe('text @cli', () => { test.describe('text @cli', () => {
test('simple', async () => { test('simple', async ({ page }) => {
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 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 note = await CLI('send', 'text', text) const note = await CLI('send', 'text', text)
const link = getLinkFromCLI(note.stdout) const link = getLinkFromCLI(note.stdout)
@@ -11,7 +11,7 @@ test.describe('text @cli', () => {
test.expect(retrieved.stdout.trim()).toBe(text) test.expect(retrieved.stdout.trim()).toBe(text)
}) })
test('simple with password', async () => { test('simple with password', async ({ page }) => {
const text = `Endless prejudice endless play derive joy eternal-return selfish burying.` const text = `Endless prejudice endless play derive joy eternal-return selfish burying.`
const password = 'password' const password = 'password'
const note = await CLI('send', 'text', text, '--password', password) const note = await CLI('send', 'text', text, '--password', password)

View File

@@ -1,8 +1,7 @@
import { test } from '@playwright/test' import { test } from '@playwright/test'
import { rm } from 'node:fs/promises' import { CLI, checkLinkForDownload, checkLinkForText, createNote, getLinkFromCLI } from '../../utils'
import { basename } from 'node:path' import { Files, getFileChecksum, rm, tmpFile } from '../../files'
import { Files, getFileChecksum, tmpFile } from '../../files' import { basename } from 'path'
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 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' const password = 'password'
@@ -31,7 +30,7 @@ test.describe('text @cross', () => {
test('web to cli', async ({ page }) => { test('web to cli', async ({ page }) => {
const files = [Files.Image] const files = [Files.Image]
const checksum = await getFileChecksum(files[0]) const checksum = await getFileChecksum(files[0])
const link = await createNoteSuccessfully(page, { files }) const link = await createNote(page, { files })
const filename = basename(files[0]) const filename = basename(files[0])
await CLI('open', link, '--all') await CLI('open', link, '--all')
@@ -43,7 +42,7 @@ test.describe('text @cross', () => {
test('web to cli with password', async ({ page }) => { test('web to cli with password', async ({ page }) => {
const files = [Files.Image] const files = [Files.Image]
const checksum = await getFileChecksum(files[0]) const checksum = await getFileChecksum(files[0])
const link = await createNoteSuccessfully(page, { files, password }) const link = await createNote(page, { files, password })
const filename = basename(files[0]) const filename = basename(files[0])
await CLI('open', link, '--all', '--password', password) await CLI('open', link, '--all', '--password', password)

View File

@@ -1,5 +1,5 @@
import { test } from '@playwright/test' import { test } from '@playwright/test'
import { CLI, checkLinkForText, createNoteSuccessfully, getLinkFromCLI } 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 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' const password = 'password'
@@ -13,7 +13,7 @@ test.describe('text @cross', () => {
}) })
test('web to cli', async ({ page }) => { test('web to cli', async ({ page }) => {
const link = await createNoteSuccessfully(page, { text }) const link = await createNote(page, { text })
const retrieved = await CLI('open', link) const retrieved = await CLI('open', link)
test.expect(retrieved.stdout.trim()).toBe(text) test.expect(retrieved.stdout.trim()).toBe(text)
}) })
@@ -25,7 +25,7 @@ test.describe('text @cross', () => {
}) })
test('web to cli with password', async ({ page }) => { test('web to cli with password', async ({ page }) => {
const link = await createNoteSuccessfully(page, { text, password }) const link = await createNote(page, { text, password })
const retrieved = await CLI('open', link, '--password', password) const retrieved = await CLI('open', link, '--password', password)
test.expect(retrieved.stdout.trim()).toBe(text) test.expect(retrieved.stdout.trim()).toBe(text)
}) })

View File

@@ -1,5 +1,10 @@
import { createHash } from 'node:crypto' import { createHash } from 'crypto'
import { cp, readFile } from 'node:fs/promises' import { cp as cpFN, rm as rmFN } from 'fs'
import { readFile } from 'fs/promises'
import { promisify } from 'util'
export const cp = promisify(cpFN)
export const rm = promisify(rmFN)
export const Files = { export const Files = {
PDF: 'test/assets/AES.pdf', PDF: 'test/assets/AES.pdf',

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,13 @@
import { test } from '@playwright/test' import { test } from '@playwright/test'
import { checkLinkDoesNotExist, checkLinkForText, createNoteSuccessfully } from '../../utils' import { checkLinkDoesNotExist, checkLinkForText, createNote } from '../../utils'
test.describe('@web', () => { test.describe('@web', () => {
test('1 minute', async ({ page, browserName }) => { test('1 minute', async ({ page }) => {
test.skip(browserName === 'webkit')
const text = `Virtues value ascetic revaluation sea dead strong burying.` const text = `Virtues value ascetic revaluation sea dead strong burying.`
const minutes = 1 const minutes = 1
const timeout = minutes * 60_000 const timeout = minutes * 60_000
test.setTimeout(timeout * 2) test.setTimeout(timeout * 2)
const link = await createNoteSuccessfully(page, { text, expiration: minutes }) const link = await createNote(page, { text, expiration: minutes })
await checkLinkForText(page, { link, text }) await checkLinkForText(page, { link, text })
await checkLinkForText(page, { link, text }) await checkLinkForText(page, { link, text })
await page.waitForTimeout(timeout) await page.waitForTimeout(timeout)

View File

@@ -1,17 +1,17 @@
import { test } from '@playwright/test' import { test } from '@playwright/test'
import { checkLinkForText, createNoteSuccessfully } from '../../utils' import { checkLinkForText, createNote } from '../../utils'
test.describe('@web', () => { test.describe('@web', () => {
test('simple', async ({ page }) => { 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 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 createNoteSuccessfully(page, { text }) const link = await createNote(page, { text })
await checkLinkForText(page, { link, text }) await checkLinkForText(page, { link, text })
}) })
test('simple with password', async ({ page }) => { test('simple with password', async ({ page }) => {
const text = 'Foo bar' const text = 'Foo bar'
const password = '123' const password = '123'
const shareLink = await createNoteSuccessfully(page, { text, password }) const shareLink = await createNote(page, { text, password })
await checkLinkForText(page, { link: shareLink, text, password }) await checkLinkForText(page, { link: shareLink, text, password })
}) })
}) })

View File

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