Skip to content

Commit

Permalink
Merge branch 'revert/legacy-hierarchy-selenium-test' into 'develop'
Browse files Browse the repository at this point in the history
See merge request edalex-group/development/oeq/openequella!413

It contains 3 changes:

revert: legacy hierarchy selenium test

fix: add missing test package in test build yaml

fix: select the exact user in the user selector dialog
  • Loading branch information
edalex-yinzi committed Jun 20, 2024
2 parents 0456510 + f523ab6 commit 4b47be4
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import com.tle.webtests.framework.PageContext;
import com.tle.webtests.pageobject.LoginPage;
import com.tle.webtests.pageobject.SettingsPage;
import com.tle.webtests.pageobject.searching.ItemAdminPage;
import com.tle.webtests.pageobject.searching.ItemListPage;
import java.lang.reflect.Method;
import org.testng.annotations.BeforeMethod;

// TODO: Remove isNewUIEnv and setNewUI in OEQ-1702
public class AbstractCleanupTest extends AbstractSessionTest {
protected String namePrefix;
private String usernameForDelete;
private String passwordForDelete;

// TODO: Remove me in OEQ-1702
protected boolean isNewUIEnv = Boolean.parseBoolean(System.getenv("OLD_TEST_NEWUI"));

public AbstractCleanupTest() {
namePrefix = getClass().getSimpleName();
}
Expand Down Expand Up @@ -76,12 +71,6 @@ protected boolean isCleanupItems() {
return true;
}

// TODO: Remove me in OEQ-1702
protected void setNewUI(boolean enable) {
SettingsPage settingsPage = new SettingsPage(context).load();
settingsPage.setNewUI(enable);
}

@BeforeMethod
public void setupSubcontext(Method method) {
context.setSubPrefix(method.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,11 @@
import com.tle.webtests.pageobject.ApidocsJsonPage;
import com.tle.webtests.pageobject.ApidocsPage;
import com.tle.webtests.pageobject.ErrorPage;
import com.tle.webtests.pageobject.SettingsPage;
import com.tle.webtests.test.AbstractSessionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

@TestInstitution("fiveo")
public class ApidocsTest extends AbstractSessionTest {

// TODO: Remove this method in OEQ-1702.
// This test become flaky on Gitlab and from the screenshot, it seems that the new UI is not
// restored.
@BeforeClass
public void enableNewUI() {
// make sure new UI is enabled.
if (testConfig.isNewUI()) {
logon("AutoTest", "automated");
SettingsPage settingsPage = new SettingsPage(context).load();
settingsPage.setNewUI(true);
}
}

@Test
public void testLoginNoAccess() {
logout(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.test.AbstractCleanupTest;
import org.testng.annotations.Test;
import testng.annotation.OldUIOnly;

// todo: lots of switching between UI modes were added to get the test passed.
// We will remove these once we work on OEQ-1701 and OEQ-1702
/** Legacy tests for dynamic hierarchy. */
@TestInstitution("hierarchy")
public class DynamicHierarchyTest extends AbstractCleanupTest {
final String TOPIC_1 = "dynamic_topic 1";
Expand All @@ -29,6 +29,7 @@ public class DynamicHierarchyTest extends AbstractCleanupTest {
final String TESTING_ITEM = "Testing item 3";

@Test
@OldUIOnly
public void checkGeneratedHierarchyMenu() {
logon("AutoTest", "automated");
HomePage homePage = new HomePage(context).load();
Expand All @@ -38,6 +39,7 @@ public void checkGeneratedHierarchyMenu() {
}

@Test
@OldUIOnly
public void modifyKeyResourceLinkOnItemSummary() {
logon("AutoTest", "automated");

Expand All @@ -52,10 +54,6 @@ public void modifyKeyResourceLinkOnItemSummary() {
// add key resource to first dynamic hierarchy
keyResourcePage.addToHierarchy(TOPIC_1);

if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(false);
}
TopicPage browseAll = new TopicPage(context).load();
TopicPage topicPage = browseAll.clickSubTopic(TOPIC_1);
TopicListPage results = topicPage.results();
Expand All @@ -64,12 +62,9 @@ public void modifyKeyResourceLinkOnItemSummary() {
assertTrue(
results.doesKeyResourceExist(TESTING_ITEM, 1),
TESTING_ITEM + " doesn't exist in " + TOPIC_1);
if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(true);
}
}

@OldUIOnly
@Test(dependsOnMethods = "modifyKeyResourceLinkOnItemSummary")
public void addToHierarchyLinkOnSearchPage() {
logon("AutoTest", "automated");
Expand All @@ -84,10 +79,6 @@ public void addToHierarchyLinkOnSearchPage() {
keyResourcePage.removeKeyResourceFromHierarchy(TOPIC_1);
keyResourcePage.addToHierarchy(TOPIC_2);

if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(false);
}
TopicPage browseAll1 = new TopicPage(context).load();
TopicPage topicPage1 = browseAll1.clickSubTopic(TOPIC_1);
TopicListPage itemList1 = topicPage1.results();
Expand All @@ -99,21 +90,14 @@ public void addToHierarchyLinkOnSearchPage() {
TopicPage topicPage2 = browseAll2.clickSubTopic(TOPIC_2);
TopicListPage itemList2 = topicPage2.results();
assertTrue(itemList2.doesKeyResourceExist(TESTING_ITEM, 1));
if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(true);
}
}

@OldUIOnly
@Test(dependsOnMethods = "addToHierarchyLinkOnSearchPage")
public void topicPageLinksAndCountNumberCheck() {
logon("AutoTest", "automated");
String itemName = "Testing item 1";

if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(false);
}
TopicPage browseAll = new TopicPage(context).load();
TopicPage topicPage = browseAll.clickSubTopic(TOPIC_1);
TopicListPage results = topicPage.results();
Expand All @@ -134,14 +118,10 @@ public void topicPageLinksAndCountNumberCheck() {
TopicPage browseAgain = topicPage.clickBrowseBreadcrumb();
int countAgain = browseAgain.topicCount(TOPIC_1);
assertEquals(Integer.toString(resultRecord), Integer.toString(countAgain));
if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(true);
}
}

@Test
// key resource references to an item should be removed when item is deleted
@OldUIOnly
@Test(description = "key resource references to an item should be removed when item is deleted")
public void testKeyResourceReferenceRemove() {
logon("AutoTest", "automated");

Expand All @@ -159,17 +139,9 @@ public void testKeyResourceReferenceRemove() {
item.delete();
item.purge();

if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(false);
}
TopicPage browseAll = new TopicPage(context).load();
TopicPage topicPage = browseAll.clickSubTopic(TOPIC_1);
TopicListPage results = topicPage.results();
assertFalse(results.doesKeyResourceExist(itemName, 1));
if (getTestConfig().isNewUI()) {
logon("TLE_ADMINISTRATOR", testConfig.getAdminPassword());
setNewUI(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,14 @@
import com.tle.webtests.pageobject.wizard.controls.universal.ResourceUniversalControlType;
import com.tle.webtests.test.AbstractCleanupTest;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import testng.annotation.OldUIOnly;

// TODO: remove disableNewUI and restoreNewUISettings in OEQ-1702
/** Legacy tests for hierarchy topic. Old UI only. */
@TestInstitution("fiveo")
public class HierarchyTopicTest extends AbstractCleanupTest {
// TODO: Create hierarchy tests for NEW UI. And remove this method in OEQ-1702.
// Because hierarchy page is is not completed in new UI, turn off New UI for the old integration
// test cases.
@BeforeClass
public void disableNewUI() {
// disable new UI if test env is set to new UI.
if (isNewUIEnv) {
logon("AutoTest", "automated");
setNewUI(false);
}
}

// TODO: Remove this method in OEQ-1702.
// Restore the new UI settings to avoid interfering with other tests.
@AfterClass
public void restoreNewUISettings() {
// Restore new UI if test env is set to new UI.
if (isNewUIEnv) {
logon("AutoTest", "automated");
setNewUI(true);
}
}

@Test(enabled = false, dependsOnMethods = "childInheritance")
@OldUIOnly
public void addKeyResource() {
logon("AutoTest", "automated");
String topic = "A Topic";
Expand All @@ -68,16 +45,10 @@ public void addKeyResource() {
}

@Test(dependsOnMethods = "childInheritance")
@OldUIOnly
public void lotsOfKeyResources() {
logon("AutoTest", "automated");

// TODO: remove me in OEQ-1702
// disable new UI if test env is set to new UI. This test is flaky so make sure it is run in old
// UI.
if (isNewUIEnv) {
setNewUI(false);
}

String topic = "A Topic";
String itemName = context.getFullName("Lots of Key Resources");

Expand Down Expand Up @@ -105,14 +76,15 @@ public void lotsOfKeyResources() {
}

@Test
@OldUIOnly
public void childInheritance() {
logon("AutoTest", "automated");
String topic = "A Topic";

String itemOne = "SearchFilters - Basic Item";
String itemTwo = "SearchSettings - Random Item";

TopicPage topicPage = new MenuSection(context, false).get().clickTopic(topic);
TopicPage topicPage = new MenuSection(context).get().clickTopic(topic);

topicPage.setSort("name");
TopicListPage results = topicPage.results();
Expand All @@ -129,31 +101,33 @@ public void childInheritance() {
}

@Test
@OldUIOnly
public void powerSearch() {
logon("AutoTest", "automated");
String topic = "Power Search";
String powerSearch = "A Power Search";

TopicPage topicPage = new MenuSection(context, false).get().clickTopic(topic);
TopicPage topicPage = new MenuSection(context).get().clickTopic(topic);
Assert.assertTrue(topicPage.hasPowerSearch());

SearchPage search = topicPage.clickPowerSearch();
Assert.assertEquals(search.getSelectedWithin(), powerSearch);
}

@Test
@OldUIOnly
public void saveAsFavourite() {
logon("AutoTest", "automated");
String topic = "A Topic";

MenuSection menuSection = new MenuSection(context, false).get();
MenuSection menuSection = new MenuSection(context).get();
TopicPage topicPage = menuSection.clickTopic(topic);

String searchName = context.getFullName(topic) + " saved";
topicPage.saveSearch(searchName, topicPage);

FavouritesPage favouritesPage =
menuSection.clickMenuForceOldUI("Favourites", new FavouritesPage(context));
menuSection.clickMenu("Favourites", new FavouritesPage(context));
FavouriteSearchList searches = favouritesPage.searches().results();
searches.doesResultExist(searchName, 1);
searches.getResultForTitle(searchName, 1).clickTitle();
Expand All @@ -164,6 +138,7 @@ public void saveAsFavourite() {
}

@Test
@OldUIOnly
public void noResults() {
logon("AutoTest", "automated");
String topic = "No Results";
Expand All @@ -176,6 +151,7 @@ public void noResults() {
}

@Test
@OldUIOnly
public void sectionNames() {
logon("AutoTest", "automated");
String topic = "Some Children Hidden";
Expand All @@ -186,6 +162,7 @@ public void sectionNames() {
}

@Test
@OldUIOnly
public void hiddenResults() {
logon("AutoTest", "automated");
String topic = "Results not shown";
Expand All @@ -197,6 +174,7 @@ public void hiddenResults() {
}

@Test
@OldUIOnly
public void hideNoResultChildren() {
logon("AutoTest", "automated");
String topic = "Some Children Hidden";
Expand Down Expand Up @@ -224,6 +202,7 @@ public void hideNoResultChildren() {
}

@Test
@OldUIOnly
public void accessTest() {
logon("NoSearchCreateUser", "``````");
TopicPage topicPage = new TopicPage(context).load();
Expand All @@ -236,6 +215,7 @@ public void accessTest() {
}

@Test
@OldUIOnly
public void browseHierarchyBreadcrumbTest() {
logon("AutoTest", "automated");

Expand Down
Loading

0 comments on commit 4b47be4

Please sign in to comment.