package com.intland.codebeamer.functionaltest.page.admin;

import com.intland.codebeamer.functionaltest.page.BasePage;
import org.openqa.selenium.By;

import java.util.List;

import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$$;
import static com.codeborne.selenide.Selenide.page;

/**
 * Copyright by Intland Software
 * <p>
 * All rights reserved.
 * <p>
 * This software is the confidential and proprietary information
 * of Intland Software. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Intland.
 */
public class MembersPage extends BasePage{

    public AddNewMemberDialog clickOnAddNewMember() {
        $(By.linkText("Add new Member")).click();
        return page(AddNewMemberDialog.class);
    }

    public AddNewGroupDialog clickOnAddNewGroup() {
        $(By.xpath(".//a[text()='Add new Group']")).click();
        return page(AddNewGroupDialog.class);
    }

    public List<String> getAllMemberUsernames() {
        return $$(By.xpath(".//ul[@class='memberList']//td[@class='username']/a")).texts();
    }

    public boolean isUserAlreadyMember(String username){
        return getAllMemberUsernames().contains(username);
    }
}
