Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'integration/master' into project-page
Browse files Browse the repository at this point in the history
Conflicts:
	zanata-war/src/main/webapp/WEB-INF/layout/version-group/languages-tab.xhtml
	zanata-war/src/main/webapp/WEB-INF/layout/version-group/projects-tab.xhtml
	zanata-war/src/main/webapp/WEB-INF/layout/version-group/settings-tab.xhtml
	zanata-war/src/main/webapp/resources/script/components-script.js
	zanata-war/src/main/webapp/version-group/version_group.xhtml
  • Loading branch information
Alex Eng committed Mar 21, 2014
2 parents 19e9a95 + c1c04a2 commit efbf11c
Show file tree
Hide file tree
Showing 15 changed files with 557 additions and 265 deletions.
Expand Up @@ -3,9 +3,8 @@
import java.util.ArrayList;
import java.util.List;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import lombok.extern.slf4j.Slf4j;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
Expand All @@ -19,6 +18,9 @@
import org.zanata.util.WebElementUtil;

import com.google.common.base.Function;
import com.google.common.base.Predicate;

import javax.annotation.Nullable;

/**
* @author Patrick Huang <a
Expand Down Expand Up @@ -130,39 +132,82 @@ public void clickOnTab(String tabId) {
tab.click();
}

public VersionGroupPage clickProjectsTab() {
getDriver().findElement(By.id("projects_tab")).click();
return new VersionGroupPage(getDriver());
}

public VersionGroupPage clickAddProjectVersionsButton() {
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver driver) {
WebElement addProjectVersionButton =
driver.findElement(By
.xpath("//*[@href='#settings-projects']"));
.id("settings-projects_tab"));
addProjectVersionButton.click();
return true;
}
});
return new VersionGroupPage(getDriver());
}

public VersionGroupPage clickLanguagesTab() {
getDriver().findElement(By.id("languages")).click();
return new VersionGroupPage(getDriver());
}

public VersionGroupPage clickProjectsTab() {
getDriver().findElement(By.id("projects")).click();
return new VersionGroupPage(getDriver());
}

public VersionGroupPage clickMaintainersTab() {
getDriver().findElement(By.id("maintainers")).click();
return new VersionGroupPage(getDriver());
}

public VersionGroupPage clickSettingsTab() {
getDriver().findElement(By.id("settings")).click();
return new VersionGroupPage(getDriver());
}

public VersionGroupPage clickLanguagesSettingsTab() {
clickSettingsTab();
getDriver().findElement(By.id("settings-languages_tab")).click();
return new VersionGroupPage(getDriver());
}

public Boolean isLanguagesTabActive() {
final WebElement languagesTab = getDriver().findElement(By.id("languages"));
waitForTenSec().until( new Predicate<WebDriver>() {
@Override
public boolean apply(@Nullable WebDriver webDriver) {
return languagesTab.getAttribute("class").contains("is-active");
}
} );
return languagesTab.getAttribute("class").contains("is-active");
}

public Boolean isProjectsTabActive() {
final WebElement languagesTab = getDriver().findElement(By.id("projects"));
waitForTenSec().until( new Predicate<WebDriver>() {
@Override
public boolean apply(@Nullable WebDriver webDriver) {
return languagesTab.getAttribute("class").contains("is-active");
}
} );
return languagesTab.getAttribute("class").contains("is-active");
}

/**
* Enter a project version identifier
* @param projectVersion identifier in format "$projectID $version"
* @return new VersionGroupPage
*/
public VersionGroupPage enterProjectVersion(String projectVersion) {
getDriver().findElement(By.id("settings-projects-form:new--versionInput"))
getDriver().findElement(By.id("versionAutocomplete-autocomplete__input"))
.sendKeys(projectVersion);
return new VersionGroupPage(getDriver());
}


public VersionGroupPage confirmAddProject() {
new Actions(getDriver()).sendKeys(Keys.ENTER);
return new VersionGroupPage(getDriver());
}

}
Expand Up @@ -9,6 +9,8 @@
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({ VersionGroupTest.class, VersionGroupFullTest.class,
VersionGroupBasicTest.class, VersionGroupIDValidationTest.class })
VersionGroupBasicTest.class, VersionGroupIDValidationTest.class,
VersionGroupUrlTest.class
})
public class VersionGroupTestSuite {
}
@@ -0,0 +1,131 @@
/*
* Copyright 2014, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.feature.versionGroup;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.zanata.feature.DetailedTest;
import org.zanata.page.groups.VersionGroupPage;
import org.zanata.page.utility.DashboardPage;
import org.zanata.util.SampleProjectRule;
import org.zanata.util.ZanataRestCaller;
import org.zanata.workflow.LoginWorkFlow;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.is;

/**
* Tests relating to custom urls handled in the page.
*
* The urls mapped for a version group are of the form:
* <zanata>/version-group/view/<slug>/languages/<locale_code>
* <zanata>/version-group/view/<slug>/projects/<project_slug>[<version_slug>]
* <zanata>/version-group/view/<slug>/maintainers
* <zanata>/version-group/view/<slug>/settings
* <zanata>/version-group/view/<slug>/settings/languages etc...
*
* @author Carlos Munoz <a
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Category(DetailedTest.class)
public class VersionGroupUrlTest {

@Rule
public SampleProjectRule sampleProjectRule = new SampleProjectRule();

private DashboardPage dashboardPage;

private ZanataRestCaller restCaller;

@Before
public void setUp() {
dashboardPage = new LoginWorkFlow().signIn("admin", "admin");
}

@Test
public void testUrlChangeUpdatesActiveElements() {
VersionGroupPage versionGroupPage = createVersionGroup();
testBasicGroupUrl(versionGroupPage);
}

private void testBasicGroupUrl(VersionGroupPage versionGroupPage) {
assertThat(versionGroupPage.isLanguagesTabActive(), is(true));
}

@Test
public void testTabClicksChangeUrl() {
VersionGroupPage versionGroupPage = createVersionGroup();

testLanguageTabClick(versionGroupPage);
testProjectTabClick(versionGroupPage);
testMaintainersTabClick(versionGroupPage);
testSettingsTabClick(versionGroupPage);
}

private void testLanguageTabClick(VersionGroupPage versionGroupPage) {
versionGroupPage.clickLanguagesTab();
assertThat(versionGroupPage.getUrl(),
endsWith("/version-group/view/test-group/languages"));
}

private void testProjectTabClick(VersionGroupPage versionGroupPage) {
versionGroupPage.clickProjectsTab();
assertThat(versionGroupPage.getUrl(),
endsWith("/version-group/view/test-group/projects"));
}

private void testMaintainersTabClick(VersionGroupPage versionGroupPage) {
versionGroupPage.clickMaintainersTab();
assertThat(versionGroupPage.getUrl(),
endsWith("/version-group/view/test-group/maintainers"));
}

private void testSettingsTabClick(VersionGroupPage versionGroupPage) {
versionGroupPage.clickSettingsTab();
assertThat(versionGroupPage.getUrl(),
endsWith("/version-group/view/test-group/settings"));
}

private VersionGroupPage createVersionGroup() {
String groupID = "test-group";
String groupName = "A Test group";
return dashboardPage
.goToGroups()
.createNewGroup()
.inputGroupId(groupID)
.inputGroupName(groupName)
.saveGroup()
.goToGroup(groupName);
}

private void createProject() {
restCaller = new ZanataRestCaller();
// create another project and version
String projectSlug = "base";
String iterationSlug = "master";
String projectType = "gettext";
restCaller.createProjectAndVersion(projectSlug, iterationSlug,
projectType);
}
}
Expand Up @@ -37,6 +37,8 @@
import org.jboss.seam.security.management.JpaIdentityStore;
import org.zanata.annotation.CachedMethodResult;
import org.zanata.common.LocaleId;
import org.zanata.dao.LocaleDAO;
import org.zanata.dao.ProjectIterationDAO;
import org.zanata.dao.VersionGroupDAO;
import org.zanata.model.HAccount;
import org.zanata.model.HLocale;
Expand Down Expand Up @@ -77,6 +79,12 @@ public class VersionGroupHomeAction extends AbstractSortAction implements
@In
private VersionGroupDAO versionGroupDAO;

@In
private ProjectIterationDAO projectIterationDAO;

@In
private LocaleDAO localeDAO;

@Getter
@Setter
private String slug;
Expand Down Expand Up @@ -540,4 +548,13 @@ public void resetPageData() {
protected String getMessage(String key, Object... args) {
return zanataMessages.getMessage(key, args);
}

public void setSelectedLocaleId(String localeId) {
this.selectedLocale = localeDAO.findByLocaleId(new LocaleId(localeId));
}

public void setSelectedVersionSlug(String projectSlug, String versionSlug) {
selectedVersion =
projectIterationDAO.getBySlug(projectSlug, versionSlug);
}
}
Expand Up @@ -27,8 +27,8 @@
aria-labelledby="dropdownContent">
<li>
<a
href="#settings-languages"
onclick="updateHashAndGotoUrl(this)">
href="javascript:void(0)"
onclick="updateUrl('/version-group/view/#{versionGroupHomeAction.slug}', '/settings/languages');">
#{messages['jsf.ManageLanguage']} <i
class="i i--settings i__item__icon"></i>
</a>
Expand Down Expand Up @@ -57,8 +57,8 @@
<s:fragment
rendered="#{s:hasPermission(versionGroupHome.instance, 'update')}">
<p>
<a href="#settings-languages" class="button--primary"
onclick="updateHashAndGotoUrl(this)">
<a href="javascript:void(0)" class="button--primary"
onclick="updateUrl('/version-group/view/#{versionGroupHomeAction.slug}', '/settings/languages');">
#{messages['jsf.AddLanguages']}
</a>
</p>
Expand All @@ -78,36 +78,35 @@
var="hLocale">
<li
class="progress-bar__expander">
<a4j:commandLink limitRender="true"
<a4j:commandLink
action="#{versionGroupHomeAction.setSelectedLocale(hLocale)}"
status="languageTab-projectsLoader"
render="languages-project_list, language-label, languageTabVersionFilter-pager, languageTabVersionFilter-page-info, languageTabVersionFilterBottom-pager, languageTabVersionFilterBottom-page-info"
onclick="updateActiveRow(this);toggleColumn('languages_content')"
styleClass="bx--block">
render="languages-project_list, language-label, #{rich:clientId('projectFilter-size')}"
onclick="updateUrl('/version-group/view/#{versionGroupHomeAction.slug}', '/languages/#{hLocale.localeId}')"
styleClass="bx--block #{hLocale.localeId}">
<div class="list__item">
<div class="list__item__info">
<span class="list__title">
#{hLocale.retrieveDisplayName()}
<s:span
rendered="#{!versionGroupHomeAction.getMissingVersion(hLocale.localeId).isEmpty()}"
styleClass="badge--danger"
title="#{versionGroupHomeAction.getMissingVersionTitle(hLocale.localeId)}">
#{versionGroupHomeAction.getMissingVersion(hLocale.localeId).size()}
</s:span>
</span>
<span class="list__title">
#{hLocale.retrieveDisplayName()}
<s:span
rendered="#{!versionGroupHomeAction.getMissingVersion(hLocale.localeId).isEmpty()}"
styleClass="badge--danger"
title="#{versionGroupHomeAction.getMissingVersionTitle(hLocale.localeId)}">
#{versionGroupHomeAction.getMissingVersion(hLocale.localeId).size()}
</s:span>
</span>
</div>
<s:div styleClass="list__item__stats"
rendered="#{versionGroupHomeAction.pageRendered}">
<ui:param name="displayUnit"
value="#{versionGroupHomeAction.getStatisticFigureForLocale(versionGroupHomeAction.languageSortingList.selectedSortOption, hLocale.localeId)}"/>
<span class="stats--small #{displayUnit.cssClass}">
<span class="stats__figure">
#{displayUnit.figure}
</span>
<span class="stats__unit">
#{displayUnit.unit}
</span>
</span>
<span class="stats--small #{displayUnit.cssClass}">
<span class="stats__figure">
#{displayUnit.figure}
</span>
<span class="stats__unit">
#{displayUnit.unit}
</span>
</span>
</s:div>
</div>

Expand Down Expand Up @@ -252,7 +251,6 @@
</ui:repeat>
</ul>
</s:fragment>

</s:fragment>
</h:form>

Expand Down

0 comments on commit efbf11c

Please sign in to comment.