'use strict';

var User = require('../../lib/user');
//	helper = require('../../lib/css-selector-builder');

function VocabularyUser(opts) {
	opts = opts || {};
	User.call(this, opts);
}
VocabularyUser.prototype = new User();

VocabularyUser.prototype.goToVocabulary = function() {
	return this.goTo('/vocabulary')
		.then(function() {
			return browser.sleep(1 * 1000);
		});
};
VocabularyUser.prototype.countNumberOfTerms = function() {
	return this.browser.element.all(by.css('.w-term'))
		.filter(function(el) {
			return el.isDisplayed();
		})
		.count();
};
VocabularyUser.prototype.clickOnNextPage = function() {
	return this.browser.element(by.css('.w-go-to-next-page')).click();
};

VocabularyUser.prototype.archiveItemByIndex = function(index) {
	return this.browser.element.all(by.css('.w-archive-term')).get(index).click()
		.then(function() {
			return browser.sleep(2 * 1000);
		});
};
VocabularyUser.prototype.makeItemValidByIndex = function(index) {
	return this.browser.element.all(by.css('.w-make-term-valid')).get(index).click()
		.then(function() {
			return browser.sleep(2 * 1000);
		});
};

VocabularyUser.prototype.getBackgroundColorOfItemByIndex = function(index) {
	return this.browser.element.all(by.css('.w-term-tag')).get(index).getCssValue('background-color');
};


module.exports = VocabularyUser;