Skip to content
Open
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
25 changes: 7 additions & 18 deletions resources/js/components/commit-search-results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ReactNode } from 'react';
import { CommitCard } from '@/components/commit-card';
import { CommitSkeleton, EmptyFeed } from '@/components/commit-feed';
import { GraphCanvas } from '@/components/graph-canvas';
import { authorLaneColor } from '@/lib/utils';
import type { Commit } from '@/types';

export type SearchResultSet = { term: string; commits: Commit[] };
Expand Down Expand Up @@ -56,23 +55,13 @@ export function SearchResults({
</div>
) : (
<GraphCanvas>
{results.commits.map((commit, index) => {
const previous = results.commits[index - 1];

return (
<CommitCard
key={commit.id}
commit={commit}
previousLane={
previous && authorLaneColor(previous.author)
}
graphAfter={previous?.id}
endsWithDot={
index === results.commits.length - 1
}
/>
);
})}
{results.commits.map((commit) => (
<CommitCard
key={commit.id}
commit={commit}
endsWithDot
/>
))}
</GraphCanvas>
)}
</section>
Expand Down
9 changes: 2 additions & 7 deletions tests/Unit/StandaloneCommitGraphs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test('keeps the graph of each report apart, even when two people report the same
assert.equal(html.match(/data-test="graph-canvas"/g)?.length, 2);
});

test('ends the chain of search results on a dot below the last one', async () => {
test('ends each search result on its own dot, as in a feed', async () => {
const html = await render(() => (
<SearchResults
results={{
Expand All @@ -173,12 +173,7 @@ test('ends the chain of search results on a dot below the last one', async () =>
/>
));

assert.equal(html.match(/data-test="rail-end-dot"/g)?.length, 1);
// In the last card: past everything the second one shows.
assert.ok(
html.indexOf('data-test="rail-end-dot"') >
html.lastIndexOf('Commit two'),
);
assert.equal(html.match(/data-test="rail-end-dot"/g)?.length, 3);
});

test('draws related commits in a canvas of their own, chained one after the other and ending on a dot below the last one', async () => {
Expand Down