Skip to content

Commit

Permalink
Cls2 555 create add task button (#6370)
Browse files Browse the repository at this point in the history
* Added add task button to dashboard

* Added test for add task button

* Removed double urls import

* Changed button prop to Link
  • Loading branch information
ClaudiaGC1339 authored Dec 19, 2023
1 parent 6cb0422 commit 26aef74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/client/components/ContentWithHeading.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import PropTypes from 'prop-types'
import React from 'react'
import { H3 } from 'govuk-react'
import { Button, H3, Link } from 'govuk-react'
import styled from 'styled-components'

import SpacedSectionBreak from './SpacedSectionBreak'
import { BLUE } from '../utils/colours'
import urls from '../../lib/urls'

const StyledHeading = styled(H3)({
flexGrow: 1,
Expand All @@ -19,6 +21,14 @@ const ContentWithHeading = ({ heading, children, headingActions }) => (
<StyledHeader>
<StyledHeading size={24}>{heading}</StyledHeading>
{headingActions}
<Button
buttonColour={BLUE}
href={urls.tasks.create()}
as={Link}
data-test="add-task"
>
Add task
</Button>
</StyledHeader>
<SpacedSectionBreak />
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,11 @@ describe('My Tasks on the Dashboard', () => {
it('should display the heading 1 task (singular) and not 1 tasks (plural)', () => {
cy.get('h3').should('contain', '1 task').should('not.contain', '1 tasks')
})

it('should contain a button to add task', () => {
cy.get('[data-test="add-task"]')
.should('have.text', 'Add task')
.should('have.attr', 'href', urls.tasks.create())
})
})
})

0 comments on commit 26aef74

Please sign in to comment.