diff --git a/package.json b/package.json index 16c468c0a0..b4e804f2ee 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "lint": "NODE_OPTIONS='--experimental-strip-types' vp fmt resources/ && NODE_OPTIONS='--experimental-strip-types' vp lint --fix", "test:lint": "NODE_OPTIONS='--experimental-strip-types' vp fmt --check resources/ && NODE_OPTIONS='--experimental-strip-types' vp lint", "test:types": "tsc --noEmit && tsc --noEmit --project tests/tsconfig.json", - "test:unit": "node --experimental-strip-types --test tests/Unit/*.test.ts" + "test:unit": "vp test run --config tests/unit.config.ts" }, "dependencies": { "@headlessui/react": "^2.2.10", diff --git a/tests/Unit/CommitImages.test.tsx b/tests/Unit/CommitImages.test.tsx index 71ed507419..030245d04c 100644 --- a/tests/Unit/CommitImages.test.tsx +++ b/tests/Unit/CommitImages.test.tsx @@ -1,6 +1,6 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import type { ReactElement, SyntheticEvent } from 'react'; import { CommitImages } from '../../resources/js/components/commit-images'; import type { Commit } from '../../resources/js/types/commit'; @@ -56,11 +56,11 @@ function renderedImage() { }>; } -void test('keeps the uploaded image until it fails to load', () => { +test('keeps the uploaded image until it fails to load', () => { assert.equal(renderedImage().props.src, '/images/missing.webp'); }); -void test('replaces a failed image with the site logo without retrying the fallback', () => { +test('replaces a failed image with the site logo without retrying the fallback', () => { let replacements = 0; let source = '/images/missing.webp'; const target = { @@ -88,6 +88,6 @@ void test('replaces a failed image with the site logo without retrying the fallb assert.equal(replacements, 1); }); -void test('renders nothing when there are no uploaded images', () => { +test('renders nothing when there are no uploaded images', () => { assert.equal(CommitImages({ commit: { ...commit, images: [] } }), null); }); diff --git a/tests/Unit/CommitMutationOptions.test.ts b/tests/Unit/CommitMutationOptions.test.ts index 20b3265328..96ae85c4ac 100644 --- a/tests/Unit/CommitMutationOptions.test.ts +++ b/tests/Unit/CommitMutationOptions.test.ts @@ -1,6 +1,6 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { restoreFeedCommit, updateQuotedCommits, @@ -24,7 +24,7 @@ const tombstone: DeletedCommit = { deleted_at: '2026-10-16T12:00:00Z', }; -void test('replaces every loaded quote embed with a tombstone without changing row order or unrelated rows', () => { +test('replaces every loaded quote embed with a tombstone without changing row order or unrelated rows', () => { const rows = [...quotes, { ...quotes[1], id: 'second-quote' }]; const updated = updateQuotedCommits(rows, tombstone); assert.deepEqual( @@ -39,7 +39,7 @@ void test('replaces every loaded quote embed with a tombstone without changing r assert.strictEqual(rows[1].quoted_commit, target); }); -void test('restores embedded reply content even when the target is absent from the loaded feed', () => { +test('restores embedded reply content even when the target is absent from the loaded feed', () => { const deleted = updateQuotedCommits(quotes, tombstone); const restored = { ...target, body: 'Restored body' }; const updated = updateQuotedCommits(deleted, restored); @@ -49,13 +49,13 @@ void test('restores embedded reply content even when the target is absent from t assert.strictEqual(updated[2], quotes[2]); }); -void test('keeps the same rows when no loaded commit quotes the changed target', () => { +test('keeps the same rows when no loaded commit quotes the changed target', () => { const updated = updateQuotedCommits(quotes, { ...target, id: 'other' }); assert.deepEqual(updated, quotes); updated.forEach((row, index) => assert.strictEqual(row, quotes[index])); }); -void test('restores a ranked row by score without reordering already loaded rows', () => { +test('restores a ranked row by score without reordering already loaded rows', () => { const rows = [ { id: 'top', hot_score: 50, created_at: '2026-10-14' }, { id: 'middle', hot_score: 10, created_at: '2026-10-16' }, @@ -77,7 +77,7 @@ void test('restores a ranked row by score without reordering already loaded rows assert.deepEqual(restoreFeedCommit(updated, restored, 'ranked'), updated); }); -void test('restores a latest row by creation time and a saved row by bookmark order', () => { +test('restores a latest row by creation time and a saved row by bookmark order', () => { const rows = [ { id: 'newest', created_at: '2026-10-16', saved_order: 4 }, { id: 'oldest', created_at: '2026-10-14', saved_order: 2 }, @@ -97,7 +97,7 @@ void test('restores a latest row by creation time and a saved row by bookmark or ); }); -void test('restoring a target also refreshes its embeds while preserving the loaded rows', () => { +test('restoring a target also refreshes its embeds while preserving the loaded rows', () => { const restored = { ...target, hot_score: 5, created_at: '2026-10-16' }; const rows = restoreFeedCommit(quotes, restored, 'ranked'); assert.strictEqual( diff --git a/tests/Unit/CommitQuoteButton.test.tsx b/tests/Unit/CommitQuoteButton.test.tsx index e34b1e999b..94dd2107ed 100644 --- a/tests/Unit/CommitQuoteButton.test.tsx +++ b/tests/Unit/CommitQuoteButton.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createInertiaApp } from '@inertiajs/react'; import { renderToString } from 'react-dom/server'; import { CommitQuoteButton } from '../../resources/js/components/commit-quote-button'; @@ -14,7 +14,7 @@ const commit = { } as Commit; for (const user of [null, { id: 'viewer' }]) { - void test(`renders the quote control for ${user === null ? 'guests' : 'signed-in readers'}`, async () => { + test(`renders the quote control for ${user === null ? 'guests' : 'signed-in readers'}`, async () => { const result = await createInertiaApp<{ auth: { user: { id: string } | null }; }>({ diff --git a/tests/Unit/CommitStarButton.test.tsx b/tests/Unit/CommitStarButton.test.tsx index 72278d0657..a176f269b4 100644 --- a/tests/Unit/CommitStarButton.test.tsx +++ b/tests/Unit/CommitStarButton.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createInertiaApp } from '@inertiajs/react'; import { renderToString } from 'react-dom/server'; import { CommitStarButton } from '../../resources/js/components/commit-star-button'; @@ -49,7 +49,7 @@ async function render( } for (const status of ['approved', 'pending', 'rejected'] as const) { - void test(`authors see only their ${status} commit's star count`, async () => { + test(`authors see only their ${status} commit's star count`, async () => { const body = await render({ id: 'author' }, { status }); assert.match(body, /data-test="star-count-readonly"/); @@ -58,7 +58,7 @@ for (const status of ['approved', 'pending', 'rejected'] as const) { }); } -void test('authors see an accessible empty star count', async () => { +test('authors see an accessible empty star count', async () => { const body = await render({ id: 'author' }, { stars_count: 0 }); assert.match(body, /aria-label="No stars yet"/); @@ -66,7 +66,7 @@ void test('authors see an accessible empty star count', async () => { }); for (const user of [null, { id: 'viewer' }]) { - void test(`approved commits keep the star control for ${user === null ? 'guests' : 'other readers'}`, async () => { + test(`approved commits keep the star control for ${user === null ? 'guests' : 'other readers'}`, async () => { const body = await render(user); assert.match(body, /data-test="star-commit-button"/); @@ -77,7 +77,7 @@ for (const user of [null, { id: 'viewer' }]) { } for (const status of ['pending', 'rejected'] as const) { - void test(`other readers cannot star a ${status} commit`, async () => { + test(`other readers cannot star a ${status} commit`, async () => { const body = await render({ id: 'viewer' }, { status }); assert.doesNotMatch( @@ -88,7 +88,7 @@ for (const status of ['pending', 'rejected'] as const) { } for (const status of ['approved', 'pending', 'rejected'] as const) { - void test(`authors see their ${status} reply's read-only star count`, async () => { + test(`authors see their ${status} reply's read-only star count`, async () => { const body = await render( { id: 'author' }, { status, parent_id: 'parent' }, diff --git a/tests/Unit/CommitStarMutations.test.ts b/tests/Unit/CommitStarMutations.test.ts index 4d008b7931..539dd361d2 100644 --- a/tests/Unit/CommitStarMutations.test.ts +++ b/tests/Unit/CommitStarMutations.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createCommitStarMutations } from '../../resources/js/lib/commit-star-mutations.ts'; const stars = { id: 'commit', starred: false, stars_count: 2 }; -void test('applies a poll when no star mutation has started', () => { +test('applies a poll when no star mutation has started', () => { const mutations = createCommitStarMutations(); const received: (typeof stars)[] = []; const update = mutations.prepare(stars.id, (state) => received.push(state)); @@ -14,7 +14,7 @@ void test('applies a poll when no star mutation has started', () => { assert.deepEqual(received, [stars]); }); -void test('a click on either copy rejects every older poll, even after completion', () => { +test('a click on either copy rejects every older poll, even after completion', () => { const mutations = createCommitStarMutations(); const received: (typeof stars)[] = []; const update = (state: typeof stars) => received.push(state); @@ -31,7 +31,7 @@ void test('a click on either copy rejects every older poll, even after completio assert.deepEqual(received, []); }); -void test('duplicate controls cannot mutate or poll a commit while its mutation is pending', () => { +test('duplicate controls cannot mutate or poll a commit while its mutation is pending', () => { const mutations = createCommitStarMutations(); const finish = mutations.begin(stars.id); @@ -45,7 +45,7 @@ void test('duplicate controls cannot mutate or poll a commit while its mutation assert.ok(mutations.begin(stars.id)); }); -void test('polling resumes after a mutation finishes or rolls back', () => { +test('polling resumes after a mutation finishes or rolls back', () => { const mutations = createCommitStarMutations(); const finish = mutations.begin(stars.id); const received: (typeof stars)[] = []; @@ -58,7 +58,7 @@ void test('polling resumes after a mutation finishes or rolls back', () => { assert.deepEqual(received, [stars]); }); -void test('a mutation leaves polls for other commits and other layouts independent', () => { +test('a mutation leaves polls for other commits and other layouts independent', () => { const mutations = createCommitStarMutations(); const otherLayout = createCommitStarMutations(); const received: (typeof stars)[] = []; diff --git a/tests/Unit/CommitThread.test.tsx b/tests/Unit/CommitThread.test.tsx index b43b793aae..8af2071ebd 100644 --- a/tests/Unit/CommitThread.test.tsx +++ b/tests/Unit/CommitThread.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createInertiaApp } from '@inertiajs/react'; import { renderToString } from 'react-dom/server'; import { @@ -20,6 +20,7 @@ const reply = (id: string): Commit => created_at: new Date().toISOString(), status: 'approved', body_segments: [{ type: 'text', text: `Visible reply ${id}` }], + preview_segments: null, replies_count: 0, user: { id: 'author', name: 'Author', username: 'author', lane: 1 }, }) as Commit; @@ -69,7 +70,7 @@ async function renderThread(count: number) { } for (const count of [0, 1, 2, 5]) { - void test(`shows ${Math.min(count, 1)} replies immediately out of ${count}`, async () => { + test(`shows ${Math.min(count, 1)} replies immediately out of ${count}`, async () => { const html = await renderThread(count); assert.equal( (html.match(/Visible reply /g) ?? []).length, diff --git a/tests/Unit/ComposerPreview.test.tsx b/tests/Unit/ComposerPreview.test.tsx index a2c50e11da..b7ba6f32cc 100644 --- a/tests/Unit/ComposerPreview.test.tsx +++ b/tests/Unit/ComposerPreview.test.tsx @@ -1,6 +1,6 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { App } from '@inertiajs/react'; import type { ComponentProps, KeyboardEvent, ReactElement } from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; @@ -66,7 +66,7 @@ function previewFor(options: { for (const modifier of ['ctrlKey', 'metaKey'] as const) { for (const shiftKey of [false, true]) { - void test(`${modifier} + ${shiftKey ? 'Shift + ' : ''}Enter publishes from preview`, () => { + test(`${modifier} + ${shiftKey ? 'Shift + ' : ''}Enter publishes from preview`, () => { let submitted = 0; let prevented = 0; const preview = previewFor({ isSubmittable: true }); @@ -87,7 +87,7 @@ for (const modifier of ['ctrlKey', 'metaKey'] as const) { } } -void test('does not publish an incomplete draft from preview', () => { +test('does not publish an incomplete draft from preview', () => { previewFor({ isSubmittable: false }).onPreviewKeyDown({ key: 'Enter', ctrlKey: true, @@ -152,7 +152,7 @@ function renderComposer(body: string): string { } for (const count of [1, 2, 3, 3850]) { - void test(`counts ${count} emoji as Unicode characters in the preview composer`, () => { + test(`counts ${count} emoji as Unicode characters in the preview composer`, () => { const markup = renderComposer('🚀'.repeat(count)); const submit = markup.match( /]*data-test="create-commit-button"[^>]*>/, @@ -168,7 +168,7 @@ for (const count of [1, 2, 3, 3850]) { }); } -void test('previews the chosen link card instead of the first link in the body', () => { +test('previews the chosen link card instead of the first link in the body', () => { const preview = previewFor({ body: 'https://first.example.com https://second.example.com', isSubmittable: true, @@ -187,7 +187,7 @@ void test('previews the chosen link card instead of the first link in the body', assert.ok(!card.includes('first.example.com')); }); -void test('omits the preview card when the author chooses no card', () => { +test('omits the preview card when the author chooses no card', () => { const preview = previewFor({ body: 'https://first.example.com', isSubmittable: true, @@ -200,7 +200,7 @@ void test('omits the preview card when the author chooses no card', () => { assert.ok(!markup.includes('data-test="link-card-preview"')); }); -void test('retains the link card picker and scheduling beside preview', () => { +test('retains the link card picker and scheduling beside preview', () => { const markup = renderComposer( 'https://first.example.com https://second.example.com', ); @@ -219,7 +219,7 @@ void test('retains the link card picker and scheduling beside preview', () => { const secret = 'ghp_' + 'Ab3dEf6hIj9kLm2nOp5qRs8tUv1wXy4zABCD'; -void test('keeps the sensitive text warning beside preview', () => { +test('keeps the sensitive text warning beside preview', () => { const markup = renderComposer(secret); assert.equal( @@ -231,13 +231,13 @@ void test('keeps the sensitive text warning beside preview', () => { assert.ok(!markup.includes('Publish possible secrets?')); }); -void test('ordinary drafts retain preview without a sensitive text warning', () => { +test('ordinary drafts retain preview without a sensitive text warning', () => { const markup = renderComposer('Shipped a small fix'); assert.ok(markup.includes('data-test="preview-toggle"')); assert.ok(!markup.includes('aria-label="Sensitive text warning"')); }); -void test('previews attached image descriptions without a published photo link', () => { +test('previews attached image descriptions without a published photo link', () => { const images = [ new File(['first'], 'first.png', { type: 'image/png' }), new File(['second'], 'second.png', { type: 'image/png' }), @@ -264,7 +264,7 @@ void test('previews attached image descriptions without a published photo link', for (const pasteisMode of [false, true]) { for (const isStatic of [false, true]) { - void test(`renders pastel words as ${pasteisMode ? 'emoji' : 'text'} in ${isStatic ? 'excerpts' : 'commit previews'}`, () => { + test(`renders pastel words as ${pasteisMode ? 'emoji' : 'text'} in ${isStatic ? 'excerpts' : 'commit previews'}`, () => { const body = 'pastel, pasteis! (pastéis) PASTEL PASTEIS PASTÉIS :rocket:'; const preview = previewFor({ body, isSubmittable: true }); @@ -307,7 +307,7 @@ for (const pasteisMode of [false, true]) { } }); - void test(`preserves code, URLs, usernames and larger words with mode ${pasteisMode ? 'on' : 'off'} in ${isStatic ? 'excerpts' : 'commits'}`, () => { + test(`preserves code, URLs, usernames and larger words with mode ${pasteisMode ? 'on' : 'off'} in ${isStatic ? 'excerpts' : 'commits'}`, () => { const preview = previewFor({ body: 'pastel https://pasteis.com/pastel @pastel pastels pastelaria épastel pastelé pastel_1\n`pasteis`\n```text\npastéis\n```', isSubmittable: true, diff --git a/tests/Unit/LinkifiedText.test.tsx b/tests/Unit/LinkifiedText.test.tsx index f22b2ea629..a319072a81 100644 --- a/tests/Unit/LinkifiedText.test.tsx +++ b/tests/Unit/LinkifiedText.test.tsx @@ -1,6 +1,6 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { renderToStaticMarkup } from 'react-dom/server'; import { typedLinks, @@ -9,7 +9,7 @@ import { const url = 'https://www.example.com/a-long-path-to-the-release-notes'; -void test('finds the full preview URL outside inline and fenced code', () => { +test('finds the full preview URL outside inline and fenced code', () => { const body = [ '`https://inline.example.com`', '```text', @@ -22,7 +22,7 @@ void test('finds the full preview URL outside inline and fenced code', () => { assert.deepEqual(typedLinks('`https://inline.example.com`'), []); }); -void test('shortens the displayed preview link while retaining the full URL', () => { +test('shortens the displayed preview link while retaining the full URL', () => { const markup = renderToStaticMarkup(); assert.ok(markup.includes(`href="${url}"`)); @@ -37,7 +37,7 @@ void test('shortens the displayed preview link while retaining the full URL', () ); }); -void test('keeps every distinct card URL in order without joining prose across code', () => { +test('keeps every distinct card URL in order without joining prose across code', () => { assert.deepEqual( typedLinks( 'https://first.example.com`code`https://second.example.com https://first.example.com', @@ -50,7 +50,7 @@ for (const body of [ 'before `https://draft.example.com', '```text\nhttps://draft.example.com', ]) { - void test(`ignores card URLs in unfinished code: ${body}`, () => { + test(`ignores card URLs in unfinished code: ${body}`, () => { assert.deepEqual(typedLinks(body), []); }); } diff --git a/tests/Unit/NotificationInbox.test.tsx b/tests/Unit/NotificationInbox.test.tsx index c464aff034..95a24c641d 100644 --- a/tests/Unit/NotificationInbox.test.tsx +++ b/tests/Unit/NotificationInbox.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createInertiaApp } from '@inertiajs/react'; import { renderToString } from 'react-dom/server'; import Index from '../../resources/js/pages/notification/index'; @@ -23,7 +23,7 @@ const actor: User = { created_at: timestamp, updated_at: timestamp, }; -const quote: NotificationGroup = { +const quote = { id: 'notice', recipient_id: 'recipient', actor_id: actor.id, @@ -44,6 +44,7 @@ const quote: NotificationGroup = { id: 'quote-commit', user_id: actor.id, parent_id: null, + hot_score: 0, body: 'My quote commentary', body_segments: [{ type: 'text', text: 'My quote commentary' }], preview_segments: null, @@ -51,10 +52,11 @@ const quote: NotificationGroup = { created_at: timestamp, updated_at: timestamp, stars_count: 0, + pasteis_count: 0, starred: false, quoted_commit_id: 'quoted-commit', }, -}; +} satisfies NotificationGroup; async function renderInbox(notifications: NotificationGroup[]) { const result = await createInertiaApp({ @@ -94,7 +96,7 @@ async function renderInbox(notifications: NotificationGroup[]) { return result.body.replaceAll('', ''); } -void test('renders quote notifications with their label and quoting commit destination', async () => { +test('renders quote notifications with their label and quoting commit destination', async () => { const html = await renderInbox([quote]); assert.match(html, /quoted your commit/); @@ -106,11 +108,11 @@ void test('renders quote notifications with their label and quoting commit desti ); }); -void test('includes quotes in the unfiltered empty inbox message', async () => { +test('includes quotes in the unfiltered empty inbox message', async () => { assert.match(await renderInbox([]), /replies, quotes, mentions/); }); -void test('renders a follow-back control outside the follower profile link', async () => { +test('renders a follow-back control outside the follower profile link', async () => { const follow: NotificationGroup = { ...quote, type: 'followed', @@ -134,7 +136,7 @@ void test('renders a follow-back control outside the follower profile link', asy ); }); -void test('renders notification code without altering emoji shortcodes or nesting interactive controls', async () => { +test('renders notification code without altering emoji shortcodes or nesting interactive controls', async () => { const html = await renderInbox([ { ...quote, @@ -150,7 +152,7 @@ void test('renders notification code without altering emoji shortcodes or nestin assert.doesNotMatch(html, /Copy code/); }); -void test('renders highlighted notification blocks without a nested copy button', async () => { +test('renders highlighted notification blocks without a nested copy button', async () => { const html = await renderInbox([ { ...quote, diff --git a/tests/Unit/NotificationIndex.test.tsx b/tests/Unit/NotificationIndex.test.tsx index 49668c7a53..0627dfff26 100644 --- a/tests/Unit/NotificationIndex.test.tsx +++ b/tests/Unit/NotificationIndex.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createInertiaApp } from '@inertiajs/react'; import { renderToString } from 'react-dom/server'; import Index from '../../resources/js/pages/notification/index'; @@ -80,7 +80,7 @@ async function render(notifications: NotificationGroup[]): Promise { return result.body.slice(result.body.indexOf(' { +test('renders a code block highlighted in a notification', async () => { const body = await render([notification]); assert.match(body, /]*>return<\/span>/); @@ -91,7 +91,7 @@ void test('renders a code block highlighted in a notification', async () => { }); for (const isFollowing of [false, true]) { - void test(`keeps ${isFollowing ? 'unfollow' : 'follow-back'} separate from highlighted notification links`, async () => { + test(`keeps ${isFollowing ? 'unfollow' : 'follow-back'} separate from highlighted notification links`, async () => { const followed = { ...notification, id: 'follow-notification', diff --git a/tests/Unit/QuotedCommit.test.tsx b/tests/Unit/QuotedCommit.test.tsx index 4170965951..83b20fc62c 100644 --- a/tests/Unit/QuotedCommit.test.tsx +++ b/tests/Unit/QuotedCommit.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createInertiaApp } from '@inertiajs/react'; import { renderToString } from 'react-dom/server'; import { QuotedCommit } from '../../resources/js/components/quoted-commit'; @@ -46,7 +46,16 @@ async function render( const result = await createInertiaApp({ page: { component: 'quote', - props: { errors: {} }, + props: { + errors: {}, + auth: { + user: null, + isAdmin: false, + log: null, + unreadNotificationsCount: 0, + pasteis: null, + }, + }, url: '/@author/quote', version: null, clearHistory: false, @@ -68,7 +77,7 @@ async function render( } for (const isPreview of [false, true]) { - void test(`renders a quoted code block highlighted ${isPreview ? 'in the composer' : 'in the log'}`, async () => { + test(`renders a quoted code block highlighted ${isPreview ? 'in the composer' : 'in the log'}`, async () => { const body = await render(isPreview); assert.match(body, /]*>return<\/span>/); @@ -76,14 +85,14 @@ for (const isPreview of [false, true]) { }); } -void test('keeps the quote a single link', async () => { +test('keeps the quote a single link', async () => { const body = await render(false); assert.equal(body.match(/ { +test('shows the options of a quoted poll without letting anyone vote inside the quote', async () => { const body = await render(false, { ...commit, poll }); assert.match(body, /data-test="commit-poll"/); @@ -93,7 +102,7 @@ void test('shows the options of a quoted poll without letting anyone vote inside assert.doesNotMatch(body, /<(input|button|fieldset|label)\b/); }); -void test('shows the results of a quoted poll once the viewer may see them', async () => { +test('shows the results of a quoted poll once the viewer may see them', async () => { const body = await render(true, { ...commit, poll: { diff --git a/tests/Unit/SecretWarning.test.tsx b/tests/Unit/SecretWarning.test.tsx index b52901ae0d..a375ae5f37 100644 --- a/tests/Unit/SecretWarning.test.tsx +++ b/tests/Unit/SecretWarning.test.tsx @@ -1,7 +1,7 @@ /// import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { createElement, useState } from 'react'; import { renderToString } from 'react-dom/server'; import { useSecretWarning } from '../../resources/js/hooks/use-secret-warning'; @@ -31,7 +31,7 @@ function run(steps: Step[]): void { renderToString(createElement(Scenario)); } -void test('allows ordinary text without asking for confirmation', () => { +test('allows ordinary text without asking for confirmation', () => { run([ { body: 'Shipped a quote with https://example.com/release', @@ -43,7 +43,7 @@ void test('allows ordinary text without asking for confirmation', () => { ]); }); -void test('requires confirmation and consumes approval for a single submission', () => { +test('requires confirmation and consumes approval for a single submission', () => { run([ { body: token, @@ -70,7 +70,7 @@ void test('requires confirmation and consumes approval for a single submission', ]); }); -void test('keeping editing does not approve the detected secret', () => { +test('keeping editing does not approve the detected secret', () => { run([ { body: token, diff --git a/tests/Unit/SensitiveText.test.ts b/tests/Unit/SensitiveText.test.ts index 3e30a2c460..42fff10aa1 100644 --- a/tests/Unit/SensitiveText.test.ts +++ b/tests/Unit/SensitiveText.test.ts @@ -1,5 +1,5 @@ import assert from 'node:assert/strict'; -import { test } from 'node:test'; +import { test } from 'vite-plus/test'; import { findSecrets, removeSecrets, @@ -8,7 +8,7 @@ import { const githubToken = 'ghp_' + 'Ab3dEf6hIj9kLm2nOp5qRs8tUv1wXy4zABCD'; -await test('finds a pasted token and returns the exact selection after Unicode text', () => { +test('finds a pasted token and returns the exact selection after Unicode text', () => { const body = `My key 🔑: ${githubToken}`; const findings = findSecrets(body); assert.equal(findings.length, 1); @@ -16,7 +16,7 @@ await test('finds a pasted token and returns the exact selection after Unicode t assert.equal(stashableBody(body), ''); }); -await test('removes multiple secrets without changing surrounding prose', () => { +test('removes multiple secrets without changing surrounding prose', () => { const body = `Token ${githubToken}; database postgres://demo:LocalOnly7z9@localhost/demo`; const cleaned = removeSecrets(body); assert.equal(cleaned, 'Token [REDACTED]; database [REDACTED]'); @@ -24,14 +24,14 @@ await test('removes multiple secrets without changing surrounding prose', () => assert.equal(stashableBody(cleaned), cleaned); }); -await test('detects a complete private key block', () => { +test('detects a complete private key block', () => { const body = '-----BEGIN PRIVATE KEY-----\nAbCdEfGhIjKlMnOp1234567890\n-----END PRIVATE KEY-----'; assert.ok(findSecrets(body).length > 0); assert.equal(stashableBody(body), ''); }); -await test('preserves ordinary code and obvious placeholder examples', () => { +test('preserves ordinary code and obvious placeholder examples', () => { for (const body of [ '', 'const id = "a1b2c3d4"; // hello world', diff --git a/tests/Unit/SeriesStash.test.ts b/tests/Unit/SeriesStash.test.ts deleted file mode 100644 index c2f12ddc9e..0000000000 --- a/tests/Unit/SeriesStash.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { execFileSync } from 'node:child_process'; -import { test } from 'node:test'; -import { fileURLToPath } from 'node:url'; - -await test('draft images survive editing, restoration, and sensitive text confirmation', () => { - const cli = fileURLToPath( - new URL('./bin/vp', import.meta.resolve('vite-plus/package.json')), - ); - - execFileSync( - process.execPath, - [cli, 'test', 'run', '--config', 'tests/draft-images.config.ts'], - { - cwd: fileURLToPath(new URL('../..', import.meta.url)), - stdio: 'inherit', - }, - ); -}); diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 17221dd096..2f408354e9 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -5,8 +5,9 @@ "allowImportingTsExtensions": true }, "include": [ + "../resources/js/**/*.d.ts", "Unit/**/*.test.ts", - "Unit/DraftStash.test.tsx", - "draft-images.config.ts" + "Unit/**/*.test.tsx", + "unit.config.ts" ] } diff --git a/tests/draft-images.config.ts b/tests/unit.config.ts similarity index 60% rename from tests/draft-images.config.ts rename to tests/unit.config.ts index d5c69926e9..9fbba8a430 100644 --- a/tests/draft-images.config.ts +++ b/tests/unit.config.ts @@ -8,10 +8,6 @@ export default defineConfig({ }, }, test: { - include: [ - 'tests/Unit/DraftStash.test.tsx', - 'tests/Unit/ComposerDraft.test.tsx', - 'tests/Unit/QuoteDraft.test.tsx', - ], + include: ['tests/Unit/**/*.test.{ts,tsx}'], }, });