Commit b7f297ed authored by winniehell's avatar winniehell

Replace static fixture for abuse_reports_spec (!7644)

parent 01ffcceb
---
title: Replace static fixture for abuse_reports_spec
merge_request: 7644
author: winniehell
/* eslint-disable space-before-function-paren, no-new, padded-blocks */
/*= require lib/utils/text_utility */
/*= require abuse_reports */
/*= require jquery */
((global) => {
const FIXTURE = 'abuse_reports.html';
describe('Abuse Reports', () => {
const FIXTURE = 'abuse_reports/abuse_reports_list.html.raw';
const MAX_MESSAGE_LENGTH = 500;
function assertMaxLength($message) {
expect($message.text().length).toEqual(MAX_MESSAGE_LENGTH);
}
let messages;
const assertMaxLength = $message => expect($message.text().length).toEqual(MAX_MESSAGE_LENGTH);
const findMessage = searchText => messages.filter(
(index, element) => element.innerText.indexOf(searchText) > -1,
).first();
describe('Abuse Reports', function() {
fixture.preload(FIXTURE);
beforeEach(function() {
beforeEach(function () {
fixture.load(FIXTURE);
new global.AbuseReports();
this.abuseReports = new global.AbuseReports();
messages = $('.abuse-reports .message');
});
it('should truncate long messages', function() {
const $longMessage = $('#long');
it('should truncate long messages', () => {
const $longMessage = findMessage('LONG MESSAGE');
expect($longMessage.data('original-message')).toEqual(jasmine.anything());
assertMaxLength($longMessage);
});
it('should not truncate short messages', function() {
const $shortMessage = $('#short');
it('should not truncate short messages', () => {
const $shortMessage = findMessage('SHORT MESSAGE');
expect($shortMessage.data('original-message')).not.toEqual(jasmine.anything());
});
it('should allow clicking a truncated message to expand and collapse the full message', function() {
const $longMessage = $('#long');
it('should allow clicking a truncated message to expand and collapse the full message', () => {
const $longMessage = findMessage('LONG MESSAGE');
$longMessage.click();
expect($longMessage.data('original-message').length).toEqual($longMessage.text().length);
$longMessage.click();
assertMaxLength($longMessage);
});
});
})(window.gl);
.abuse-reports
.message#long
Cat ipsum dolor sit amet, hide head under blanket so no one can see.
Gate keepers of hell eat and than sleep on your face but hunt by meowing
loudly at 5am next to human slave food dispenser cats go for world
domination or chase laser, yet poop on grasses chirp at birds. Cat is love,
cat is life chase after silly colored fish toys around the house climb a
tree, wait for a fireman jump to fireman then scratch his face fall asleep
on the washing machine lies down always hungry so caticus cuteicus. Sit on
human. Spot something, big eyes, big eyes, crouch, shake butt, prepare to
pounce sleep in the bathroom sink hiss at vacuum cleaner hide head under
blanket so no one can see throwup on your pillow.
.message#short
Cat ipsum dolor sit amet, groom yourself 4 hours - checked, have your
beauty sleep 18 hours - checked, be fabulous for the rest of the day -
checked! for shake treat bag.
require 'spec_helper'
describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let!(:abuse_report) { create(:abuse_report) }
let!(:abuse_report_with_short_message) { create(:abuse_report, message: 'SHORT MESSAGE') }
let!(:abuse_report_with_long_message) { create(:abuse_report, message: "LONG MESSAGE\n" * 50) }
render_views
before(:all) do
clean_frontend_fixtures('abuse_reports/')
end
before(:each) do
sign_in(admin)
end
it 'abuse_reports/abuse_reports_list.html.raw' do |example|
get :index
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment