From adfb20b7543c4d99fb8c5879190e2c07bce9875a Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Wed, 31 Jan 2024 15:12:34 +0000 Subject: [PATCH 1/3] added envelope property for joins --- src/fragmentarium/domain/join.ts | 1 + src/fragmentarium/ui/info/Details.test.tsx | 10 ++++++++++ src/fragmentarium/ui/info/Details.tsx | 19 +++++++++++++++++-- src/test-support/join-fixtures.ts | 2 ++ src/test-support/test-fragment.ts | 2 ++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/fragmentarium/domain/join.ts b/src/fragmentarium/domain/join.ts index 8b705e6a5..71dc7b502 100644 --- a/src/fragmentarium/domain/join.ts +++ b/src/fragmentarium/domain/join.ts @@ -6,6 +6,7 @@ export interface Join { readonly note: string readonly legacyData: string readonly isInFragmentarium: boolean + readonly isEnvelope: boolean } export type Joins = ReadonlyArray> diff --git a/src/fragmentarium/ui/info/Details.test.tsx b/src/fragmentarium/ui/info/Details.test.tsx index 350219f61..bb59c9d61 100644 --- a/src/fragmentarium/ui/info/Details.test.tsx +++ b/src/fragmentarium/ui/info/Details.test.tsx @@ -77,6 +77,7 @@ describe('All details', () => { [ joinFactory.build({ isInFragmentarium: false }), joinFactory.build({ isInFragmentarium: true }), + joinFactory.build({ isEnvelope: true }), ], ], }, @@ -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() @@ -179,6 +186,9 @@ describe('Missing details', () => { it(`Renders dash for joins`, () => { expect(screen.getByText(/Joins:/)).toHaveTextContent('-') }) + it(`Does not render envelope icon`, () => { + expect(screen.queryAllByLabelText('envelope icon').length).toEqual(0) + }) it('Does not renders missing measures', () => { expect( diff --git a/src/fragmentarium/ui/info/Details.tsx b/src/fragmentarium/ui/info/Details.tsx index 5b8511514..63d24df2a 100644 --- a/src/fragmentarium/ui/info/Details.tsx +++ b/src/fragmentarium/ui/info/Details.tsx @@ -46,12 +46,27 @@ function Joins({ fragment: { number, joins } }: Props): JSX.Element { > {index > 0 ? ( <> -
+{!join.isChecked && ?} +
+ {join.isEnvelope ? ( + + ) : ( + <>+{!join.isChecked && ?} + )} ) : groupIndex > 0 ? ( <>
- (+{!join.isChecked && ?}) + {join.isEnvelope ? ( + + ) : ( + <>+{!join.isChecked && ?} + )} ) : ( '' diff --git a/src/test-support/join-fixtures.ts b/src/test-support/join-fixtures.ts index 516f140e1..612a055be 100644 --- a/src/test-support/join-fixtures.ts +++ b/src/test-support/join-fixtures.ts @@ -21,6 +21,7 @@ export const joinDtoFactory = Factory.define< note: chance.sentence(), legacyData: chance.sentence(), isInFragmentarium: chance.bool(), + isEnvelope: chance.bool(), } }) @@ -32,4 +33,5 @@ export const joinFactory = Factory.define(({ sequence }) => ({ note: defaultChance.sentence(), legacyData: defaultChance.sentence(), isInFragmentarium: defaultChance.bool(), + isEnvelope: defaultChance.bool(), })) diff --git a/src/test-support/test-fragment.ts b/src/test-support/test-fragment.ts index 59dd5d457..30827d759 100644 --- a/src/test-support/test-fragment.ts +++ b/src/test-support/test-fragment.ts @@ -439,6 +439,7 @@ export const fragment = new Fragment( note: '', legacyData: '', isInFragmentarium: true, + isEnvelope: true, }, ], [ @@ -450,6 +451,7 @@ export const fragment = new Fragment( note: '', legacyData: '', isInFragmentarium: false, + isEnvelope: true, }, ], ], From ce5bacf40ceabc44a6ff08f22eb9a4c20ed9354f Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Thu, 1 Feb 2024 08:30:54 +0000 Subject: [PATCH 2/3] Refactoring --- src/fragmentarium/domain/Fragment.test.ts | 1 + src/fragmentarium/ui/info/Details.test.tsx | 3 --- src/fragmentarium/ui/info/Details.tsx | 14 +------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/fragmentarium/domain/Fragment.test.ts b/src/fragmentarium/domain/Fragment.test.ts index 386675882..8a6b57b6a 100644 --- a/src/fragmentarium/domain/Fragment.test.ts +++ b/src/fragmentarium/domain/Fragment.test.ts @@ -42,6 +42,7 @@ const config: Parameters[0] = { note: '', legacyData: '', isInFragmentarium: true, + isEnvelope: true, }, ], ], diff --git a/src/fragmentarium/ui/info/Details.test.tsx b/src/fragmentarium/ui/info/Details.test.tsx index bb59c9d61..b3cafbfc7 100644 --- a/src/fragmentarium/ui/info/Details.test.tsx +++ b/src/fragmentarium/ui/info/Details.test.tsx @@ -186,9 +186,6 @@ describe('Missing details', () => { it(`Renders dash for joins`, () => { expect(screen.getByText(/Joins:/)).toHaveTextContent('-') }) - it(`Does not render envelope icon`, () => { - expect(screen.queryAllByLabelText('envelope icon').length).toEqual(0) - }) it('Does not renders missing measures', () => { expect( diff --git a/src/fragmentarium/ui/info/Details.tsx b/src/fragmentarium/ui/info/Details.tsx index 63d24df2a..698270428 100644 --- a/src/fragmentarium/ui/info/Details.tsx +++ b/src/fragmentarium/ui/info/Details.tsx @@ -44,19 +44,7 @@ function Joins({ fragment: { number, joins } }: Props): JSX.Element { className="Details-joins__join" key={`${groupIndex}-${index}`} > - {index > 0 ? ( - <> -
- {join.isEnvelope ? ( - - ) : ( - <>+{!join.isChecked && ?} - )} - - ) : groupIndex > 0 ? ( + {index > 0 || groupIndex > 0 ? ( <>
{join.isEnvelope ? ( From 08c07068f3d0486e4294d880c44d1cd8b33cf0a9 Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy Date: Thu, 1 Feb 2024 08:52:40 +0000 Subject: [PATCH 3/3] Added isEnvelope property to test --- src/test-support/test-fragment.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test-support/test-fragment.ts b/src/test-support/test-fragment.ts index 30827d759..fd65dbe91 100644 --- a/src/test-support/test-fragment.ts +++ b/src/test-support/test-fragment.ts @@ -342,6 +342,7 @@ export const fragmentDto: FragmentDto = { note: '', legacyData: '', isInFragmentarium: true, + isEnvelope: true, }, ], [ @@ -357,6 +358,7 @@ export const fragmentDto: FragmentDto = { note: '', legacyData: '', isInFragmentarium: false, + isEnvelope: true, }, ], ],