var SentimentMemoryAnnotationsUser = 
    require('./sentiment-memory-annotations.user.js');

xdescribe('SentimentMemoryAnnotations', function () {
    var user = new SentimentMemoryAnnotationsUser();

    beforeEach(function () {
	return user.goToSentimentMemoryAnnotations();
    });

    describe('USE CASE: visualize the annotations', function () {
	it(
	    'when user access in the URL /sentiment-memory-annotation then ' +
	    '10 annotations are visualize',
	    function () {
		return user.countNumberOfAnnotations().then(function (number) {
		    expect(number).toBe(10);
		});
	    }
	);
    });

    describe('USE CASE: filter by', function () {
	describe('category', function () {
	    it(
		'when user select the category filter then only the ' +
		'annotation with that category are visualized',
		function () {
		    return user.openCategory().then(function () {
			return user.selectFirstCategory();
		    }).then(function () {
			return user.readCategorySelected();
		    }).then(function (category) {
			return user.seeCategoriesAnnotation().then(
			    function (categories) {
				categories.forEach(function (c) {
				    expect(c).toBe(category);
				});
			    }
			);
		    });
		}
	    )
	});

	describe('status', function () {
	    it(
		'when user select the status filter then only the ' +
		'annotation with that status are visualized',
		function () {
		    return user.selectStatus('new')
		    .then(function () {
			return user.seeStatusAnnotations();
		    }).then(function (status) {
			status.forEach(function (cl) {
			    expect(cl).toBe('w-new');
			});
		    });
		}
	    )
	});
    });

    describe('USE CASE: get other annotation', function () {
	it(
	    'when user clicks on More terms the other annotations appear',
	    function () {
		return user.clickOnNextPage().then(function () {
		    return user.countNumberOfAnnotations();
		}).then(function (count) {
		    expect(count).toBeGreaterThan(10);
		});
	    }
	);
    });

    describe(
	'USE CASE: visualize reviews associated to an annotation', 
	function () {
	    it(
		'when user clicks on number of reviews jump on other page',
		function () {
		    return user.clickOnNumberReviews().then(function () {
			return user.whereIAm();
		    }).then(function (url) {
			console.log(url);
			var page = url.match(/http:\/\/.*\//g)[0];
			expect(page).toMatch(
			    'http:\/\/.*\/#\/annotation-reviews/'
			);
		    });
		}
	    );
	}
    );
});

