Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #134 from uktrade/reorganise-directory-structure
Browse files Browse the repository at this point in the history
refactor: Reorganise directories
  • Loading branch information
rafenden authored Sep 2, 2019
2 parents 1a127a9 + a10c34d commit 8c3e924
Show file tree
Hide file tree
Showing 94 changed files with 7,712 additions and 753 deletions.
12 changes: 0 additions & 12 deletions fixtures/activity_feed/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import React from 'react'
import { find } from 'lodash'

import PropTypes from 'prop-types'
import Cards from './activity-feed-cards'
import cards from './cards'

export default class ActivityFeedCard extends React.PureComponent {
export default class Activity extends React.PureComponent {
static propTypes = {
activity: PropTypes.object.isRequired,
showDetails: PropTypes.bool.isRequired,
showDetails: PropTypes.bool,
}

static defaultProps = {
showDetails: false,
}

constructor(props) {
super(props)
const { activity } = this.props
this.Card = find(Cards, c => c.canRender(activity))
this.Card = find(cards, c => c.canRender(activity))
}

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/activity-feed/ActivityFeed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import styled from 'styled-components'
import { SPACING } from '@govuk-react/constants'

import ActivityFeedCard from './ActivityFeedCard'
import Activity from './Activity'
import ActivityFeedHeader from './ActivityFeedHeader'
import ActivityFeedFilters from './ActivityFeedFilters'
import ActivityFeedPagination from './ActivityFeedPagination'
Expand Down Expand Up @@ -89,7 +89,7 @@ export default class ActivityFeed extends React.Component {
<ActivityFeedCardList>
{activities.map(activity => (
<li key={activity.id}>
<ActivityFeedCard activity={activity} showDetails={showDetails} />
<Activity activity={activity} showDetails={showDetails} />
</li>
))}
</ActivityFeedCardList>
Expand Down
18 changes: 0 additions & 18 deletions src/activity-feed/ActivityFeedCard.stories.jsx

This file was deleted.

23 changes: 23 additions & 0 deletions src/activity-feed/__fixtures__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import accountsAreDueFixture from './companies_house/accounts_are_due'
import incorporatedFixture from './companies_house/incorporated'
import exportOfGoodsFixture from './hmrc/export_of_goods'
import interactionFixture from './interactions/interaction'
import investmentProjectFixture from './interactions/investment_project'
import serviceDeliveryFixture from './interactions/service_delivery'
import projectAddedFdiFixture from './investment_projects/project_added_fdi'
import projectAddedNonFdiFixture from './investment_projects/project_added_non_fdi'
import projectAddedCtiFixture from './investment_projects/project_added_cti'
import orderAddedFixture from './omis/order_added'

export default [
accountsAreDueFixture,
incorporatedFixture,
exportOfGoodsFixture,
interactionFixture,
investmentProjectFixture,
serviceDeliveryFixture,
projectAddedFdiFixture,
projectAddedNonFdiFixture,
projectAddedCtiFixture,
orderAddedFixture,
]
18 changes: 18 additions & 0 deletions src/activity-feed/__stories__/Activity.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { storiesOf } from '@storybook/react'

import Activity from '../Activity'
import fixtureInteraction from '../__fixtures__/interactions/interaction'
import fixtureInvestmentProject from '../__fixtures__/interactions/investment_project'
import foreignDirectInvestment from '../__fixtures__/investment_projects/project_added_fdi'
import nonCommitmentToInvest from '../__fixtures__/investment_projects/project_added_non_fdi'
import commitmentToInvest from '../__fixtures__/investment_projects/project_added_cti'
import orderAdded from '../__fixtures__/omis/order_added'

storiesOf('Activity', module)
.add('interaction', () => <Activity activity={fixtureInteraction} />)
.add('investment project - interaction', () => <Activity activity={fixtureInvestmentProject} />)
.add('investment project added - FDI', () => <Activity activity={foreignDirectInvestment} />)
.add('investment project added - Non-FDI', () => <Activity activity={nonCommitmentToInvest} />)
.add('investment project added - CTI', () => <Activity activity={commitmentToInvest} />)
.add('omis - new order added', () => <Activity activity={orderAdded} />)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { withKnobs } from '@storybook/addon-knobs'
import { GridCol, GridRow, Main } from 'govuk-react'
import { SPACING } from '@govuk-react/constants'

import ActivityFeed from './ActivityFeed'
import activityFeedFixtures from '../../fixtures/activity_feed'
import datahubBackground from '../../assets/images/data-hub-one-list-corp.png'
import ActivityFeed from '../ActivityFeed'
import activityFeedFixtures from '../__fixtures__'
import datahubBackground from './images/data-hub-one-list-corp.png'

addDecorator(withKnobs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { addDecorator, storiesOf } from '@storybook/react'
import { withKnobs, text } from '@storybook/addon-knobs'

import ActivityFeedApp from './ActivityFeedApp'
import ActivityFeedApp from '../ActivityFeedApp'

addDecorator(withKnobs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ import React from 'react'
import renderer from 'react-test-renderer'
import moment from 'moment'
import { set } from 'lodash'

import MockDate from 'mockdate'
import ActivityFeedCard from './ActivityFeedCard'
import companiesHouseAccountsDueFixture from '../../fixtures/activity_feed/companies_house/accounts_are_due'
import companiesHouseCompaniesFixture from '../../fixtures/activity_feed/companies_house/incorporated'
import hmrcExportersFixture from '../../fixtures/activity_feed/hmrc/export_of_goods'
import interactionActivityFixture from '../../fixtures/activity_feed/interactions/interaction'
import serviceDeliveryActivityFixture from '../../fixtures/activity_feed/interactions/service_delivery'
import investmentProjectsCTIFixture from '../../fixtures/activity_feed/investment_projects/project_added_cti'
import investmentProjectsFDIFixture from '../../fixtures/activity_feed/investment_projects/project_added_fdi'
import investmentProjectsNonFDIFixture from '../../fixtures/activity_feed/investment_projects/project_added_non_fdi'
import orderAddedFixture from '../../fixtures/activity_feed/omis/order_added'

import Activity from '../Activity'

import companiesHouseAccountsDueFixture from '../__fixtures__/companies_house/accounts_are_due'
import companiesHouseCompaniesFixture from '../__fixtures__/companies_house/incorporated'
import hmrcExportersFixture from '../__fixtures__/hmrc/export_of_goods'
import interactionActivityFixture from '../__fixtures__/interactions/interaction'
import serviceDeliveryActivityFixture from '../__fixtures__/interactions/service_delivery'
import investmentProjectsCTIFixture from '../__fixtures__/investment_projects/project_added_cti'
import investmentProjectsFDIFixture from '../__fixtures__/investment_projects/project_added_fdi'
import investmentProjectsNonFDIFixture from '../__fixtures__/investment_projects/project_added_non_fdi'
import orderAddedFixture from '../__fixtures__/omis/order_added'


// Lock the date so moment's relative date doesn't break our deterministic tests.
MockDate.set(1559750582706)

describe('ActivityFeedCard', () => {
describe('Activity', () => {
describe('when the interaction is empty', () => {
test('should render null', () => {
const tree = renderer
.create(<ActivityFeedCard activity={{}} showDetails={false} />)
.create(<Activity activity={{}} showDetails={false} />)
.toJSON()
expect(tree).toBeNull()
})
Expand All @@ -32,7 +33,7 @@ describe('ActivityFeedCard', () => {
describe('when there is an interaction', () => {
test('should render interaction activity', () => {
const tree = renderer
.create(<ActivityFeedCard activity={interactionActivityFixture} showDetails={false} />)
.create(<Activity activity={interactionActivityFixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -44,7 +45,7 @@ describe('ActivityFeedCard', () => {
set(fixture, 'object.dit:status', 'draft')
set(fixture, 'object.startTime', moment().subtract(1, 'years').toISOString())
const tree = renderer
.create(<ActivityFeedCard activity={fixture} showDetails={false} />)
.create(<Activity activity={fixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -56,7 +57,7 @@ describe('ActivityFeedCard', () => {
set(fixture, 'object.dit:status', 'draft')
set(fixture, 'object.startTime', moment().add(1, 'days').toISOString())
const tree = renderer
.create(<ActivityFeedCard activity={fixture} showDetails={false} />)
.create(<Activity activity={fixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -68,7 +69,7 @@ describe('ActivityFeedCard', () => {
set(fixture, 'object.dit:status', 'draft')
set(fixture, 'object.dit:archived', true)
const tree = renderer
.create(<ActivityFeedCard activity={fixture} showDetails={false} />)
.create(<Activity activity={fixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -79,7 +80,7 @@ describe('ActivityFeedCard', () => {
const fixture = { ...interactionActivityFixture }
set(fixture, 'object.dit:status', 'complete')
const tree = renderer
.create(<ActivityFeedCard activity={fixture} showDetails={false} />)
.create(<Activity activity={fixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -88,7 +89,7 @@ describe('ActivityFeedCard', () => {
describe('when there is a service delivery', () => {
test('should render service delivery activity', () => {
const tree = renderer
.create(<ActivityFeedCard activity={serviceDeliveryActivityFixture} showDetails={false} />)
.create(<Activity activity={serviceDeliveryActivityFixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -102,7 +103,7 @@ describe('ActivityFeedCard', () => {
},
}
const tree = renderer
.create(<ActivityFeedCard activity={activity} showDetails={false} />)
.create(<Activity activity={activity} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -116,7 +117,7 @@ describe('ActivityFeedCard', () => {
interactionActivityFixture.object.attributedTo.filter(a => !a.type.includes('Person')))

const tree = renderer
.create(<ActivityFeedCard activity={interactionWithNoPeople} showDetails={false} />)
.create(<Activity activity={interactionWithNoPeople} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -128,7 +129,7 @@ describe('ActivityFeedCard', () => {
set(interactionWithoutService, 'object.dit:service', null)

const tree = renderer
.create(<ActivityFeedCard activity={interactionWithoutService} showDetails={false} />)
.create(<Activity activity={interactionWithoutService} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -138,7 +139,7 @@ describe('ActivityFeedCard', () => {
test('should render the CTI investment project activity card', () => {
const commitmentToInvest = { ...investmentProjectsCTIFixture }
const tree = renderer
.create(<ActivityFeedCard activity={commitmentToInvest} showDetails={false} />)
.create(<Activity activity={commitmentToInvest} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -148,7 +149,7 @@ describe('ActivityFeedCard', () => {
test('should render the FDI investment project activity card', () => {
const foreignDirectInvestment = { ...investmentProjectsFDIFixture }
const tree = renderer
.create(<ActivityFeedCard activity={foreignDirectInvestment} showDetails={false} />)
.create(<Activity activity={foreignDirectInvestment} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -158,7 +159,7 @@ describe('ActivityFeedCard', () => {
test('should render the Non-FDI investment project activity card', () => {
const nonForeignDirectInvestment = { ...investmentProjectsNonFDIFixture }
const tree = renderer
.create(<ActivityFeedCard activity={nonForeignDirectInvestment} showDetails={false} />)
.create(<Activity activity={nonForeignDirectInvestment} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -168,7 +169,7 @@ describe('ActivityFeedCard', () => {
test('should render an activity card', () => {
const orderAdded = { ...orderAddedFixture }
const tree = renderer
.create(<ActivityFeedCard activity={orderAdded} showDetails={false} />)
.create(<Activity activity={orderAdded} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -178,7 +179,7 @@ describe('ActivityFeedCard', () => {
test('should render an activity card', () => {
const companiesHouseAccountsDue = { ...companiesHouseAccountsDueFixture }
const tree = renderer
.create(<ActivityFeedCard activity={companiesHouseAccountsDue} showDetails={false} />)
.create(<Activity activity={companiesHouseAccountsDue} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand All @@ -188,7 +189,7 @@ describe('ActivityFeedCard', () => {
test('should render an activity card', () => {
const companiesHouseCompanyIncorporated = { ...companiesHouseCompaniesFixture }
const tree = renderer
.create(<ActivityFeedCard
.create(<Activity
activity={companiesHouseCompanyIncorporated}
showDetails={false}
/>)
Expand All @@ -200,7 +201,7 @@ describe('ActivityFeedCard', () => {
describe('when there is a HMRC Exporter record', () => {
test('should render an activity card', () => {
const tree = renderer
.create(<ActivityFeedCard activity={hmrcExportersFixture} showDetails={false} />)
.create(<Activity activity={hmrcExportersFixture} showDetails={false} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { uniqueId } from 'lodash'
import { mount } from 'enzyme'
import { Details } from 'govuk-react'

import ActivityFeed from './ActivityFeed'
import interactionActivityFixture from '../../fixtures/activity_feed/interactions/interaction'
import ActivityFeed from '../ActivityFeed'
import interactionActivityFixture from '../__fixtures__/interactions/interaction'


const generateActivities = total => Array.from({ length: total }, () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import renderer from 'react-test-renderer'
import nock from 'nock'

import ActivityFeedApp from './ActivityFeedApp'
import esResults from '../../fixtures/activity_feed/activity-feed-from-es'
import ActivityFeedApp from '../ActivityFeedApp'
import esResults from '../__fixtures__/activity-feed-from-es'

describe('ActivityFeedApp', () => {
test('fetches activity feed', async (done) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import renderer from 'react-test-renderer'
import { shallow } from 'enzyme'

import ActivityFeedFilters from './ActivityFeedFilters'
import ActivityFeedFilters from '../ActivityFeedFilters'

describe('ActivityFeedFilters', () => {
describe('when the details for all activities are hidden', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import renderer from 'react-test-renderer'

import ActivityFeedHeader from './ActivityFeedHeader'
import ActivityFeedHeader from '../ActivityFeedHeader'

describe('ActivityFeedHeader', () => {
test('renders header without props', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import renderer from 'react-test-renderer'
import { mount } from 'enzyme'

import ActivityFeedPagination from './ActivityFeedPagination'
import ActivityFeedPagination from '../ActivityFeedPagination'

describe('ActivityFeedPagination', () => {
test('renders default pagination', () => {
Expand Down
Loading

0 comments on commit 8c3e924

Please sign in to comment.