Reposition 'Feature Post' button on Mod Panel (#17735)
* physically move btn
* fix styling
* actually fix styling 😅
* remove old button
* add cypress seed and specs
* fix E2E seeds to fix Travis failures
* refactor specs
This commit is contained in:
parent
c93794f987
commit
2fed62454d
3 changed files with 99 additions and 40 deletions
|
|
@ -48,6 +48,21 @@
|
|||
<span></span>
|
||||
<%= crayons_icon_tag(:checkmark, class: "vomit-checkmark", title: t("views.moderations.actions.checkmark")) %>
|
||||
</button>
|
||||
<% if current_user.any_admin? && @moderatable.published %>
|
||||
<% @recent_featured_count = Article.where(featured: true).where("published_at > ?", 1.day.ago).size %>
|
||||
<button
|
||||
class="c-btn c-btn--primary w-100"
|
||||
id="feature-article-btn"
|
||||
data-article-featured="<%= @moderatable.featured %>"
|
||||
data-article-id="<%= @moderatable.id %>"
|
||||
data-article-author="<%= @moderatable.username %>"
|
||||
data-article-slug="<%= @moderatable.slug %>">
|
||||
<%= @moderatable.featured ? t("views.moderations.actions.unfeature") : t("views.moderations.actions.feature") %>
|
||||
</button>
|
||||
<div class="additional-subtext-section py-4 pt-2">
|
||||
<%= t("views.moderations.actions.featured_past_day", count: @recent_featured_count) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<a href="<%= URL.url %>/community-moderation#using-the-quick-reactions-to-moderate-content" target="_blank" rel="noopener">
|
||||
<span class="additional-subtext-section py-3">
|
||||
<%= t("views.moderations.actions.how") %>
|
||||
|
|
@ -177,22 +192,6 @@
|
|||
</button>
|
||||
|
||||
<div id="admin-action-options" class="admin-action-options dropdown-options hidden">
|
||||
<% @recent_featured_count = Article.where(featured: true).where("published_at > ?", 1.day.ago).size %>
|
||||
<div class="article-admin-action mt-2">
|
||||
<button
|
||||
class="c-btn c-btn--primary w-100 <%= "crayons-btn--destructive" if @moderatable.featured %>"
|
||||
id="feature-article-btn"
|
||||
data-article-featured="<%= @moderatable.featured %>"
|
||||
data-article-id="<%= @moderatable.id %>"
|
||||
data-article-author="<%= @moderatable.username %>"
|
||||
data-article-slug="<%= @moderatable.slug %>">
|
||||
<%= @moderatable.featured ? t("views.moderations.actions.unfeature") : t("views.moderations.actions.feature") %>
|
||||
</button>
|
||||
<div class="block additional-subtext-section py-4 pt-2">
|
||||
<%= t("views.moderations.actions.featured_past_day", count: @recent_featured_count) %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="article-admin-action">
|
||||
<button
|
||||
class="c-btn c-btn--primary c-btn--destructive w-100"
|
||||
|
|
|
|||
|
|
@ -3,27 +3,11 @@ describe('Moderation Tools for Posts', () => {
|
|||
cy.testSetup();
|
||||
});
|
||||
|
||||
it('should load moderation tools on a post for a trusted user', () => {
|
||||
cy.fixture('users/trustedUser.json').as('user');
|
||||
cy.get('@user').then((user) => {
|
||||
cy.loginAndVisit(user, '/').then(() => {
|
||||
cy.findAllByRole('link', { name: 'Test article' })
|
||||
.first()
|
||||
.click({ force: true });
|
||||
cy.findByRole('button', { name: 'Moderation' }).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not load moderation tools for a post when the logged on user is not a trusted user', () => {
|
||||
cy.fixture('users/articleEditorV1User.json').as('user');
|
||||
|
||||
cy.get('@user').then((user) => {
|
||||
cy.loginAndVisit(user, '/').then(() => {
|
||||
cy.findAllByRole('link', { name: 'Test article' })
|
||||
.first()
|
||||
.click({ force: true });
|
||||
|
||||
cy.loginAndVisit(user, '/admin_mcadmin/test-article-slug').then(() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).should('not.exist');
|
||||
});
|
||||
});
|
||||
|
|
@ -32,18 +16,14 @@ describe('Moderation Tools for Posts', () => {
|
|||
it('should not load moderation tools for a post when not logged in', () => {
|
||||
cy.fixture('users/articleEditorV1User.json').as('user');
|
||||
|
||||
cy.visit('/').then(() => {
|
||||
cy.findAllByRole('link', { name: 'Test article' })
|
||||
.first()
|
||||
.click({ force: true });
|
||||
|
||||
cy.visit('/admin_mcadmin/test-article-slug').then(() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).should('not.exist');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not alter tags from a post if a reason is not specified', () => {
|
||||
cy.fixture('users/adminUser.json').as('user');
|
||||
cy.get('@user').then((user) => {
|
||||
cy.fixture('users/adminUser.json').as('adminUser');
|
||||
cy.get('@adminUser').then((user) => {
|
||||
cy.loginAndVisit(user, '/admin_mcadmin/tag-test-article').then(() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).click();
|
||||
|
||||
|
|
@ -65,4 +45,64 @@ describe('Moderation Tools for Posts', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should show Feature Post button on an unfeatured post for an admin user', () => {
|
||||
cy.fixture('users/adminUser.json').as('adminUser');
|
||||
cy.get('@adminUser').then((user) => {
|
||||
cy.loginAndVisit(user, '/admin_mcadmin/unfeatured-article-slug').then(
|
||||
() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).click();
|
||||
|
||||
cy.getIframeBody('[title="Moderation panel actions"]').within(() => {
|
||||
cy.findByRole('button', { name: 'Feature Post' }).should('exist');
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should show Unfeature Post button on a featured post for an admin user', () => {
|
||||
cy.fixture('users/adminUser.json').as('adminUser');
|
||||
cy.get('@adminUser').then((user) => {
|
||||
cy.loginAndVisit(user, '/admin_mcadmin/test-article-slug').then(() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).click();
|
||||
|
||||
cy.getIframeBody('[title="Moderation panel actions"]').within(() => {
|
||||
cy.findByRole('button', { name: 'Unfeature Post' }).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('as trusted user', () => {
|
||||
beforeEach(() => {
|
||||
cy.fixture('users/trustedUser.json').as('trustedUser');
|
||||
});
|
||||
|
||||
it('should load moderation tools on a post for a trusted user', () => {
|
||||
cy.get('@trustedUser').then((user) => {
|
||||
cy.loginAndVisit(user, '/admin_mcadmin/test-article-slug').then(() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not show Feature Post button on a post for a trusted user', () => {
|
||||
cy.get('@trustedUser').then((user) => {
|
||||
cy.loginAndVisit(user, '/admin_mcadmin/unfeatured-article-slug').then(
|
||||
() => {
|
||||
cy.findByRole('button', { name: 'Moderation' }).click();
|
||||
|
||||
cy.getIframeBody('[title="Moderation panel actions"]').within(
|
||||
() => {
|
||||
cy.findByRole('button', { name: 'Feature Post' }).should(
|
||||
'not.exist',
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -556,6 +556,26 @@ end
|
|||
|
||||
##############################################################################
|
||||
|
||||
seeder.create_if_doesnt_exist(Article, "slug", "unfeatured-article-slug") do
|
||||
markdown = <<~MARKDOWN
|
||||
---
|
||||
title: Unfeatured article
|
||||
published: true
|
||||
---
|
||||
#{Faker::Hipster.paragraph(sentence_count: 2)}
|
||||
#{Faker::Markdown.random}
|
||||
#{Faker::Hipster.paragraph(sentence_count: 2)}
|
||||
MARKDOWN
|
||||
Article.create!(
|
||||
body_markdown: markdown,
|
||||
featured: false,
|
||||
user_id: admin_user.id,
|
||||
slug: "unfeatured-article-slug",
|
||||
)
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
||||
seeder.create_if_doesnt_exist(Article, "slug", "test-article-with-hidden-comments-slug") do
|
||||
markdown = <<~MARKDOWN
|
||||
---
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue