Skip to content

Commit 6484e70

Browse files
committed
feat(HNT-1363): remove parser dependency
- removes time to read (not available from zyte) - removes publish date (ticket filed to re-add)
1 parent 6ab0b02 commit 6484e70

File tree

10 files changed

+31
-214
lines changed

10 files changed

+31
-214
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
.env.development.local
2121
.env.test.local
2222
.env.production.local
23+
tsconfig.tsbuildinfo
2324

2425
npm-debug.log*
2526
yarn-debug.log*

src/api/fragments/BasicParserItemData.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/api/fragments/prospectWithCorpusItems.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { gql } from '@apollo/client';
22
import { CuratedItemDataWithHistory } from './CuratedItemWithHistory';
33
import { RejectedItemData } from './rejectedItemData';
4-
import { BasicParserItemData } from './BasicParserItemData';
54

65
/**
76
* Everything we need to fetch for a Prospect, including optional
@@ -32,11 +31,7 @@ export const ProspectDataWithCorpusItems = gql`
3231
rejectedCorpusItem {
3332
...RejectedItemData
3433
}
35-
item {
36-
...BasicParserItemData
37-
}
3834
}
3935
${CuratedItemDataWithHistory}
4036
${RejectedItemData}
41-
${BasicParserItemData}
4237
`;

src/curated-corpus/components/ExistingProspectCard/ExistingProspectCard.test.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ describe('The ExistingProspectCard component', () => {
6767
<MemoryRouter>
6868
<ExistingProspectCard
6969
item={prospect.approvedCorpusItem!}
70-
parserItem={prospect.item!}
7170
prospectId={prospect.prospectId}
7271
onSchedule={onSchedule}
7372
onRemoveProspect={onRemoveProspect}
@@ -100,7 +99,6 @@ describe('The ExistingProspectCard component', () => {
10099
<MemoryRouter>
101100
<ExistingProspectCard
102101
item={prospect.approvedCorpusItem!}
103-
parserItem={prospect.item!}
104102
prospectId={prospect.prospectId}
105103
onSchedule={onSchedule}
106104
onRemoveProspect={onRemoveProspect}
@@ -120,7 +118,6 @@ describe('The ExistingProspectCard component', () => {
120118
<MemoryRouter>
121119
<ExistingProspectCard
122120
item={prospect.approvedCorpusItem!}
123-
parserItem={prospect.item!}
124121
prospectId={prospect.prospectId}
125122
onSchedule={onSchedule}
126123
onRemoveProspect={onRemoveProspect}
@@ -140,7 +137,6 @@ describe('The ExistingProspectCard component', () => {
140137
<MemoryRouter>
141138
<ExistingProspectCard
142139
item={prospect.approvedCorpusItem!}
143-
parserItem={prospect.item!}
144140
prospectId={prospect.prospectId}
145141
onSchedule={onSchedule}
146142
onRemoveProspect={onRemoveProspect}
@@ -160,7 +156,6 @@ describe('The ExistingProspectCard component', () => {
160156
<MemoryRouter>
161157
<ExistingProspectCard
162158
item={prospect.approvedCorpusItem!}
163-
parserItem={prospect.item!}
164159
prospectId={prospect.prospectId}
165160
onSchedule={onSchedule}
166161
onRemoveProspect={onRemoveProspect}
@@ -183,7 +178,6 @@ describe('The ExistingProspectCard component', () => {
183178
<MemoryRouter>
184179
<ExistingProspectCard
185180
item={prospect.approvedCorpusItem!}
186-
parserItem={prospect.item!}
187181
prospectId={prospect.prospectId}
188182
onSchedule={onSchedule}
189183
onRemoveProspect={onRemoveProspect}
@@ -203,7 +197,6 @@ describe('The ExistingProspectCard component', () => {
203197
<MemoryRouter>
204198
<ExistingProspectCard
205199
item={prospect.approvedCorpusItem!}
206-
parserItem={prospect.item!}
207200
prospectId={prospect.prospectId}
208201
onSchedule={onSchedule}
209202
onRemoveProspect={onRemoveProspect}
@@ -252,7 +245,6 @@ describe('The ExistingProspectCard component', () => {
252245
<MemoryRouter>
253246
<ExistingProspectCard
254247
item={prospectWithScheduleHistory.approvedCorpusItem!}
255-
parserItem={prospect.item!}
256248
prospectId={prospect.prospectId}
257249
onSchedule={onSchedule}
258250
onRemoveProspect={onRemoveProspect}

src/curated-corpus/components/ExistingProspectCard/ExistingProspectCard.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
2020
import { DateTime } from 'luxon';
2121

2222
import { curationPalette } from '../../../theme';
23-
import { ApprovedCorpusItem, Item } from '../../../api/generatedTypes';
23+
import { ApprovedCorpusItem } from '../../../api/generatedTypes';
2424
import { Button } from '../../../_shared/components';
2525
import { getCuratorNameFromLdap } from '../../helpers/helperFunctions';
2626
import { ScheduleHistory } from '../ScheduleHistory/ScheduleHistory';
@@ -34,11 +34,6 @@ interface ExistingProspectCardProps {
3434
* An object with everything approved curated item-related in it.
3535
*/
3636
item: ApprovedCorpusItem;
37-
38-
/**
39-
* An object with details from the parser
40-
*/
41-
parserItem: Item;
4237
/**
4338
* This is the prospect.id and NOT prospect.prospectId
4439
*/
@@ -73,7 +68,6 @@ export const ExistingProspectCard: React.FC<ExistingProspectCardProps> = (
7368
): JSX.Element => {
7469
const {
7570
item,
76-
parserItem,
7771
onSchedule,
7872
onRemoveProspect,
7973
prospectId,
@@ -115,16 +109,6 @@ export const ExistingProspectCard: React.FC<ExistingProspectCardProps> = (
115109
</ListItemIcon>
116110
<ListItemText secondary={item.language} />
117111
</ListItem>
118-
<ListItem disableGutters>
119-
<ListItemText
120-
secondary={
121-
parserItem?.datePublished &&
122-
`Published ${DateTime.fromJSDate(
123-
new Date(parserItem?.datePublished),
124-
).toFormat('MMMM dd, yyyy')}`
125-
}
126-
/>
127-
</ListItem>
128112
<ListItem disableGutters>
129113
<ListItemIcon sx={{ minWidth: '1.5rem' }}>
130114
<FaceIcon fontSize="small" />

src/curated-corpus/components/ProspectFilters/ProspectFilters.test.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ describe('The ProspectFilters component', () => {
9393
const onChange = jest.fn();
9494
const onSortByPublishedDate = jest.fn();
9595
const sortByPublishedDate = false;
96-
const sortByTimeToRead = false;
97-
const handleSortByTimeToRead = jest.fn();
9896

9997
// const mockSetFilters = jest.fn();
10098
//
@@ -114,8 +112,6 @@ describe('The ProspectFilters component', () => {
114112
onChange={onChange}
115113
onSortByPublishedDate={onSortByPublishedDate}
116114
sortByPublishedDate={sortByPublishedDate}
117-
sortByTimeToRead={sortByTimeToRead}
118-
handleSortByTimeToRead={handleSortByTimeToRead}
119115
/>,
120116
);
121117
};
@@ -142,19 +138,15 @@ describe('The ProspectFilters component', () => {
142138
expect(switchLabel).toBeInTheDocument();
143139
});
144140

141+
/*
142+
TODO: re-enable after https://mozilla-hub.atlassian.net/browse/HNT-1364
145143
it('should render the sort by published date filter', () => {
146144
renderComponent();
147145
148146
const publishedDate = screen.getByText(/Published Date/i);
149147
expect(publishedDate).toBeInTheDocument();
150148
});
151-
152-
it('should render the sort by time to read filter', () => {
153-
renderComponent();
154-
155-
const timeToRead = screen.getByText(/Time to Read/i);
156-
expect(timeToRead).toBeInTheDocument();
157-
});
149+
*/
158150

159151
it('should render the topic filter', () => {
160152
renderComponent();

src/curated-corpus/components/ProspectFilters/ProspectFilters.tsx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ interface ProspectFiltersProps {
6363
* in the parent component (Prospecting page).
6464
*/
6565
sortByPublishedDate: boolean;
66-
67-
/**
68-
* Boolean flag to represent the state of sortByTimeToRead toggle in the parent component
69-
* (prospecting page)
70-
*/
71-
sortByTimeToRead: boolean;
72-
73-
/**
74-
* Function to toggle sortByTimeToRead in the parent component (prospecting page)
75-
*/
76-
handleSortByTimeToRead: VoidFunction;
7766
}
7867

7968
/**
@@ -91,12 +80,14 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
9180
setProspectMetadataFilters,
9281
excludePublisherSwitch,
9382
filterByPublisher,
83+
// remove disable after https://mozilla-hub.atlassian.net/browse/HNT-1364
84+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
9485
sortByPublishedDate,
9586
setFilterByPublisher,
9687
onChange,
88+
// remove disable after https://mozilla-hub.atlassian.net/browse/HNT-1364
89+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
9790
onSortByPublishedDate,
98-
sortByTimeToRead,
99-
handleSortByTimeToRead,
10091
} = props;
10192

10293
// Extract all topics from prospects item data
@@ -137,6 +128,10 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
137128
labelPlacement={'top'} // Ensures the label is on top of the switch
138129
/>
139130
</FormGroup>
131+
{/*
132+
TODO: uncomment this filter after adding published date to prospect
133+
object
134+
https://mozilla-hub.atlassian.net/browse/HNT-1364
140135
<FormGroup>
141136
<FormControlLabel
142137
sx={{ mx: 2, mb: 2 }}
@@ -150,19 +145,7 @@ export const ProspectFilters: React.FC<ProspectFiltersProps> = (
150145
labelPlacement={'top'} // Ensures the label is on top of the switch
151146
/>
152147
</FormGroup>
153-
<FormGroup>
154-
<FormControlLabel
155-
sx={{ mx: 2, mb: 2 }}
156-
control={
157-
<Switch
158-
checked={sortByTimeToRead}
159-
onChange={handleSortByTimeToRead}
160-
/>
161-
}
162-
label={'Time to Read'}
163-
labelPlacement={'top'} // Ensures the label is on top of the switch
164-
/>
165-
</FormGroup>
148+
*/}
166149
{/*Topic Filter*/}
167150
{prospects.length > 0 && (
168151
<FormGroup sx={{ mx: 1, mb: 2 }}>

src/curated-corpus/components/ProspectListCard/ProspectListCard.test.tsx

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,20 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
33
import { MemoryRouter } from 'react-router-dom';
4-
import {
5-
CorpusLanguage,
6-
Item,
7-
Prospect,
8-
Topics,
9-
} from '../../../api/generatedTypes';
4+
import { CorpusLanguage, Prospect, Topics } from '../../../api/generatedTypes';
105
import { ProspectListCard } from './ProspectListCard';
116
import userEvent from '@testing-library/user-event';
127
import { MockedProvider, MockedResponse } from '@apollo/client/testing';
138

149
describe('The ProspectListCard component', () => {
1510
let prospect: Prospect;
16-
let parserItem: Item;
1711

1812
const onAddToCorpus = jest.fn();
1913
const onRecommend = jest.fn();
2014
const onReject = jest.fn();
2115
const onRemoveProspect = jest.fn();
2216

2317
beforeEach(() => {
24-
parserItem = {
25-
id: '0',
26-
itemId: 'test-id',
27-
givenUrl: 'www.test-item.com',
28-
normalUrl: 'www.test-normal-item.com',
29-
readerSlug: 'test-slug',
30-
timeToRead: 5,
31-
};
32-
3318
prospect = {
3419
id: '123-abc',
3520
prospectId: '456-dfg',
@@ -46,9 +31,6 @@ describe('The ProspectListCard component', () => {
4631
topic: Topics.Technology,
4732
saveCount: 111222,
4833
isSyndicated: false,
49-
item: {
50-
...parserItem,
51-
},
5234
};
5335
});
5436

@@ -62,7 +44,6 @@ describe('The ProspectListCard component', () => {
6244
onRecommend={onRecommend}
6345
onReject={onReject}
6446
onRemoveProspect={onRemoveProspect}
65-
parserItem={prospect.item!}
6647
/>
6748
</MemoryRouter>
6849
</MockedProvider>,
@@ -142,46 +123,6 @@ describe('The ProspectListCard component', () => {
142123
expect(screen.getByText('Syndicated')).toBeInTheDocument();
143124
});
144125

145-
it('should render time to read when prospect has a time to read', () => {
146-
renderComponent();
147-
148-
expect(
149-
screen.getByText(`${prospect.item?.timeToRead} min(s)`),
150-
).toBeInTheDocument();
151-
});
152-
153-
it('should not render time to read when prospect does not a time to read', () => {
154-
// setting time to read to undefined
155-
parserItem.timeToRead = undefined;
156-
157-
// modifying prospect item to not have a time to read
158-
prospect = {
159-
...prospect,
160-
item: {
161-
...parserItem,
162-
},
163-
};
164-
165-
renderComponent();
166-
167-
expect(
168-
screen.queryByText(`${prospect.item?.timeToRead} min(s)`),
169-
).not.toBeInTheDocument();
170-
});
171-
172-
it('should render when prospect does not have a parser object', () => {
173-
prospect = {
174-
...prospect,
175-
item: null,
176-
};
177-
178-
renderComponent();
179-
180-
expect(
181-
screen.queryByText(`${prospect.item?.timeToRead} min(s)`),
182-
).not.toBeInTheDocument();
183-
});
184-
185126
it('should render prospect card with the action buttons', () => {
186127
renderComponent();
187128

0 commit comments

Comments
 (0)