Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/js/components/commit-thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import {
} from '@/lib/commit';
import { commitStateKey } from '@/lib/commit-state';
import { hasModKey } from '@/lib/keyboard';
import { exactCountTitle, formatCount, formatExactCount } from '@/lib/numbers';
import { exactCountTitle, formatCount } from '@/lib/numbers';
import {
characterCount,
cn,
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/ConversationSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const org = (id: string, name: string | null, users: User[]) =>

const ids = (conversations: ConversationSummary[]) => conversations.map(({ id }) => id);

test('finds loaded conversations by a partner or member handle or name, or an org name, ignoring case', () => {
void test('finds loaded conversations by a partner or member handle or name, or an org name, ignoring case', () => {
const loaded = [direct(ana), direct(ben), org('core', 'Core Team', [ana]), org('crew', null, [ben])];

assert.deepEqual(ids(conversationsMatching('ANA', loaded)), ['direct-ana', 'core']);
Expand All @@ -24,7 +24,7 @@ test('finds loaded conversations by a partner or member handle or name, or an or
assert.deepEqual(conversationsMatching('nobody', loaded), []);
});

test('keeps the first matching copy of a conversation found in several lists', () => {
void test('keeps the first matching copy of a conversation found in several lists', () => {
const fresh = direct(ana, { ahead: 2 });
const renamed = org('core', 'Core', [ben]);

Expand All @@ -34,7 +34,7 @@ test('keeps the first matching copy of a conversation found in several lists', (
]);
});

test('keeps every conversation the server found for the term, ahead of stale copies on hand', () => {
void test('keeps every conversation the server found for the term, ahead of stale copies on hand', () => {
const found = [org('core', 'Review Renamed Team', [ben]), direct(ana)];

assert.deepEqual(conversationsMatching('review', [org('core', 'Core', [ben])], found), [...found]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/IssueCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
typedCommand,
} from '../../resources/js/lib/issue-commands.ts';

test('suggests commands only while the draft is a slash and the start of a name', () => {
void test('suggests commands only while the draft is a slash and the start of a name', () => {
const names = (body: string) =>
suggestedCommands(body).map((command) => command.name);

Expand All @@ -19,7 +19,7 @@ test('suggests commands only while the draft is a slash and the start of a name'
assert.deepEqual(names(''), []);
});

test('a complete command and a space or new line becomes an issue without the command', () => {
void test('a complete command and a space or new line becomes an issue without the command', () => {
assert.deepEqual(typedCommand('/bug '), { kind: 'bug', body: '' });
assert.deepEqual(typedCommand('/feature Dark mode'), {
kind: 'feature',
Expand All @@ -34,7 +34,7 @@ test('a complete command and a space or new line becomes an issue without the co
assert.equal(typedCommand('Fixed a /bug today'), null);
});

test('hints the command a plain draft mentions', () => {
void test('hints the command a plain draft mentions', () => {
const name = (body: string) => hintedCommand(body)?.name ?? null;

assert.equal(name('The search has a bug'), '/bug');
Expand Down
44 changes: 28 additions & 16 deletions tests/Unit/ThreadHistory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ function restoredThread(saved: unknown, except?: string) {
key === `thread:root:${except ?? ''}` ? (saved as never) : undefined,
);
let thread: ReturnType<typeof useThread> | undefined;
function Probe() {
thread = useThread(
{ ...reply('root'), replies_count: 18 },
initial,
false,
except,
function Probe({
onRender,
}: {
onRender: (rendered: typeof thread) => void;
}) {
onRender(
useThread(
{ ...reply('root'), replies_count: 18 },
initial,
false,
except,
),
);
return null;
}
renderToString(<Probe />);
renderToString(<Probe onRender={(rendered) => (thread = rendered)} />);
assert.ok(thread);
return thread;
}
Expand Down Expand Up @@ -72,17 +78,23 @@ test('restores loaded continuation pages and their next cursor', () => {
: undefined,
);
let result: ReturnType<typeof useContinuation> | undefined;
function Probe() {
result = useContinuation({
data: [],
next_id: 'next',
position: 1,
length: 3,
is_capped: false,
});
function Probe({
onRender,
}: {
onRender: (rendered: typeof result) => void;
}) {
onRender(
useContinuation({
data: [],
next_id: 'next',
position: 1,
length: 3,
is_capped: false,
}),
);
return null;
}
renderToString(<Probe />);
renderToString(<Probe onRender={(rendered) => (result = rendered)} />);
assert.ok(result);
assert.deepEqual(result.shown, shown);
assert.equal(result.nextId, 'more');
Expand Down
44 changes: 31 additions & 13 deletions tests/Unit/ThreadMutationHistory.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@ const reply = (id: string) =>
({ id, replies_count: 0, deleted_at: null }) as ThreadCommit;
function mount(id: string) {
let thread: ReturnType<typeof useThread> | undefined;
function Probe() {
thread = useThread(
{ ...reply(id), replies_count: 5 },
{ data: [reply('one')], next_cursor: 'next', prev_cursor: null },
function Probe({
onRender,
}: {
onRender: (rendered: typeof thread) => void;
}) {
onRender(
useThread(
{ ...reply(id), replies_count: 5 },
{
data: [reply('one')],
next_cursor: 'next',
prev_cursor: null,
},
),
);
return null;
}
renderToString(<Probe />);
renderToString(<Probe onRender={(rendered) => (thread = rendered)} />);
assert.ok(thread);
return thread;
}
Expand Down Expand Up @@ -242,21 +252,29 @@ for (const isOpen of [true, false]) {
prev_cursor: null,
};
let thread: ReturnType<typeof useThread> | undefined;
function Probe() {
function Probe({
onRender,
}: {
onRender: (rendered: typeof thread) => void;
}) {
const [posted, setPosted] = React.useState(false);
thread = useThread(
{
...reply(`quoted-${isOpen}-${hasReplies}`),
replies_count: refreshed.data.length,
},
posted ? refreshed : initial,
onRender(
useThread(
{
...reply(`quoted-${isOpen}-${hasReplies}`),
replies_count: refreshed.data.length,
},
posted ? refreshed : initial,
),
);
if (!posted) {
setPosted(true);
}
return null;
}
renderToString(<Probe />);
renderToString(
<Probe onRender={(rendered) => (thread = rendered)} />,
);
assert.ok(thread);
assert.deepEqual(
thread.replies?.map((row) => row.id),
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/TranslationLanguages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const languages = [
];

for (const query of ['Hungarian', 'magyar', ' MAGYAR ', 'hung', 'hu']) {
test(`finds Hungarian by ${JSON.stringify(query)}`, () => {
void test(`finds Hungarian by ${JSON.stringify(query)}`, () => {
assert.deepEqual(searchTranslationLanguages(languages, query), [languages[0]]);
});
}

test('finds languages in their native script', () => {
void test('finds languages in their native script', () => {
assert.deepEqual(searchTranslationLanguages(languages, '日本語'), [languages[1]]);
});

test('returns every language for an empty search and none for an unknown name', () => {
void test('returns every language for an empty search and none for an unknown name', () => {
assert.deepEqual(searchTranslationLanguages(languages, ''), languages);
assert.deepEqual(searchTranslationLanguages(languages, 'not-a-language'), []);
});