package it.com.atlassian.stash.lfs;

import com.atlassian.bitbucket.test.GitLfsTestHelper;
import com.atlassian.webdriver.bitbucket.page.admin.GitLfsAdminFormFragment;
import com.atlassian.webdriver.bitbucket.page.admin.ServerSettingsPage;
import it.com.atlassian.stash.BaseBrowserFuncTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class GitLfsServerSettingsPageTest extends BaseBrowserFuncTest {

    @Before
    public void setUp() {
        GitLfsTestHelper.enable();
    }

    @After
    public void tearDown() {
        GitLfsTestHelper.restoreDefaults();
    }

    @Test
    public void testCheckbox() {
        GitLfsAdminFormFragment page = loginAsAdmin(ServerSettingsPage.class).getGitLfsFormFragment();

        assertTrue(page.isEnabled());
        page.toggleEnabled()
                .end()
                .clickSave();
        assertFalse(page.isEnabled());
        assertFalse(GitLfsTestHelper.isEnabled());

        page.toggleEnabled()
                .end()
                .clickSave();
        assertTrue(GitLfsTestHelper.isEnabled());
    }
}
