Apply final review tweaks for components and page roots
This commit is contained in:
@@ -2,9 +2,12 @@ package ru.otus.mobile.component;
|
||||
|
||||
import com.codeborne.selenide.ElementsCollection;
|
||||
import com.codeborne.selenide.SelenideElement;
|
||||
import com.codeborne.selenide.WebElementCondition;
|
||||
import io.appium.java_client.AppiumBy;
|
||||
import ru.otus.mobile.page.AbsPageObject;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public abstract class BaseMobileComponent extends AbsPageObject {
|
||||
protected final SelenideElement root;
|
||||
|
||||
@@ -19,4 +22,14 @@ public abstract class BaseMobileComponent extends AbsPageObject {
|
||||
protected ElementsCollection allByIdInRoot(String id) {
|
||||
return root.$$(AppiumBy.id(fullIdValue(id)));
|
||||
}
|
||||
|
||||
public BaseMobileComponent shouldBe(WebElementCondition... conditions) {
|
||||
root.shouldBe(conditions);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseMobileComponent shouldBe(WebElementCondition condition, Duration timeout) {
|
||||
root.shouldBe(condition, timeout);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.otus.mobile.component;
|
||||
|
||||
import com.codeborne.selenide.Condition;
|
||||
import com.codeborne.selenide.SelenideElement;
|
||||
|
||||
import static com.codeborne.selenide.Condition.text;
|
||||
@@ -7,6 +8,7 @@ import static com.codeborne.selenide.Condition.text;
|
||||
public final class GiftItemComponent extends BaseMobileComponent {
|
||||
private final SelenideElement title = byIdInRoot("title");
|
||||
private final SelenideElement editButton = byIdInRoot("edit_button");
|
||||
private final SelenideElement reservedToggle = byIdInRoot("reserved");
|
||||
|
||||
public GiftItemComponent(SelenideElement root) {
|
||||
super(root);
|
||||
@@ -27,4 +29,12 @@ public final class GiftItemComponent extends BaseMobileComponent {
|
||||
public void edit() {
|
||||
editButton.click();
|
||||
}
|
||||
|
||||
public boolean isReserved() {
|
||||
return Boolean.parseBoolean(reservedToggle.shouldBe(Condition.visible).getAttribute("checked"));
|
||||
}
|
||||
|
||||
public void toggleReservation() {
|
||||
reservedToggle.shouldBe(Condition.visible).click();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ru.otus.mobile.page;
|
||||
|
||||
import ru.otus.mobile.component.BottomNavigationComponent;
|
||||
import ru.otus.mobile.component.TopBarComponent;
|
||||
|
||||
public abstract class AbsBasePage extends AbsPageObject {
|
||||
protected final BottomNavigationComponent bottomNavigation =
|
||||
new BottomNavigationComponent(byId("bottom_navigation"));
|
||||
protected final TopBarComponent topBar = new TopBarComponent(byId("top_app_bar"));
|
||||
}
|
||||
|
||||
@@ -8,27 +8,25 @@ import ru.otus.mobile.component.GiftsContentComponent;
|
||||
|
||||
@Singleton
|
||||
public final class GiftsPage extends AbsBasePage {
|
||||
private final SelenideElement giftsContentRoot = byId("gifts_content");
|
||||
private final SelenideElement addButton = byId("add_button");
|
||||
private final SelenideElement formRoot = byId("gift_edit_bottom_sheet");
|
||||
private final GiftsContentComponent content = new GiftsContentComponent(giftsContentRoot);
|
||||
private final GiftFormComponent form = new GiftFormComponent(formRoot);
|
||||
private final GiftsContentComponent content = new GiftsContentComponent(byId("gifts_content"));
|
||||
private final GiftFormComponent form = new GiftFormComponent(byId("gift_edit_bottom_sheet"));
|
||||
|
||||
public void createGift(String name) {
|
||||
addButton.click();
|
||||
form.save(name, "100");
|
||||
giftsContentRoot.shouldBe(Condition.visible);
|
||||
content.shouldBe(Condition.visible);
|
||||
}
|
||||
|
||||
public void editGift(String oldName, String newName) {
|
||||
openGift(oldName);
|
||||
content.byTitle(oldName).edit();
|
||||
form.save(newName, "100");
|
||||
giftsContentRoot.shouldBe(Condition.visible);
|
||||
content.shouldBe(Condition.visible);
|
||||
}
|
||||
|
||||
public void shouldSeeGift(String name) {
|
||||
giftsContentRoot.shouldBe(Condition.visible);
|
||||
content.shouldBe(Condition.visible);
|
||||
content.byTitle(name).shouldHaveTitle(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package ru.otus.mobile.page;
|
||||
|
||||
import com.codeborne.selenide.Condition;
|
||||
import com.codeborne.selenide.SelenideElement;
|
||||
import com.google.inject.Singleton;
|
||||
import ru.otus.mobile.component.GiftItemComponent;
|
||||
import ru.otus.mobile.component.GiftsContentComponent;
|
||||
import ru.otus.mobile.component.TopBarComponent;
|
||||
import ru.otus.mobile.component.UsersContentComponent;
|
||||
import ru.otus.mobile.component.UsersFilterComponent;
|
||||
import ru.otus.mobile.component.WishlistsContentComponent;
|
||||
@@ -13,30 +12,22 @@ import java.time.Duration;
|
||||
|
||||
@Singleton
|
||||
public final class UsersPage extends AbsBasePage {
|
||||
private final SelenideElement topBarRoot = byId("top_app_bar");
|
||||
private final SelenideElement usersContentRoot = byId("users_content");
|
||||
private final SelenideElement usersFilterBottomSheet = byId("users_filter_bottom_sheet");
|
||||
private final SelenideElement firstUserItem = byId("user_item");
|
||||
private final SelenideElement wishlistsContentRoot = byId("wishlists_content");
|
||||
private final SelenideElement giftsContentRoot = byId("gifts_content");
|
||||
private final SelenideElement reservedToggle = byId("reserved");
|
||||
|
||||
private final TopBarComponent topBar = new TopBarComponent(topBarRoot);
|
||||
private final UsersContentComponent usersContent = new UsersContentComponent(usersContentRoot);
|
||||
private final UsersFilterComponent usersFilter = new UsersFilterComponent(usersFilterBottomSheet);
|
||||
private final WishlistsContentComponent wishlistsContent = new WishlistsContentComponent(wishlistsContentRoot);
|
||||
private final GiftsContentComponent giftsContent = new GiftsContentComponent(giftsContentRoot);
|
||||
private final UsersContentComponent usersContent = new UsersContentComponent(byId("users_content"));
|
||||
private final UsersFilterComponent usersFilter = new UsersFilterComponent(byId("users_filter_bottom_sheet"));
|
||||
private final WishlistsContentComponent wishlistsContent = new WishlistsContentComponent(byId("wishlists_content"));
|
||||
private final GiftsContentComponent giftsContent = new GiftsContentComponent(byId("gifts_content"));
|
||||
private GiftItemComponent currentGift;
|
||||
|
||||
public void open() {
|
||||
bottomNavigation.openUsers();
|
||||
usersContentRoot.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
usersContent.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
}
|
||||
|
||||
public void filterByUsername(String username) {
|
||||
topBar.openUsersFilter();
|
||||
usersFilterBottomSheet.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
usersFilter.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
usersFilter.applyByUsername(username);
|
||||
firstUserItem.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
usersContent.byUsername(username);
|
||||
}
|
||||
|
||||
public void openUser(String username) {
|
||||
@@ -52,18 +43,25 @@ public final class UsersPage extends AbsBasePage {
|
||||
}
|
||||
|
||||
public void openFirstGift() {
|
||||
giftsContent.get(0).open();
|
||||
currentGift = giftsContent.get(0);
|
||||
}
|
||||
|
||||
public void openGift(String name) {
|
||||
giftsContent.byTitle(name).open();
|
||||
currentGift = giftsContent.byTitle(name);
|
||||
}
|
||||
|
||||
public boolean isReserved() {
|
||||
return Boolean.parseBoolean(reservedToggle.shouldBe(Condition.visible).getAttribute("checked"));
|
||||
return selectedGift().isReserved();
|
||||
}
|
||||
|
||||
public void toggleReservation() {
|
||||
reservedToggle.shouldBe(Condition.visible).click();
|
||||
selectedGift().toggleReservation();
|
||||
}
|
||||
|
||||
private GiftItemComponent selectedGift() {
|
||||
if (currentGift == null) {
|
||||
throw new IllegalStateException("Gift is not selected. Call openFirstGift/openGift first.");
|
||||
}
|
||||
return currentGift;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,13 @@ import java.time.Duration;
|
||||
|
||||
@Singleton
|
||||
public final class WishlistsPage extends AbsBasePage {
|
||||
private final SelenideElement wishlistsContentRoot = byId("wishlists_content");
|
||||
private final SelenideElement addButton = byId("add_button");
|
||||
private final SelenideElement formRoot = byId("wishlist_edit_bottom_sheet");
|
||||
private final WishlistsContentComponent content = new WishlistsContentComponent(wishlistsContentRoot);
|
||||
private final WishlistFormComponent form = new WishlistFormComponent(formRoot);
|
||||
private final WishlistsContentComponent content = new WishlistsContentComponent(byId("wishlists_content"));
|
||||
private final WishlistFormComponent form = new WishlistFormComponent(byId("wishlist_edit_bottom_sheet"));
|
||||
|
||||
public void open() {
|
||||
bottomNavigation.openWishlists();
|
||||
wishlistsContentRoot.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
content.shouldBe(Condition.visible, Duration.ofSeconds(15));
|
||||
}
|
||||
|
||||
public void createWishlist(String name) {
|
||||
|
||||
Reference in New Issue
Block a user