Skip to content

Commit

Permalink
update navigation and surfaces example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grossopa committed Dec 7, 2024
1 parent 7439dbc commit 80f3304
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected By getSeparatorLocator() {
}

protected By getTouchRippleLocator() {
return By2.className(config.getCssPrefix() + "TouchRipple-root");
return By2.attrExact("data-testid", "MoreHorizIcon");
}

protected By getItemContainersLocator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void getItems() {

@Test
void isCollapsed() {
when(element.findElements(By.className("MuiTouchRipple-root"))).thenReturn(singletonList(touchRipple));
when(element.findElements(By2.attrExact("data-testid", "MoreHorizIcon"))).thenReturn(singletonList(touchRipple));
assertTrue(testSubject.isCollapsed());
}

Expand All @@ -124,7 +124,7 @@ void isCollapsedNegative() {

@Test
void expand() {
when(element.findElements(By.className("MuiTouchRipple-root"))).thenReturn(singletonList(touchRipple));
when(element.findElements(By2.attrExact("data-testid", "MoreHorizIcon"))).thenReturn(singletonList(touchRipple));
testSubject.expand();
verify(touchRippleParent, only()).click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ public class MuiDatePickersTestCases extends AbstractBrowserSupport {
/**
* Tests the basic date picker.
*
* @see <a href="https://mui.com/components/date-picker/#basic-usage">
* https://mui.com/components/date-picker/#basic-usage</a>
* @see <a href="https://mui.com/x/react-date-pickers/date-picker/#basic-usage">
* https://mui.com/x/react-date-pickers/date-picker/#basic-usage</a>
*/
public void testBasicDatePicker() {
MuiDatePickerFormField datePickerFormField = driver.findComponent(By.id("BasicDatePicker.js"))
.findComponent(parent()).findComponent(By.className("MuiTextField-root")).as(muiV5())
.toDatePickerFormField();

MuiCalendarPicker calendarPicker = datePickerFormField.openCalendarPicker(500L);
MuiCalendarPicker calendarPicker = datePickerFormField.openCalendarPicker(1200L);
calendarPicker.setDate(LocalDate.of(2020, Month.JANUARY, 13), 500L);
assertEquals("01/13/2020", datePickerFormField.getInput().getAttribute("value"));
}

/**
* Tests the sub-component {@link MuiCalendarPicker}.
*
* @see <a href="https://mui.com/components/date-picker/#sub-components">
* https://mui.com/components/date-picker/#sub-components</a>
* @see <a href="https://mui.com/x/react-date-pickers/date-picker/#sub-components">
* https://mui.com/x/react-date-pickers/date-picker/#sub-components</a>
*/
public void testSubComponentsPickersCalendarPicker() {
MuiCalendarPicker calendarPicker = driver.findComponent(By.id("SubComponentsPickers.js"))
Expand Down Expand Up @@ -130,8 +130,8 @@ public void testSubComponentsPickersCalendarPicker() {
/**
* Tests the sub-component {@link MuiMonthPicker}.
*
* @see <a href="https://mui.com/components/date-picker/#sub-components">
* https://mui.com/components/date-picker/#sub-components</a>
* @see <a href="https://mui.com/x/react-date-pickers/date-picker/#sub-components">
* https://mui.com/x/react-date-pickers/date-picker/#sub-components</a>
*/
public void testSubComponentsPickersMonthPicker() {
MuiMonthPicker monthPicker = driver.findComponent(By.id("SubComponentsPickers.js")).findComponent(parent())
Expand All @@ -149,8 +149,8 @@ public void testSubComponentsPickersMonthPicker() {
/**
* Tests the selection views of year, month and date
*
* @see <a href="https://mui.com/components/date-picker/#views-playground">
* https://mui.com/components/date-picker/#views-playground</a>
* @see <a href="https://mui.com/x/react-date-pickers/date-picker/#views-playground">
* https://mui.com/x/react-date-pickers/date-picker/#views-playground</a>
*/
public void testViewsPlayground() {
WebComponent container = driver.findComponent(By.id("ViewsDatePicker.js")).findComponent(parent());
Expand Down Expand Up @@ -228,7 +228,7 @@ public void testViewsPlayground() {
public static void main(String[] args) {
MuiDatePickersTestCases test = new MuiDatePickersTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/date-picker/");
test.driver.navigate().to("https://mui.com/x/react-date-pickers/date-picker/");

test.testBasicDatePicker();
test.testSubComponentsPickersCalendarPicker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class MuiBottomNavigationTestCases extends AbstractBrowserSupport {
/**
* Tests the basic bottom navigation.
*
* @see <a href="https://mui.com/components/bottom-navigation/#bottom-navigation">
* https://mui.com/components/bottom-navigation/#bottom-navigation</a>
* @see <a href="https://mui.com/material-ui/react-bottom-navigation/#bottom-navigation">
* https://mui.com/material-ui/react-bottom-navigation/#bottom-navigation</a>
*/
public void testBottomNavigation() {
MuiBottomNavigation bottomNavigation = driver.findComponent(By.id("SimpleBottomNavigation.js"))
Expand All @@ -70,7 +70,7 @@ public void testBottomNavigation() {
public static void main(String[] args) {
MuiBottomNavigationTestCases test = new MuiBottomNavigationTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/bottom-navigation/");
test.driver.navigate().to("https://mui.com/material-ui/react-bottom-navigation/");

test.testBottomNavigation();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class MuiBreadcrumbsTestCases extends AbstractBrowserSupport {

/**
* Tests the basic features.
* <a href="https://mui.com/components/breadcrumbs/#basic-breadcrumbs">
* https://mui.com/components/breadcrumbs/#basic-breadcrumbs</a>
* <a href="https://mui.com/material-ui/react-breadcrumbs/#basic-breadcrumbs">
* https://mui.com/material-ui/react-breadcrumbs/#basic-breadcrumbs</a>
*/
public void testBasicBreadcrumbs() {
MuiBreadcrumbs breadcrumbs = driver.findComponent(By.id("BasicBreadcrumbs.js")).findComponent(By2.parent())
Expand All @@ -63,8 +63,8 @@ public void testBasicBreadcrumbs() {

/**
* Tests the collapsed feature.
* <a href="https://mui.com/components/breadcrumbs/#collapsed-breadcrumbs">
* https://mui.com/components/breadcrumbs/#collapsed-breadcrumbs</a>
* <a href="https://mui.com/material-ui/react-breadcrumbs/#collapsed-breadcrumbs">
* https://mui.com/material-ui/react-breadcrumbs/#collapsed-breadcrumbs</a>
*/
public void testCollapsedBreadcrumbs() {
MuiBreadcrumbs breadcrumbs = driver.findComponent(By.id("CollapsedBreadcrumbs.js")).findComponent(By2.parent())
Expand All @@ -89,7 +89,7 @@ public void testCollapsedBreadcrumbs() {
public static void main(String[] args) {
MuiBreadcrumbsTestCases test = new MuiBreadcrumbsTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/breadcrumbs/");
test.driver.navigate().to("https://mui.com/material-ui/react-breadcrumbs/");

test.testBasicBreadcrumbs();
test.testCollapsedBreadcrumbs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class MuiLinkTestCases extends AbstractBrowserSupport {
/**
* Tests the basics.
*
* @see <a href="https://mui.com/components/links/#basic-links">
* https://mui.com/components/links/#basic-links</a>
* @see <a href="https://mui.com/material-ui/react-link/#basic-links">
* https://mui.com/material-ui/react-link/#basic-links</a>
*/
public void testBasicLinks() {
List<MuiLink> links = driver.findComponent(By.id("Links.js")).findComponent(By2.parent())
Expand All @@ -67,7 +67,7 @@ public void testBasicLinks() {
public static void main(String[] args) {
MuiLinkTestCases test = new MuiLinkTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/links/");
test.driver.navigate().to("https://mui.com/material-ui/react-link/");

test.testBasicLinks();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class MuiMenuTestCases extends AbstractBrowserSupport {
/**
* Tests for the basic menu.
*
* @see <a href="https://mui.com/components/menus/#basic-menu">https://mui.com/components/menus/#basic-menu</a>
* @see <a href="https://mui.com/material-ui/react-menu/#basic-menu">https://mui.com/material-ui/react-menu/#basic-menu</a>
*/
public void testBasicMenu() {
MuiButton dashboardButton = driver.findComponent(By.id("BasicMenu.js")).findComponent(By2.parent())
Expand All @@ -75,7 +75,7 @@ public void testBasicMenu() {
public static void main(String[] args) {
MuiMenuTestCases test = new MuiMenuTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/menus/");
test.driver.navigate().to("https://mui.com/material-ui/react-menu/");

test.testBasicMenu();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class MuiPaginationTestCases extends AbstractBrowserSupport {

/**
* Tests the basic pagination.
* <a href="https://mui.com/components/pagination/#basic-pagination">
* https://mui.com/components/pagination/#basic-pagination</a>
* <a href="https://mui.com/material-ui/react-pagination/#basic-pagination">
* https://mui.com/material-ui/react-pagination/#basic-pagination</a>
*/
public void testBasicPagination() {
List<MuiPagination> paginationList = driver.findComponent(By.id("BasicPagination.js"))
Expand Down Expand Up @@ -93,8 +93,8 @@ public void testBasicPagination() {

/**
* Tests the buttons of the pagination.
* <a href="https://mui.com/components/pagination/#buttons">
* https://mui.com/components/pagination/#buttons</a>
* <a href="https://mui.com/material-ui/react-pagination/#buttons">
* https://mui.com/material-ui/react-pagination/#buttons</a>
*/
public void testButtons() {
List<MuiPagination> paginationList = driver.findComponent(By.id("PaginationButtons.js"))
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testButtons() {
public static void main(String[] args) {
MuiPaginationTestCases test = new MuiPaginationTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/pagination/");
test.driver.navigate().to("https://mui.com/material-ui/react-pagination/");

test.testBasicPagination();
test.testButtons();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MuiTabsTestCases extends AbstractBrowserSupport {
/**
* Tests the basics.
*
* @see <a href="https://mui.com/components/tabs/#basic-tabs">https://mui.com/components/tabs/#basic-tabs</a>
* @see <a href="https://mui.com/material-ui/react-tabs/#basic-tabs">https://mui.com/material-ui/react-tabs/#basic-tabs</a>
*/
public void testBasicTabs() {
MuiTabs tabs = driver.findComponent(By.id("BasicTabs.js")).findComponent(By2.parent())
Expand All @@ -66,8 +66,8 @@ public void testBasicTabs() {
/**
* Tests the wrapped labels.
*
* @see <a href="https://mui.com/components/tabs/#wrapped-labels">
* https://mui.com/components/tabs/#wrapped-labels</a>
* @see <a href="https://mui.com/material-ui/react-tabs/#wrapped-labels">
* https://mui.com/material-ui/react-tabs/#wrapped-labels</a>
*/
public void testWrappedLabels() {
MuiTabs tabs = driver.findComponent(By.id("TabsWrappedLabel.js")).findComponent(By2.parent())
Expand All @@ -86,7 +86,7 @@ public void testWrappedLabels() {
/**
* Tests the disabled tab.
*
* @see <a href="https://mui.com/components/tabs/#disabled-tab">https://mui.com/components/tabs/#disabled-tab</a>
* @see <a href="https://mui.com/material-ui/react-tabs/#disabled-tab">https://mui.com/material-ui/react-tabs/#disabled-tab</a>
*/
public void testDisabledTab() {
MuiTabs tabs = driver.findComponent(By.id("DisabledTabs.js")).findComponent(By2.parent())
Expand All @@ -100,8 +100,8 @@ public void testDisabledTab() {
/**
* Tests the scrollable tab.
*
* @see <a href="https://mui.com/components/tabs/#scrollable-tabs">
* https://mui.com/components/tabs/#scrollable-tabs</a>
* @see <a href="https://mui.com/material-ui/react-tabs/#scrollable-tabs">
* https://mui.com/material-ui/react-tabs/#scrollable-tabs</a>
*/
public void testScrollableTabs() {
MuiTabs tabs = driver.findComponent(By.id("ScrollableTabsButtonAuto.js")).findComponent(By2.parent())
Expand All @@ -118,14 +118,16 @@ public void testScrollableTabs() {
assertEquals("ITEM SEVEN", tabs.getTabs().get(6).getText());

assertDoesNotThrow(() -> tabs.getNextScrollButton().orElseThrow().click());
// Wait until animation completes
driver.threadSleep(1000L);
assertDoesNotThrow(() -> tabs.getPreviousScrollButton().orElseThrow().click());
}

/**
* Tests the vertical tab.
*
* @see <a href="https://mui.com/components/tabs/#vertical-tabs">
* https://mui.com/components/tabs/#vertical-tabs</a>
* @see <a href="https://mui.com/material-ui/react-tabs/#vertical-tabs">
* https://mui.com/material-ui/react-tabs/#vertical-tabs</a>
*/
public void testVerticalTabs() {
MuiTabs tabs = driver.findComponent(By.id("VerticalTabs.js")).findComponent(By2.parent())
Expand All @@ -139,7 +141,7 @@ public void testVerticalTabs() {
public static void main(String[] args) {
MuiTabsTestCases test = new MuiTabsTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/tabs/");
test.driver.navigate().to("https://mui.com/material-ui/react-tabs/");

test.testBasicTabs();
test.testWrappedLabels();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public class MuiAccordionTestCases extends AbstractBrowserSupport {
/**
* Tests the basic features
*
* @see <a href="https://mui.com/components/accordion/#basic-accordion">
* https://mui.com/components/accordion/#basic-accordion</a>
* @see <a href="https://mui.com/material-ui/react-accordion/#basic-accordion">
* https://mui.com/material-ui/react-accordion/#basic-accordion</a>
*/
public void testBasicAccordion() {
List<MuiAccordion> accordionList = driver.findComponent(By.id("BasicAccordion.js")).findComponent(By2.parent())
List<MuiAccordion> accordionList = driver.findComponent(By.id("DisabledAccordion.js")).findComponent(By2.parent())
.findComponentsAs(By.className("MuiAccordion-root"), c -> c.as(muiV5()).toAccordion());
assertEquals(3, accordionList.size());
accordionList.forEach(accordion -> {
Expand All @@ -69,6 +69,7 @@ public void testBasicAccordion() {

requireNonNull(accordionList.get(1).getAccordionSummary()).click();
assertTrue(accordionList.get(1).isExpand());
driver.threadSleep(1000L);
assertEquals("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
+ "Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.",
requireNonNull(accordionList.get(1).getAccordionDetails()).getText());
Expand All @@ -82,7 +83,7 @@ public void testBasicAccordion() {
public static void main(String[] args) {
MuiAccordionTestCases test = new MuiAccordionTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/accordion/");
test.driver.navigate().to("https://mui.com/material-ui/react-accordion/");

test.testBasicAccordion();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public class MuiAppBarTestCases extends AbstractBrowserSupport {
/**
* Tests the basic features
*
* @see <a href="https://mui.com/components/app-bar/#basic-app-bar">
* https://mui.com/components/app-bar/#basic-app-bar</a>
* @see <a href="https://mui.com/material-ui/react-app-bar/#basic-app-bar">
* https://mui.com/material-ui/react-app-bar/#basic-app-bar</a>
*/
public void testBasicAppBar() {
MuiAppBar appBar = driver.findComponent(By.id("ButtonAppBar.js")).findComponent(By2.parent())
Expand All @@ -59,7 +59,7 @@ public void testBasicAppBar() {
public static void main(String[] args) {
MuiAppBarTestCases test = new MuiAppBarTestCases();
test.setUpDriver(EDGE);
test.driver.navigate().to("https://mui.com/components/app-bar/");
test.driver.navigate().to("https://mui.com/material-ui/react-app-bar/");

test.testBasicAppBar();
}
Expand Down

0 comments on commit 80f3304

Please sign in to comment.