Skip to content

Commit 8f42833

Browse files
committed
refactor(report): rename ReportableEntity.comment to ReportableEntity.engagement
- Update `ReportableEntity` enum: - Rename `comment` to `engagement` - Update JSON value to 'engagement' - Update related tests - Update fixtures to use `engagement` instead of `comment` - Update models to include missing fields and adjust serialization
1 parent d716f05 commit 8f42833

File tree

7 files changed

+27
-51
lines changed

7 files changed

+27
-51
lines changed

lib/src/enums/reportable_entity.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum ReportableEntity {
1616
@JsonValue('source')
1717
source,
1818

19-
/// The report is for a user-submitted comment.
20-
@JsonValue('comment')
21-
comment,
19+
/// The report is for a user engagement (mainly for engagements with comments).
20+
@JsonValue('engagement')
21+
engagement,
2222
}

lib/src/fixtures/reports.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ List<Report> getReportsFixturesData({DateTime? now}) {
1414
final headlines = getHeadlinesFixturesData(
1515
now: referenceTime,
1616
).take(10).toList();
17+
final engagementsWithComments = getEngagementsFixturesData(
18+
now: referenceTime,
19+
).where((e) => e.comment != null).toList();
1720
final reportIds = [
1821
kReportId1,
1922
kReportId2,
@@ -75,8 +78,8 @@ List<Report> getReportsFixturesData({DateTime? now}) {
7578
Report(
7679
id: reportIds[i],
7780
reporterUserId: user.id,
78-
entityType: ReportableEntity.comment,
79-
entityId: getHeadlineCommentsFixturesData(now: referenceTime)[i].id,
81+
entityType: ReportableEntity.engagement,
82+
entityId: engagementsWithComments[i].id,
8083
reason: commentReasons[i % commentReasons.length].name,
8184
additionalComments: 'This comment is spam.',
8285
status: status,

lib/src/models/user_generated_content/comment.g.dart

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/models/user_generated_content/engagement.g.dart

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/models/user_generated_content/reaction.g.dart

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/models/user_generated_content/report.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/src/enums/reportable_entity_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ void main() {
99
containsAll([
1010
ReportableEntity.headline,
1111
ReportableEntity.source,
12-
ReportableEntity.comment,
12+
ReportableEntity.engagement,
1313
]),
1414
);
1515
});
1616

1717
test('has correct string values', () {
1818
expect(ReportableEntity.headline.name, 'headline');
1919
expect(ReportableEntity.source.name, 'source');
20-
expect(ReportableEntity.comment.name, 'comment');
20+
expect(ReportableEntity.engagement.name, 'engagement');
2121
});
2222

2323
test('can be created from string values', () {
@@ -27,8 +27,8 @@ void main() {
2727
);
2828
expect(ReportableEntity.values.byName('source'), ReportableEntity.source);
2929
expect(
30-
ReportableEntity.values.byName('comment'),
31-
ReportableEntity.comment,
30+
ReportableEntity.values.byName('engagement'),
31+
ReportableEntity.engagement,
3232
);
3333
});
3434
});

0 commit comments

Comments
 (0)