@@ -60,21 +61,28 @@
<%= sanitize tag.short_summary %>
<% end %>
- <% if tag %>
-
<% end %>
<% end %>
-<%= javascript_packs_with_chunks_tag "followButtons", defer: true %>
+
+<%= javascript_packs_with_chunks_tag "TagsIndex", defer: true %>
diff --git a/config/locales/views/tags/en.yml b/config/locales/views/tags/en.yml
index 419625359..c2610fe3b 100644
--- a/config/locales/views/tags/en.yml
+++ b/config/locales/views/tags/en.yml
@@ -38,7 +38,12 @@ en:
placeholder: Optional - Can be used for challenges, i.e. submission guidelines.
submit: Save
follow: Follow
+ hide: Hide
+ aria_labels:
+ follow: "Follow tag: %{tag_name}"
+ hide: "Hide tag: %{tag_name}"
following_tags: Following tags
+ hidden_tags: Hidden tags
moderator:
text_html: "comma separated, space is optional. Example: %{code}"
code: 123
diff --git a/config/locales/views/tags/fr.yml b/config/locales/views/tags/fr.yml
index c12f5030a..e6703b84a 100644
--- a/config/locales/views/tags/fr.yml
+++ b/config/locales/views/tags/fr.yml
@@ -39,7 +39,12 @@ fr:
submit: Save
markdown_html: "%{tag} is the name of the tag used in Markdown."
follow: Suivre
+ aria_labels:
+ follow: "Follow tag: %{tag_name}"
+ hide: "Hide tag: %{tag_name}"
+ hide: Hide
following_tags: Sujets suivis
+ hidden_tags: Hidden tags
moderator:
text_html: "comma separated, space is optional. Example: %{code}"
code: 123
diff --git a/cypress/e2e/seededFlows/loggedOutFlows/showLoginModal.spec.js b/cypress/e2e/seededFlows/loggedOutFlows/showLoginModal.spec.js
index e4b83c5a9..dae9a4932 100644
--- a/cypress/e2e/seededFlows/loggedOutFlows/showLoginModal.spec.js
+++ b/cypress/e2e/seededFlows/loggedOutFlows/showLoginModal.spec.js
@@ -80,7 +80,6 @@ describe('Show log in modal', () => {
it('should show login modal for tag follow button click', () => {
cy.visit('/tags');
cy.findByRole('heading', { name: 'Tags' });
- cy.get('[data-follow-clicks-initialized]');
verifyLoginModalBehavior(() =>
cy.findByRole('button', { name: 'Follow tag: tag1' }),
@@ -94,6 +93,15 @@ describe('Show log in modal', () => {
);
});
+ it('should show login modal for tag hide button click', () => {
+ cy.visit('/tags');
+ cy.findByRole('heading', { name: 'Tags' });
+
+ verifyLoginModalBehavior(() =>
+ cy.findByRole('button', { name: 'Hide tag: tag1' }),
+ );
+ });
+
it('should show login modal for user profile follow button click', () => {
cy.visit('/admin_mcadmin');
cy.get('[data-follow-clicks-initialized]');
diff --git a/cypress/e2e/seededFlows/tagsFlows/followTag.spec.js b/cypress/e2e/seededFlows/tagsFlows/followTag.spec.js
index b136cacd0..e1b128539 100644
--- a/cypress/e2e/seededFlows/tagsFlows/followTag.spec.js
+++ b/cypress/e2e/seededFlows/tagsFlows/followTag.spec.js
@@ -7,14 +7,13 @@ describe('Follow tag', () => {
cy.get('@user').then((user) => {
cy.loginAndVisit(user, '/tags').then(() => {
cy.findByRole('heading', { name: 'Tags' });
- cy.get('[data-follow-clicks-initialized]');
});
});
});
it('Follows and unfollows a tag from the tag index page', () => {
cy.intercept('/follows').as('followsRequest');
- cy.findByRole('button', { name: 'Follow tag: tag1' }).as('followButton');
+ cy.findByRole('button', { name: 'Follow tag: tag0' }).as('followButton');
cy.get('@followButton').click();
cy.wait('@followsRequest');
@@ -28,6 +27,34 @@ describe('Follow tag', () => {
cy.get('@followButton').should('have.text', 'Follow');
cy.get('@followButton').should('have.attr', 'aria-pressed', 'false');
});
+
+ it('hides and unhides a tag', () => {
+ cy.intercept('/follows').as('followsRequest');
+ cy.findByRole('button', { name: 'Follow tag: tag0' }).as('followButton');
+ cy.findByRole('button', { name: 'Hide tag: tag0' }).as('hideButton');
+
+ cy.get('@hideButton').click();
+ cy.wait('@followsRequest');
+
+ // clicking on 'Hide' should change it to an 'Unhide'
+ // and remove the Follow button
+ cy.get('@hideButton').should('have.text', 'Unhide');
+ cy.get('@followButton').should('not.exist');
+
+ // clicking on 'Unhide' should change it back to 'Hide'
+ // and show a 'Following' button
+ cy.get('@hideButton').click();
+ cy.wait('@followsRequest');
+
+ cy.get('@hideButton').should('have.text', 'Hide');
+ cy.get('@followButton').should('not.exist');
+ cy.findByRole('button', { name: 'Following tag: tag0' }).as(
+ 'followingButton',
+ );
+ cy.get('@followingButton').should('exist');
+ cy.get('@followingButton').should('have.text', 'Following');
+ cy.get('@followingButton').should('have.attr', 'aria-pressed', 'true');
+ });
});
describe('Tag feed page', () => {