<commit_before>'use strict';
var openUrl = require('./helpers/utils').open,
    openBlog = require('./helpers/utils').openBlog;

describe('timeline deletions', function() {
    beforeEach(openUrl('/#/liveblog'));
    it('can delete items on the timeline', function() {
        openBlog(2);
        element.all(by.repeater('post in posts')).then(function(posts) {
            //this post should be single item post
            posts[0].getText().then(function(txt) {
                posts[0].element(by.css('.timeline-simple-item')).click();
                posts[0].element(by.css('[ng-click="askRemoveItem(item, post)"]')).click();
                confirmRemoval();
                compareTexts(txt, 0);
            });
        });
    });
    it('can delete posts on the timeline', function() {
        openBlog(2);
        element.all(by.repeater('post in posts')).then(function(posts) {
            //this post should be a multiple item one
            posts[1].getText().then(function(txt) {
                posts[1].element(by.css('.post-item__header')).click();
                posts[1].element(by.css('[dropdown-toggle]')).click();
                posts[1].element(by.css('[ng-click="askRemovePost(post)"]')).click();
                confirmRemoval();
                compareTexts(txt, 1);
            });
        });
    });
});
function compareTexts(oldText, position) {
    element.all(by.repeater('post in posts')).then(function(newPosts) {
        expect(oldText).not.toEqual(newPosts[position].getText());
    });
}

function confirmRemoval() {
    browser.wait(element(by.css('[ng-click="ok()"')).isDisplayed);
    element(by.css('[ng-click="ok()"')).click();
}<commit_msg>LBSD-416 new timeline deletion e2e tests<commit_after>'use strict';
var openUrl = require('./helpers/utils').open,
    openBlog = require('./helpers/utils').openBlog;

describe('timeline deletions', function() {
    beforeEach(function(done) {openUrl('/#/liveblog').then(done);});
    it('can delete posts on the timeline', function() {
        openBlog(0);
        element.all(by.repeater('post in posts')).then(function(posts) {
            posts[0].element(by.css('[ng-click="askRemovePost(post)"]')).click();
            confirmRemoval();
            compare(posts.length);
        });
    });
});
function compare(oldLength) {
    element.all(by.repeater('post in posts')).then(function(newPosts) {
        expect(oldLength).not.toEqual(newPosts.length);
    });
}
function confirmRemoval() {
    browser.wait(function() {
        return element(by.css('.modal-footer.ng-scope')).isDisplayed();
    });
    element(by.css('button[ng-click="ok()"')).sendKeys(protractor.Key.ENTER);
}
{'fraction_non_alphanumeric': 0.18878504672897195, 'fraction_numerical': 0.006355140186915888, 'mean_word_length': 2.9469026548672566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6796758', 'n_tokens_mistral': 817, 'n_tokens_neox': 798, 'n_words': 116}