Skip to content

Commit

Permalink
updated pdf in Palace, added sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
AEkaterina committed Oct 19, 2023
1 parent 748fba5 commit 1770468
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 12 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow helps you trigger a SonarQube analysis of your code and populates
# GitHub Code Scanning alerts with the vulnerabilities found.
# (this feature is available starting from SonarQube 9.7, Developer Edition and above)

# 1. Make sure you add a valid GitHub configuration to your SonarQube (Administration > DevOps platforms > GitHub)

# 2. Import your project on SonarQube
# * Add your repository as a new project by clicking "Create project" from your homepage.
#
# 3. Select GitHub Actions as your CI and follow the tutorial
# * a. Generate a new token and add it to your GitHub repository's secrets using the name SONAR_TOKEN
# (On SonarQube, click on your avatar on top-right > My account > Security or ask your administrator)
#
# * b. Copy/paste your SonarQube host URL to your GitHub repository's secrets using the name SONAR_HOST_URL
#
# * c. Copy/paste the project Key into the args parameter below
# (You'll find this information in SonarQube by following the tutorial or by clicking on Project Information at the top-right of your project's homepage)

# Feel free to take a look at our documentation (https://docs.sonarqube.org/latest/analysis/github-integration/)
# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/sq/10)

name: SonarQube analysis

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
pull-requests: read # allows SonarQube to decorate PRs with analysis results

jobs:
Analysis:
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3
env:
EXCLUDE_PATH: palace/.git
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Install SonarQube Scanner
run: |
curl -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip -o sonar-scanner.zip
unzip sonar-scanner.zip
rm sonar-scanner.zip
mv sonar-scanner-* sonar-scanner
sudo mv sonar-scanner /opt/
sudo ln -s /opt/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner
- name: Run SonarQube analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: sonar-scanner -Dsonar.projectKey=Mobile_tests -Dsonar.projectName='MobileTests' -Dsonar.sources='src' -Dsonar.language='java' -Dsonar.java.binaries='src' -Dsonar.java.test.binaries='src'
5 changes: 3 additions & 2 deletions src/test/java/features/PdfPalaceIos.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Read PDF in Palace Bookshelf on IOS
Then Library "Palace Bookshelf" is opened on Libraries screen
When Open Catalog
And Open search modal
And Search for 'Deep into Pharo' and save bookName as 'bookNameInfo'
And Search for 'Pharo by Example 5.0' and save bookName as 'bookNameInfo'
And Click GET action button on EBOOK book with 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Then EBOOK book with READ action button and 'bookInfo' bookInfo is present on Catalog books screen
When Open EBOOK book with READ action button and 'bookNameInfo' bookName on Catalog books screen and save book as 'bookInfo'
Expand Down Expand Up @@ -72,7 +72,8 @@ Feature: Read PDF in Palace Bookshelf on IOS

@tier2 @exclude_android
Scenario: Navigate by Page slider
When Save page number as 'pageNumber' on pdf reader screen
When Swipe pdf page forward from 4 to 6 times on reader pdf screen
And Save page number as 'pageNumber' on pdf reader screen
And Slide page slider RIGHT on reader pdf screen
Then The 'pageNumber' saved page number is less than the current page number on the reader pdf screen
When Save page number as 'pageNumber' on pdf reader screen
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/screens/SortOptionsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SortOptionsScreen extends Screen {

private final IButton btnSortBy = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.Button[2]")),
new IosLocator(By.xpath("(//XCUIElementTypeCollectionView/preceding-sibling::XCUIElementTypeOther//XCUIElementTypeButton)[1]"))), "Sort by button");
new IosLocator(By.xpath("//XCUIElementTypeStaticText[@name=\"Sort By:\"]/following-sibling::XCUIElementTypeButton"))), "Sort by button");
private final IButton btnAvailability = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//*[contains(@resource-id,\"feedHeaderFacets\")]/android.widget.Button[1]")),
new IosLocator(By.xpath("//XCUIElementTypeScrollView//XCUIElementTypeButton[2]"))), "Availability button");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/screens/pdf/NavigationBarPdfScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class NavigationBarPdfScreen extends Screen {
new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeOther[2]//XCUIElementTypeButton[2]"))), "Search button");
private final IButton btnBack = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("//android.widget.ImageButton[@content-desc=\"Back\"]")),
new IosLocator(By.xpath("//XCUIElementTypeNavigationBar/XCUIElementTypeButton[@name=\"Back\"]"))), "Back button");
new IosLocator(By.xpath("//XCUIElementTypeNavigationBar//XCUIElementTypeButton[@name=\"Back\"]"))), "Back button");
private final IButton btnSettings = getElementFactory().getButton(By.xpath("//android.widget.Button[@content-desc=\"Settings\"]"), "Settings button");
private final IButton btnBookmark = getElementFactory().getButton(LocatorUtils.getLocator(
new AndroidLocator(By.xpath("")),
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/screens/pdf/ReaderPdfScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean isReaderOpened() {
public int getPageNumber() {
Integer pageNumber = ActionProcessorUtils.doForIos(() -> {
openNavigationBar();
return Integer.parseInt(StringUtils.substringBefore(lblPageNumber.getAttribute(IosAttributes.NAME), "/"));
return Integer.parseInt(StringUtils.substringBetween(lblPageNumber.getAttribute(IosAttributes.NAME), "(", "/"));
});

if(pageNumber == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/screens/pdf/ThumbnailsPdfScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ThumbnailsPdfScreen extends Screen {
private static final String THUMBNAIL_NUMBER_LOCATOR_ANDROID = "//android.view.View[@content-desc=\"Thumbnail of Page %d\"]";

private static final String THUMBNAIL_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell";
private static final String THUMBNAIL_NUMBER_LOCATOR_IOS = THUMBNAIL_LOCATOR_IOS + "/XCUIElementTypeStaticText[@name=\"%d\"]";
private static final String THUMBNAIL_NUMBER_LOCATOR_IOS = "//XCUIElementTypeCollectionView/XCUIElementTypeCell[%d]/XCUIElementTypeStaticText";

public ThumbnailsPdfScreen() {
super(LocatorUtils.getLocator(
Expand Down
7 changes: 1 addition & 6 deletions src/test/java/stepdefinitions/ApplicationSteps.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package stepdefinitions;

import aquality.appium.mobile.application.AqualityServices;
import aquality.appium.mobile.application.PlatformName;
import com.google.inject.Inject;
import enums.localization.catalog.ActionButtonsForBooksAndAlertsKeys;
import enums.timeouts.RestartAppTimeouts;
Expand Down Expand Up @@ -144,11 +143,7 @@ public void returnToPreviousScreenForEpubAndPdf() {
readerEpubScreen.openNavigationBar();
readerEpubScreen.getNavigationBarEpubScreen().returnToPreviousScreen();
} else if (readerPdfScreen.state().isDisplayed()) {
if (AqualityServices.getApplication().getPlatformName() == PlatformName.ANDROID) {
readerPdfScreen.getNavigationBarScreen().tapBackButton();
} else if (AqualityServices.getApplication().getPlatformName() == PlatformName.IOS) {
readerPdfScreen.getNavigationBarScreen().tapBackButton();
}
readerPdfScreen.getNavigationBarScreen().tapBackButton();
}
});
}
Expand Down

0 comments on commit 1770468

Please sign in to comment.