Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added envelope property for joins #440

Merged
merged 3 commits into from
Feb 2, 2024
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
1 change: 1 addition & 0 deletions src/fragmentarium/domain/Fragment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const config: Parameters<typeof Fragment['create']>[0] = {
note: '',
legacyData: '',
isInFragmentarium: true,
isEnvelope: true,
},
],
],
Expand Down
1 change: 1 addition & 0 deletions src/fragmentarium/domain/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Join {
readonly note: string
readonly legacyData: string
readonly isInFragmentarium: boolean
readonly isEnvelope: boolean
}

export type Joins = ReadonlyArray<ReadonlyArray<Join>>
7 changes: 7 additions & 0 deletions src/fragmentarium/ui/info/Details.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('All details', () => {
[
joinFactory.build({ isInFragmentarium: false }),
joinFactory.build({ isInFragmentarium: true }),
joinFactory.build({ isEnvelope: true }),
],
],
},
Expand All @@ -101,6 +102,12 @@ describe('All details', () => {
).toBeInTheDocument()
})

it(`Renders envelope icon for joins`, () => {
expect(screen.queryAllByLabelText('envelope icon').length).toBeGreaterThan(
0
)
})

it('Does not link to self', () => {
fragment.joins
.flat()
Expand Down
15 changes: 9 additions & 6 deletions src/fragmentarium/ui/info/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ function Joins({ fragment: { number, joins } }: Props): JSX.Element {
className="Details-joins__join"
key={`${groupIndex}-${index}`}
>
{index > 0 ? (
<>
<br />+{!join.isChecked && <sup>?</sup>}
</>
) : groupIndex > 0 ? (
{index > 0 || groupIndex > 0 ? (
<>
<br />
(+{!join.isChecked && <sup>?</sup>})
{join.isEnvelope ? (
<i
className="fa fa-envelope"
aria-label="envelope icon"
></i>
) : (
<>+{!join.isChecked && <sup>?</sup>}</>
)}
</>
) : (
''
Expand Down
2 changes: 2 additions & 0 deletions src/test-support/join-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const joinDtoFactory = Factory.define<
note: chance.sentence(),
legacyData: chance.sentence(),
isInFragmentarium: chance.bool(),
isEnvelope: chance.bool(),
}
})

Expand All @@ -32,4 +33,5 @@ export const joinFactory = Factory.define<Join>(({ sequence }) => ({
note: defaultChance.sentence(),
legacyData: defaultChance.sentence(),
isInFragmentarium: defaultChance.bool(),
isEnvelope: defaultChance.bool(),
}))
4 changes: 4 additions & 0 deletions src/test-support/test-fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export const fragmentDto: FragmentDto = {
note: '',
legacyData: '',
isInFragmentarium: true,
isEnvelope: true,
},
],
[
Expand All @@ -357,6 +358,7 @@ export const fragmentDto: FragmentDto = {
note: '',
legacyData: '',
isInFragmentarium: false,
isEnvelope: true,
},
],
],
Expand Down Expand Up @@ -439,6 +441,7 @@ export const fragment = new Fragment(
note: '',
legacyData: '',
isInFragmentarium: true,
isEnvelope: true,
},
],
[
Expand All @@ -450,6 +453,7 @@ export const fragment = new Fragment(
note: '',
legacyData: '',
isInFragmentarium: false,
isEnvelope: true,
},
],
],
Expand Down
Loading