package com.intland.codebeamer.functionaltest.page;

import com.codeborne.selenide.Condition;
import org.openqa.selenium.By;

import static com.codeborne.selenide.Selectors.byAttribute;
import static com.codeborne.selenide.Selectors.byTitle;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.page;

public class RepositoryPage extends BasePage {

    public String getRepositoryId() {
        return $(By.id("breadcrumbs-item-id")).getText().substring(1);
    }

    public void waitForFinish() {
        $(By.id("changesets-tab")).waitUntil(Condition.visible, 30000);
    }

    public void clickOnPermissions() {
        $(By.id("permissions-tab")).click();
    }

    public void clickOnProjectAdminClonePermission() {
        $(byTitle("Project Admin: SCM Repository - Checkout / Clone")).$(byAttribute("type", "checkbox")).setSelected(true);
    }

    public void clickOnProjectAdminForkPermission() {
        $(byTitle("Project Admin: SCM Repository - Fork")).$(byAttribute("type", "checkbox")).setSelected(true);
    }
}
