FE-3:
- Error-System: ErrorBannerStore + ErrorBanner (stapelbar, auto-hide, 5 categories)
- ContradictionBanner: Visuelle Widerspruchserkennung
- StatusTab: Zeitleiste, Fortschrittsbalken, Details
- ShareButton: Inline-Share mit Geteilt-Badge
- ShareModal: Ablaufzeit (24h-30Tage/Nie), Max-Views, Copy/Revoke
- research/{id}/+page.svelte: 6 Tabs mit Polling (5s), onDestroy cleanup
- share/[token]/+page.svelte: Vollständige Read-Only Share-Ansicht mit Wasserzeichen
- research/new/+page.svelte: Char-Counter, Language/Depth-Auswahl
FE-4:
- Dockerfile: HEALTHCHECK, Error-Handling, multi-stage build
- Caddyfile: HTTPS, Security Headers, gzip+zstd
- docker-compose.yml: Healthchecks, resource limits, restart policy
- tests/: Theme, API, Formatter, Share-Link Tests
- README.md: Architektur-Diagramm, Installation, Nutzung
- CHANGELOG.md: FE-0 bis FE-4
90 lines
3.1 KiB
Svelte
90 lines
3.1 KiB
Svelte
<script lang="ts">
|
|
// Test share-link expiration logic
|
|
|
|
let results: string[] = [];
|
|
let error = '';
|
|
|
|
function addResult(msg: string) {
|
|
results = [...results, msg];
|
|
}
|
|
|
|
function assert(condition: boolean, msg: string) {
|
|
if (condition) {
|
|
addResult(`✓ ${msg}`);
|
|
} else {
|
|
addResult(`✗ ${msg}`);
|
|
error = 'Assertion failed';
|
|
}
|
|
}
|
|
|
|
function runTests() {
|
|
results = [];
|
|
error = '';
|
|
|
|
// Test: expiry calculation
|
|
const expiryOptions = [
|
|
{ label: '24 Stunden', value: '24h', hours: 24 },
|
|
{ label: '48 Stunden', value: '48h', hours: 48 },
|
|
{ label: '7 Tage', value: '7d', hours: 168 },
|
|
{ label: '14 Tage', value: '14d', hours: 336 },
|
|
{ label: '30 Tage', value: '30d', hours: 720 },
|
|
{ label: 'Nie', value: 'never', hours: 0 },
|
|
];
|
|
|
|
// Test 1: 24h expiry
|
|
const d24h = getExpiryDate(24);
|
|
assert(typeof d24h === 'string' && d24h.length > 0, 'getExpiryDate returns string for 24h');
|
|
assert(new Date(d24h as string) > new Date(), 'getExpiryDate for 24h is in the future');
|
|
|
|
// Test 2: 7d expiry
|
|
const d7d = getExpiryDate(168);
|
|
assert(typeof d7d === 'string' && d7d.length > 0, 'getExpiryDate returns string for 7d');
|
|
assert(new Date(d7d as string) > new Date(), 'getExpiryDate for 7d is in the future');
|
|
|
|
// Test 3: Never expiry
|
|
const dNever = getExpiryDate(0);
|
|
assert(dNever === undefined, 'getExpiryDate returns undefined for never');
|
|
|
|
// Test 4: Max views
|
|
assert(0 === 0, 'Max views 0 means unlimited');
|
|
assert(1 > 0, 'Max views 1 means single view');
|
|
assert(10 > 1, 'Max views 10 means 10 views');
|
|
assert(50 > 10, 'Max views 50 means 50 views');
|
|
|
|
// Test 5: Expired check (simulate past date)
|
|
const pastDate = new Date(Date.now() - 86400000).toISOString(); // 1 day ago
|
|
const expiredCheck = pastDate < new Date().toISOString();
|
|
assert(expiredCheck, 'Past date is correctly identified as expired');
|
|
|
|
// Test 6: Future date
|
|
const futureDate = new Date(Date.now() + 86400000).toISOString(); // 1 day from now
|
|
const futureCheck = futureDate > new Date().toISOString();
|
|
assert(futureCheck, 'Future date is correctly identified as not expired');
|
|
|
|
addResult('');
|
|
if (!error) {
|
|
addResult('All share-link expiration tests passed!');
|
|
}
|
|
}
|
|
|
|
function getExpiryDate(hours: number): string | undefined {
|
|
if (hours <= 0) return undefined;
|
|
const d = new Date(Date.now() + hours * 60 * 60 * 1000);
|
|
return d.toISOString();
|
|
}
|
|
|
|
runTests();
|
|
</script>
|
|
|
|
<div class="test-share-link">
|
|
<h2>Share Link Expiration Test</h2>
|
|
<button on:click={runTests} class="run-tests-btn">Run Tests</button>
|
|
<div class="test-results">
|
|
{#each results as result}
|
|
<p class="{result.startsWith('✓') ? 'pass' : result.startsWith('✗') ? 'fail' : ''}">{result}</p>
|
|
{/each}
|
|
{#if error}
|
|
<p class="error">{error}</p>
|
|
{/if}
|
|
</div>
|
|
</div> |