docbrown/app/javascript/articles/__tests__/utilities/articleUtilities.js
Joshua Wehner 8a45a4bf67
Enable multiple reactions on #index (including front-end render) (#19169)
* Revert "(Temporarily) Remove multiple reactions from #index (#19142)"

This reverts commit a45d300639.

* Clean up reaction category count mechanism for #index

* Remove, unnecessary

* Expose reaction categories in JSON response

* Update test with new categories

* Fix flaky sample / minimum floor

* buildArticle (infinite scroll) with multiple reactions

* If we're doing #index front-end, we aren't feature-flag'd

* nbsp

* react (home feed) has multiple_reactions

* Update app/assets/javascripts/utilities/buildArticleHTML.js

Co-authored-by: Rajat Talesra <rajat@forem.com>

* Clean up Reactable#reaction_categories

* Use 'multiple_reactions_icons_container'

* Try adding a ReactionCount test

* Adapt memory fix from 76dd53d

* Try adding categories to fixture

* Attempt to eager-load distinct public categories

* Setting dependent to the default for rubocop

* Try making image assets more public?

* Revert "Fix flaky sample / minimum floor"

---------

Co-authored-by: Rajat Talesra <rajat@forem.com>
Co-authored-by: Mac Siri <mac@forem.com>
2023-03-03 15:17:19 +01:00

353 lines
8.4 KiB
JavaScript

export const assetPath = (relativeUrl) => `/images/${relativeUrl}`;
export const article = {
id: 62407,
title: 'Unbranded Home Loan Account',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 35682,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 23289,
user: {
username: 'Emil99',
name: 'Stella Macejkovic',
profile_image_90: '/images/10.png',
},
published_at_int: 1582037964819,
published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT',
published_at: '2020-02-18T14:59:24Z',
readable_publish_date: 'February 18',
top_comments: [],
main_image: '/images/10.png',
};
export const articleWithOrganization = {
id: 62407,
title: 'Unbranded Home Loan Account',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 35682,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 23289,
user: {
username: 'Emil99',
name: 'Stella Macejkovic',
profile_image_90: '/images/10.png',
},
published_at_int: 1582037964819,
published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT',
readable_publish_date: 'February 18',
top_comments: [],
organization: {
id: 87120,
name: 'Web info-mediaries',
slug: 'bluetooth-Gorgeous-Wooden-Pants',
profile_image_90: '/images/30.png',
},
main_image: '/images/10.png',
};
export const articleWithSnippetResult = {
id: 62407,
title: 'Unbranded Home Loan Account',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 35682,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 23289,
user: {
username: 'Emil99',
name: 'Stella Macejkovic',
profile_image_90: '/images/10.png',
},
published_at_int: 1582037964819,
published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT',
published_at: '2020-02-18T14:59:24Z',
readable_publish_date: 'February 18',
top_comments: [],
highlight: {
body_text: [
'copying Rest withdrawal Handcrafted multi-state Pre-emptive e-markets feed',
'overriding RSS Fantastic Plastic Gloves invoice productize systemic Monaco',
],
},
};
export const articleWithReactions = {
id: 62407,
title: 'Unbranded Home Loan Account',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 35682,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 23289,
user: {
username: 'Emil99',
name: 'Stella Macejkovic',
profile_image_90: '/images/10.png',
},
published_at_int: 1582037964819,
published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT',
published_at: '2020-03-19T10:04:15-05:00',
readable_publish_date: 'February 18',
top_comments: [],
public_reactions_count: 232,
public_reaction_categories: [
{
slug: 'like',
name: 'Like',
icon: 'sparkle-heart',
position: 1,
},
{
slug: 'unicorn',
name: 'Unicorn',
icon: 'multi-unicorn',
position: 2,
},
{
slug: 'raised_hands',
name: 'Raised Hands',
icon: 'raised-hands',
position: 4,
},
{
slug: 'fire',
name: 'Fire',
icon: 'fire',
position: 5,
},
],
};
export const articleWithoutReactions = {
...article,
public_reactions_count: 428,
};
export const articleWithComments = {
id: 62407,
title: 'Unbranded Home Loan Account',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 35682,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 23289,
user: {
username: 'Emil99',
name: 'Stella Macejkovic',
profile_image_90: '/images/10.png',
},
published_at_int: 1582037964819,
published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT',
published_at: '2020-03-19T10:04:15-05:00',
readable_publish_date: 'February 18',
top_comments: [
{
comment_id: 23,
user_id: 6,
published_timestamp: '2020-04-21T19:41:40Z',
published_at_int: new Date(),
safe_processed_html: '<p>Kitsch hoodie artisan.</p>\n\n',
path: '/naoma_dr_rice/comment/n',
username: 'naoma_dr_rice',
name: 'Dr. Naoma Rice',
profile_image_90: '/images/7.png',
},
],
public_reactions_count: 428,
comments_count: 213,
};
export const articleWithReadingTimeGreaterThan1 = {
id: 62407,
title: 'Unbranded Home Loan Account',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 35682,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 23289,
user: {
username: 'Emil99',
name: 'Stella Macejkovic',
profile_image_90: '/images/10.png',
},
published_at_int: 1582037964819,
published_timestamp: 'Tue, 18 Feb 2020 14:59:24 GMT',
published_at: '2020-02-18T14:59:24Z',
readable_publish_date: 'February 18',
top_comments: [],
reading_time: 8,
};
export const videoArticle = {
id: 49020,
title: 'monitor recontextualize',
path: '/some-post/path',
type_of: '',
class_name: 'Article',
flare_tag: {
id: 58676,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 27683,
user: {
username: 'Nova_Luettgen',
name: 'Henri Gibson',
profile_image_90: '/images/10.png',
},
published_at_int: 1582038662478,
published_timestamp: 'Tue, 18 Feb 2020 15:11:02 GMT',
published_at: '2020-02-18T14:59:24Z',
readable_publish_date: 'February 18',
cloudinary_video_url: '/images/apple-icon.png',
main_image: '/images/10.png',
video_duration_in_minutes: 10,
};
export const podcastArticle = {
id: 49020,
title: 'monitor recontextualize',
path: '/some-post/path',
type_of: 'podcast_episodes',
class_name: 'Article',
flare_tag: {
id: 58676,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 27683,
user: {
username: 'Nova_Luettgen',
name: 'Henri Gibson',
profile_image_90: '/images/10.png',
},
published_at_int: 1582038662478,
published_timestamp: 'Tue, 18 Feb 2020 15:11:02 GMT',
published_at: '2020-02-18T15:11:02Z',
readable_publish_date: 'February 18',
podcast: {
slug: 'monitor-recontextualize',
title: 'Rubber local',
image_url: '/images/16.png',
image_90: '/images/16.png',
},
slug: 'episode-slug',
};
export const podcastEpisodeArticle = {
id: 49020,
title: 'monitor recontextualize',
path: '/some-post/path',
type_of: '',
class_name: 'PodcastEpisode',
flare_tag: {
id: 58676,
name: 'javascript',
hotness_score: 99,
points: 23,
bg_color_hex: '#000000',
text_color_hex: '#ffffff',
},
tag_list: ['javascript', 'ruby', 'go'],
cached_tag_list_array: [],
user_id: 27683,
user: {
username: 'Nova_Luettgen',
name: 'Henri Gibson',
profile_image_90: '/images/10.png',
},
published_at_int: 1582038662478,
published_timestamp: 'Tue, 18 Feb 2020 15:11:02 GMT',
published_at: '2020-02-18T15:11:02Z',
readable_publish_date: 'February 18',
};
export const userArticle = {
id: 24692,
title: 'Phyllis Armstrong',
user_id: 7955,
class_name: 'User',
user: {
username: 'phyllis.armstrong',
name: 'Phyllis Armstrong',
profile_image_90: '/images/3.png',
},
};
export const featuredArticle = {
...article,
main_image: '/images/onboarding-background.png',
public_reactions_count: 428,
comments_count: 213,
};
export const featuredArticleWithOrganization = {
...articleWithOrganization,
main_image: '/images/12.png',
};