Skip to content

Commit

Permalink
Merge pull request #30 from ThePalaceProject/sample
Browse files Browse the repository at this point in the history
refactoring ios
  • Loading branch information
AEkaterina authored Feb 6, 2024
2 parents b4bfc22 + 1af05e4 commit 72acf24
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 94 deletions.
62 changes: 9 additions & 53 deletions src/test/java/features/AudiobookOverdrive.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@ Feature: Audiobooks in A1QA library
When Open Catalog
And Switch to "Audiobooks" catalog tab
Then Catalog screen is opened
When Open categories by chain and chain starts from CategoryScreen:
| OverDrive |
Then Subcategory screen is opened

@logout @returnBooks @tier2
Scenario: Audiobooks: Open the audiobook at the last open chapter and check time code
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand Down Expand Up @@ -70,11 +62,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario: Audiobooks: Navigate by Audiobook
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand Down Expand Up @@ -102,12 +90,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario: Audiobooks: Check end of chapter sleep timer
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand All @@ -128,11 +111,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2 @exclude_android
Scenario: Audiobooks: Check of line for time remaining
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand All @@ -145,12 +124,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario: Audiobooks: Check of switching to the next chapter
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand All @@ -167,11 +141,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario: Audiobooks: Check closing playback speed and sleep timer
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand All @@ -192,12 +162,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario: Audiobooks: Check time tracking line
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand All @@ -221,11 +186,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario: Audiobooks: Check of not rewinding forward and back by tapping on time bar
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand All @@ -250,12 +211,7 @@ Feature: Audiobooks in A1QA library

@logout @returnBooks @tier2
Scenario Outline: Audiobooks: Playback speed: Check of playback speed
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
And Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
When Get AUDIOBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open AUDIOBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains LISTEN action button on Book details screen
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/features/Distributors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,7 @@ Feature: Distributors
And Open Catalog
And Switch to "eBooks" catalog tab
Then Catalog screen is opened
When Open categories by chain and chain starts from CategoryScreen:
| OverDrive |
Then Subcategory screen is opened
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
When Get EBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Open EBOOK book with GET action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click GET action button on Book details screen
Then Check that book contains READ action button on Book details screen
Expand Down
25 changes: 4 additions & 21 deletions src/test/java/features/EpubOverdrive.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,10 @@ Feature: Read EPUB from Overdrive in A1QA
When Open Catalog
And Switch to "eBooks" catalog tab
Then Catalog screen is opened
When Open categories by chain and chain starts from CategoryScreen:
| OverDrive |
Then Subcategory screen is opened

@logout @tier2
Scenario: Epub: Open book to last page read
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
When Get EBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click READ action button on Book details screen
Expand All @@ -54,10 +47,7 @@ Feature: Read EPUB from Overdrive in A1QA

@logout @tier2
Scenario: Epub: Navigate by Page
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
When Get EBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click READ action button on Book details screen
Expand All @@ -76,11 +66,7 @@ Feature: Read EPUB from Overdrive in A1QA

@logout @returnBooks @tier2
Scenario: Epub: Navigate by bookmarks
When Swipe down
And Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
When Get EBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click READ action button on Book details screen
Expand All @@ -105,10 +91,7 @@ Feature: Read EPUB from Overdrive in A1QA

@logout @returnBooks @tier2
Scenario: Epub: Delete bookmarks
When Get names of books on Catalog books screen and save them as "bookList"
And Open Catalog
And Open search modal
And Search a book from the list "bookList" and save book name as 'bookNameInfo'
When Get EBOOK book from "OverDrive" category and save it as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
And Click READ action button on Book details screen
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/stepdefinitions/CatalogSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys;
import enums.localization.sortoptions.AvailabilityKeys;
import enums.localization.sortoptions.SortByKeys;
import framework.utilities.ActionProcessorUtils;
import framework.utilities.ScenarioContext;
import framework.utilities.swipe.SwipeElementUtils;
import io.cucumber.java.en.Then;
Expand Down Expand Up @@ -35,6 +36,8 @@ public class CatalogSteps {
private final CatalogBooksScreen catalogBooksScreen;
private final SortOptionsScreen sortOptionsScreen;
private final SearchScreen searchScreen;
private final SettingsScreen settingsScreen;
private final LibrariesScreen librariesScreen;
private final ScenarioContext context;
private static final SecureRandom random = new SecureRandom();

Expand All @@ -48,6 +51,8 @@ public CatalogSteps(ScenarioContext context){
catalogBooksScreen = new CatalogBooksScreen();
sortOptionsScreen = new SortOptionsScreen();
searchScreen = new SearchScreen();
settingsScreen = new SettingsScreen();
librariesScreen = new LibrariesScreen();
}

@When("Open Catalog")
Expand All @@ -62,7 +67,13 @@ public void isCatalogScreenOpened() {

@Then("Library {string} is opened on Catalog screen")
public void isLibraryOpenedInCatalog(String libraryName){
Assert.assertTrue("Library is not opened on the Catalog screen!", catalogScreen.isLibraryOnTheCatalogDisplayed(libraryName));
ActionProcessorUtils.doForAndroid(() -> Assert.assertTrue("Library is not opened on the Catalog screen!", catalogScreen.isLibraryOnTheCatalogDisplayed(libraryName)));
ActionProcessorUtils.doForIos(() -> {
menuBarScreen.openBottomMenuTab(MenuBar.SETTINGS);
menuBarScreen.openBottomMenuTab(MenuBar.SETTINGS);
settingsScreen.openLibraries();
Assert.assertTrue(libraryName + " is not present on Libraries screen", librariesScreen.isLibraryPresent(libraryName));
});
}

@Then("Count of books in first category is more than {int}")
Expand Down Expand Up @@ -307,6 +318,7 @@ public void getABookAndSave(BookType bookType, String categoryName, String bookN
bookName = StringUtils.substringBefore(bookName, ". Audiobook.");
}

menuBarScreen.openBottomMenuTab(MenuBar.CATALOG);
mainToolBarScreen.openSearchModal();
searchScreen.setSearchedText(bookName);
searchScreen.applySearch();
Expand Down
12 changes: 0 additions & 12 deletions src/test/java/stepdefinitions/SearchSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
import org.junit.Assert;
import screens.*;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;

public class SearchSteps {

private static final SecureRandom random = new SecureRandom();
private final MainToolBarScreen mainToolBarScreen;
private final SearchScreen searchScreen;
private final CatalogScreen catalogScreen;
Expand Down Expand Up @@ -138,14 +136,4 @@ public void searchSeveralBooks(String listKey, List<String> listOfBooks) {
public void returnBack() {
searchScreen.closeSearchScreen();
}

@When("Search a book from the list {string} and save book name as {string}")
public void searchFromList(String listNameKey, String bookNameInfoKey) {
List<String> bookList = context.get(listNameKey);
int bookIndex = random.nextInt(bookList.size());
String bookName = bookList.get(bookIndex);
searchScreen.setSearchedText(bookName);
searchScreen.applySearch();
context.add(bookNameInfoKey, bookName);
}
}

0 comments on commit 72acf24

Please sign in to comment.