Skip to content
Merged
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
7 changes: 7 additions & 0 deletions src/apps/opportunities/src/assets/detail-prize-medal-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/apps/opportunities/src/assets/prize-medal-disc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/apps/opportunities/src/assets/prize-medal-ribbon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/apps/opportunities/src/assets/prize-range-separator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@
}
}

.manyPrizeCard {
gap: 16px;
min-height: 256px;
}

.expandedPrizeCard {
gap: 40px;
}

.prizeFrame {
align-items: center;
display: flex;
Expand Down Expand Up @@ -337,9 +346,7 @@

img {
flex: 0 0 auto;
height: 20px;
object-fit: contain;
width: 20px;
}
}

Expand Down Expand Up @@ -378,28 +385,71 @@
}

.denseFeaturedPrizes {
gap: 8px 16px;
gap: 4px 20px;
}

.densePrize {
font-size: 22px !important;
line-height: 26px !important;
min-width: 0;
}

.additionalPrizes {
flex-wrap: wrap;
gap: 4px 12px;
gap: 4px 24px;
}

.secondaryPrize {
&,
img {
height: 16px !important;
}
font-size: 16px !important;
}

& {
font-size: 16px !important;
}
.medal {
align-items: center;
display: inline-flex;
flex: 0 0 16px;
height: 16px;
justify-content: center;
width: 16px;
}

.featuredMedal {
flex-basis: 20px;
height: 20px;
width: 20px;
}

.numberedMedal {
height: 16px;
position: relative;
width: 16px;
}

.medalRibbon {
left: 4px;
position: absolute;
top: 10.318px;
}

.medalDisc {
left: 2.4px;
position: absolute;
top: .8px;
}

.medalNumber {
color: #161616;
font-size: 8px;
font-weight: 900;
left: 0;
line-height: normal;
position: absolute;
text-align: center;
top: 1.19px;
width: 16px;
}

.prizeRangeSeparator {
align-self: center;
}

.checkpointAward {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '@testing-library/jest-dom'
import { fireEvent, render, RenderResult, screen, within } from '@testing-library/react'
import { MemoryRouter } from 'react-router-dom'

import { ChallengeOpportunity } from '../models'
import { ChallengeOpportunity, ChallengePrize } from '../models'

import { ChallengeDetailHeader } from './ChallengeDetailHeader'

Expand Down Expand Up @@ -1145,3 +1145,109 @@ describe('ChallengeDetailHeader actions and presentation', () => {
.toBeInTheDocument()
})
})

describe('ChallengeDetailHeader placement prizes beyond tenth place', () => {
function renderPrizes(prizes: ChallengePrize[]): void {
render(
<MemoryRouter>
<ChallengeDetailHeader
busy={false}
challenge={challengeFixture({ prizeSets: [{ prizes, type: 'PLACEMENT' }] })}
isRegistered
onRegister={jest.fn()}
onSubmit={jest.fn()}
onUnregister={jest.fn()}
/>
</MemoryRouter>,
)
}

it.each(['POINT', 'USD'])('renders all eighteen distinct %s prizes with their placements', type => {
renderPrizes(Array.from({ length: 18 }, (_, index) => ({ type, value: 1800 - index * 50 })))

for (let placement = 1; placement <= 18; placement += 1) {
const medal = screen.getByRole('img', { name: `${placement} place` })
const amount = (1850 - placement * 50).toLocaleString('en-US')
expect(medal.closest('strong'))
.toHaveTextContent(type === 'USD' ? `$${amount}` : `${amount} pts`)
}

expect(screen.getByRole('group', { name: 'Additional placement prizes' }).children)
.toHaveLength(15)
expect(screen.getByText('Prizes')
.closest('aside'))
.toHaveClass('expandedPrizeCard')
expect(screen.getByRole('button', { name: 'Submit a solution' }))
.toBeEnabled()
})

it('renders the Figma fourth-through-eighteenth range while keeping podium prizes separate', () => {
renderPrizes(Array.from({ length: 18 }, (_, index) => ({
type: 'POINT',
value: [5000, 4000, 3000][index] ?? 1000,
})))

const additional = screen.getByRole('group', { name: 'Additional placement prizes' })
expect(additional.children)
.toHaveLength(1)
expect(within(additional)
.getByText('1,000 pts'))
.toContainElement(screen.getByRole('img', { name: '4 place' }))
expect(within(additional)
.getByText('1,000 pts'))
.toContainElement(screen.getByRole('img', { name: '18 place' }))
expect(within(additional)
.getByRole('img', { name: 'through' }))
.toBeInTheDocument()
expect(screen.queryByRole('img', { name: '5 place' })).not.toBeInTheDocument()
expect(screen.getByText('Prizes')
.closest('aside')).not.toHaveClass('expandedPrizeCard')
})

it('keeps the top three medals separate even when all rewards match, without imposing another prize limit', () => {
renderPrizes(Array.from({ length: 25 }, () => ({ type: 'USD', value: 100 })))

expect(screen.getAllByText('$100'))
.toHaveLength(4)
for (const placement of [1, 2, 3, 4, 25]) {
expect(screen.getByRole('img', { name: `${placement} place` }))
.toBeInTheDocument()
}
})

it('never groups across missing placements, different reward types, or intervening amounts', () => {
renderPrizes([
{ value: 500 }, { value: 400 }, { value: 300 },
{ type: 'USD', value: 100 }, { type: 'POINT', value: 100 },
{ type: 'POINTS', value: 100 }, { type: 'POINT', value: -1 },
{ type: 'POINT', value: 100 }, { type: 'POINT', value: 50 },
{ type: 'POINT', value: 100 },
])

const additional = screen.getByRole('group', { name: 'Additional placement prizes' })
expect(additional.children)
.toHaveLength(5)
expect(screen.getByRole('img', { name: '5 place' })
.closest('strong'))
.toContainElement(screen.getByRole('img', { name: '6 place' }))
expect(screen.queryByRole('img', { name: '7 place' })).not.toBeInTheDocument()
expect(screen.getByRole('img', { name: '8 place' })
.closest('strong'))
.not.toContainElement(screen.getByRole('img', { name: '10 place' }))
})

it('preserves original placement numbers when earlier prize values are invalid', () => {
renderPrizes([
{ value: -1 }, { value: 400 }, { value: 300 },
{ value: 200 }, { value: 100 }, { value: 100 },
])

expect(screen.queryByRole('img', { name: '1 place' })).not.toBeInTheDocument()
const additional = screen.getByRole('group', { name: 'Additional placement prizes' })
expect(additional)
.toContainElement(screen.getByRole('img', { name: '4 place' }))
expect(screen.getByRole('img', { name: '5 place' })
.closest('strong'))
.toContainElement(screen.getByRole('img', { name: '6 place' }))
})
})
Loading
Loading