Skip to content

Commit

Permalink
Adding subject filter and sort to company activity tab (#7519)
Browse files Browse the repository at this point in the history
* Adding subject filter and sort to company activity tab
  • Loading branch information
stuart-mindt authored Feb 11, 2025
1 parent 6eaff36 commit 882b8a2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client/modules/Companies/CompanyActivity/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const ACTIVITY_TYPE_OPTIONS = [
export const SORT_OPTIONS = [
{ value: 'date:desc', name: 'Recently created' },
{ value: 'date:asc', name: 'Oldest first' },
{ value: 'subject', name: 'Subject A-Z (interaction)' },
]

export const NEW_PROJECT_TAG = {
Expand Down
9 changes: 9 additions & 0 deletions src/client/modules/Companies/CompanyActivity/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const CompanyActivityCollectionNoAS = ({
selectedOptions={selectedFilters.createdByOthers.options}
data-test="created-by-others-filter"
/>*/}

<Filters.Date
label={LABELS.dateAfter}
name="date_after"
Expand Down Expand Up @@ -193,6 +194,14 @@ const CompanyActivityCollectionNoAS = ({
label="Interaction details"
isOpen={true}
>
<Filters.Input
id="subject"
label={LABELS.subject}
name="subject"
qsParam="subject"
placeholder="Search subject"
data-test="subject-filter"
/>
<Filters.AdvisersTypeahead
taskProps={adviserListTask}
isMulti={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ describe('Company Activity Feed Filter', () => {
})
})

context('Subject Filter', () => {
it('should pass the interaction subject search term as a filter in the request payload', () => {
const queryString = buildQueryString({
subject: 'amazing',
})
cy.intercept('POST', companyActivitiesEndPoint).as('apiRequest')
cy.visit(
`${urls.companies.activity.index(
fixtures.company.allActivitiesCompany.id
)}?${queryString}`
)

assertPayload('@apiRequest', {
limit: 10,
offset: 0,
subject: 'amazing',
company: fixtures.company.allActivitiesCompany.id,
include_parent_companies: false,
include_subsidiary_companies: false,
sortby: 'date:desc',
})
})
})

context('Dates', () => {
const dateAfterFilter = '[data-test="date-after-filter"]'
const dateBeforeFilter = '[data-test="date-before-filter"]'
Expand Down
33 changes: 33 additions & 0 deletions test/functional/cypress/specs/companies/sort-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import qs from 'qs'

import urls from '../../../../../src/lib/urls'

const companySearchEndpoint = '/api-proxy/v4/search/company'
const companyActivitiesEndPoint = '/api-proxy/v4/search/company-activity'
const fixtures = require('../../fixtures')

const buildQueryString = (queryParams = {}) =>
qs.stringify({
// Default query params
sortby: 'date:desc',
...queryParams,
})

describe('Contact Collections Sort', () => {
context('Default sort', () => {
Expand Down Expand Up @@ -69,4 +80,26 @@ describe('Contact Collections Sort', () => {
})
})
})

context('Subject sort', () => {
const element = '[data-test="sortby"] select'

beforeEach(() => {
const queryString = buildQueryString()
cy.intercept('POST', companyActivitiesEndPoint).as('apiRequest')
cy.visit(
`${urls.companies.activity.index(
fixtures.company.allActivitiesCompany.id
)}?${queryString}`
)
cy.wait('@apiRequest')
})

it('should sort by "Subject A-Z (interaction)"', () => {
cy.get(element).select('subject')
cy.wait('@apiRequest').then(({ request }) => {
expect(request.body.sortby).to.equal('subject')
})
})
})
})

0 comments on commit 882b8a2

Please sign in to comment.