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

PRMDR-412 - LG action menu fix #223

Merged
merged 3 commits into from
Jan 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ describe('GP Workflow: View Lloyd George record', () => {
cy.get('#verify-submit').click();
cy.wait('@lloydGeorgeStitch');

cy.getByTestId('actions-menu').click();
cy.getByTestId('download-all-files-link').should('not.exist');
cy.getByTestId('actions-menu').should('not.exist');
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ describe('GP Workflow: View Lloyd George record', () => {
cy.get('#verify-submit').click();
cy.wait('@lloydGeorgeStitch');

cy.getByTestId('actions-menu').click();
cy.getByTestId('download-all-files-link').should('not.exist');
cy.getByTestId('actions-menu').should('not.exist');
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,8 @@ describe('LloydGeorgeRecordDetails', () => {

renderComponent();

expect(screen.getByText(`Select an action...`)).toBeInTheDocument();
expect(screen.getByTestId('actions-menu')).toBeInTheDocument();

act(() => {
userEvent.click(screen.getByTestId('actions-menu'));
});
await waitFor(async () => {
expect(screen.queryByText(action.label)).not.toBeInTheDocument();
});
expect(screen.queryByText(`Select an action...`)).not.toBeInTheDocument();
expect(screen.queryByTestId('actions-menu')).not.toBeInTheDocument();
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Link } from 'react-router-dom';
import useRole from '../../../helpers/hooks/useRole';
import { actionLinks } from '../../../types/blocks/lloydGeorgeActions';
import { LG_RECORD_STAGE } from '../../../types/blocks/lloydGeorgeStages';
import { REPOSITORY_ROLE } from '../../../types/generic/authRole';

export type Props = {
lastUpdated: string;
Expand Down Expand Up @@ -54,54 +55,56 @@ function LloydGeorgeRecordDetails({
</Button>
</div>
) : (
<div className="lloydgeorge_record-details_actions">
<div
data-testid="actions-menu"
className={`nhsuk-select lloydgeorge_record-details_actions-select ${
showActionsMenu
? 'lloydgeorge_record-details_actions-select--selected'
: ''
}`}
onClick={handleMoreActions}
>
role !== REPOSITORY_ROLE.GP_CLINICAL && (
<div className="lloydgeorge_record-details_actions">
<div
className={`lloydgeorge_record-details_actions-select_border ${
data-testid="actions-menu"
className={`nhsuk-select lloydgeorge_record-details_actions-select ${
showActionsMenu
? 'lloydgeorge_record-details_actions-select_border--selected'
? 'lloydgeorge_record-details_actions-select--selected'
: ''
}`}
/>
<span className="lloydgeorge_record-details_actions-select_placeholder">
Select an action...
</span>
<Chevron className="lloydgeorge_record-details_actions-select_icon" />
</div>
{showActionsMenu && (
<div ref={actionsRef}>
<Card className="lloydgeorge_record-details_actions-menu">
<Card.Content>
<ol>
{actionLinks.map((link) =>
role && !link.unauthorised?.includes(role) ? (
<li key={link.key} data-testid={link.key}>
<Link
to="#"
onClick={(e) => {
e.preventDefault();
setStage(link.stage);
}}
>
{link.label}
</Link>
</li>
) : null,
)}
</ol>
</Card.Content>
</Card>
onClick={handleMoreActions}
>
<div
className={`lloydgeorge_record-details_actions-select_border ${
showActionsMenu
? 'lloydgeorge_record-details_actions-select_border--selected'
: ''
}`}
/>
<span className="lloydgeorge_record-details_actions-select_placeholder">
Select an action...
</span>
<Chevron className="lloydgeorge_record-details_actions-select_icon" />
</div>
)}
</div>
{showActionsMenu && (
<div ref={actionsRef}>
<Card className="lloydgeorge_record-details_actions-menu">
<Card.Content>
<ol>
{actionLinks.map((link) =>
role && !link.unauthorised?.includes(role) ? (
<li key={link.key} data-testid={link.key}>
<Link
to="#placeholder"
onClick={(e) => {
e.preventDefault();
setStage(link.stage);
}}
>
{link.label}
</Link>
</li>
) : null,
)}
</ol>
</Card.Content>
</Card>
</div>
)}
</div>
)
)}
</div>
);
Expand Down
5 changes: 0 additions & 5 deletions app/src/types/blocks/lloydGeorgeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ type PdfActionLink = {
};

export const actionLinks: Array<PdfActionLink> = [
{
label: 'See all files',
key: 'see-all-files-link',
stage: LG_RECORD_STAGE.SEE_ALL,
},
{
label: 'Download all files',
key: 'download-all-files-link',
Expand Down
1 change: 0 additions & 1 deletion app/src/types/blocks/lloydGeorgeStages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum LG_RECORD_STAGE {
RECORD = 0,
DOWNLOAD_ALL = 1,
SEE_ALL = 2,
DELETE_ALL = 3,
}
Loading