diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb
index 4fd8a9528..338cda997 100644
--- a/app/views/comments/index.html.erb
+++ b/app/views/comments/index.html.erb
@@ -42,9 +42,9 @@
<% end %>
<% end %>
-<%= javascript_packs_with_chunks_tag "commentDropdowns", defer: true %>
+<%= javascript_packs_with_chunks_tag "commentDropdowns", "followButtons", defer: true %>
-
+
<% if @commentable.class.name == "Article" %>
<%= render "shared/payment_pointer", user: @commentable.user %>
@@ -159,5 +159,6 @@
<%== YoutubeTag.script %>
<%== PodcastTag.script %>
<%== GistTag.script %>
+ <%== RunkitTag.script %>
<%== TwitterTimelineTag.script %>
diff --git a/cypress/integration/seededFlows/articleFlows/viewArticleDiscussion.spec.js b/cypress/integration/seededFlows/articleFlows/viewArticleDiscussion.spec.js
new file mode 100644
index 000000000..e10c879d8
--- /dev/null
+++ b/cypress/integration/seededFlows/articleFlows/viewArticleDiscussion.spec.js
@@ -0,0 +1,49 @@
+describe('View article discussion', () => {
+ beforeEach(() => {
+ cy.testSetup();
+ cy.fixture('users/articleEditorV1User.json').as('user');
+
+ cy.get('@user').then((user) => {
+ cy.loginAndVisit(user, '/admin_mcadmin/test-article-slug/comments');
+ // Make sure the page has loaded
+ cy.findByRole('heading', { name: 'Test article' });
+ });
+ });
+
+ it('follows and unfollows a user from a comment preview card', () => {
+ // Make sure the preview card is ready to be interacted with
+ cy.get('[data-initialized]');
+ cy.findByRole('button', { name: 'Admin McAdmin profile details' }).click();
+
+ cy.findByTestId('profile-preview-card').within(() => {
+ cy.findByRole('button', { name: 'Follow' }).as('userFollowButton');
+ cy.get('@userFollowButton').click();
+
+ // Confirm the follow button has been updated
+ cy.get('@userFollowButton').should('have.text', 'Following');
+
+ // Repeat and check the button changes back to 'Follow'
+ cy.get('@userFollowButton').click();
+ cy.get('@userFollowButton').should('have.text', 'Follow');
+ });
+ });
+
+ it('initializes the follow button when a new comment is added', () => {
+ cy.findByRole('textbox', { name: 'Add a comment to the discussion' }).type(
+ 'New comment',
+ );
+ cy.findByRole('button', { name: 'Submit' }).click();
+
+ cy.findByRole('button', {
+ name: 'Article Editor v1 User profile details',
+ }).as('previewButton');
+
+ // Make sure the newly added button is ready for interaction
+ cy.get('@previewButton').should('have.attr', 'data-initialized');
+ cy.get('@previewButton').click();
+
+ cy.findAllByTestId('profile-preview-card')
+ .first()
+ .findByRole('button', { name: 'Edit profile' });
+ });
+});
diff --git a/spec/support/seeds/seeds_e2e.rb b/spec/support/seeds/seeds_e2e.rb
index f610a0cff..d14d0c8fe 100644
--- a/spec/support/seeds/seeds_e2e.rb
+++ b/spec/support/seeds/seeds_e2e.rb
@@ -342,6 +342,7 @@ seeder.create_if_doesnt_exist(Article, "title", "Test article") do
featured: true,
show_comments: true,
user_id: admin_user.id,
+ slug: "test-article-slug",
)
comment_attributes = {