diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ec35210..b497ffd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,11 +1,3 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# 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. - name: Java CI with Maven on: @@ -20,69 +12,59 @@ on: - issue-* permissions: - statuses: write - checks: write - contents: write - pull-requests: write + statuses: write + checks: write + contents: write + pull-requests: write jobs: build: - name: Build and Test + name: Build and Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - - name: Install Java and Maven - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'adopt' - cache: maven - - - name: Checkout Practice Software Testing repo - uses: actions/checkout@v4 - with: - repository: testsmith-io/practice-software-testing - path: practice-repo - - - name: Start Practice Software Testing with Docker Compose - working-directory: practice-repo - run: docker compose -f docker-compose.yml up -d - - - name: Sleep for 60 seconds - run: sleep 60s - shell: bash - - - name: Create and Seed Database - working-directory: practice-repo - run: | - docker compose exec laravel-api php artisan migrate:fresh --seed - - - name: Install Chrome - uses: browser-actions/setup-chrome@latest - - - name: Build Project and run tests - run: mvn clean install - - - name: Upload screenshots - if: always() - uses: actions/upload-artifact@v4 - with: - name: test-screenshots - path: screenshots - - - name: Test Report - uses: dorny/test-reporter@v2 - if: success() || failure() - with: - name: Test Results - path: ${{ github.workspace }}/target/surefire-reports/TEST-TestSuite.xml - reporter: java-junit - java-version: 17 \ No newline at end of file + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Checkout Practice Software Testing repo + uses: actions/checkout@v4 + with: + repository: testsmith-io/practice-software-testing + path: practice-repo + + - name: Start Practice Software Testing with Docker Compose + working-directory: practice-repo + run: docker compose -f docker-compose.yml up -d + + - name: Sleep for 60 seconds + run: sleep 60s + shell: bash + + - name: Create and Seed Database + working-directory: practice-repo + run: | + docker compose exec laravel-api php artisan migrate:fresh --seed + + - name: Build Project and run tests + run: mvn clean install + + - name: Upload screenshots + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-screenshots + path: screenshots + + - name: Test Report + uses: dorny/test-reporter@v2 + if: success() || failure() + with: + name: Test Results + path: ${{ github.workspace }}/target/surefire-reports/TEST-TestSuite.xml + reporter: java-junit + java-version: 17 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 73f7c40..d9aa04c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ target/ .idea/ /screenshots/ +/API +/UI ### VS Code ### .vscode/ diff --git a/UI/package-lock.json b/UI/package-lock.json deleted file mode 100644 index 4ca926f..0000000 --- a/UI/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "app", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} diff --git a/docker-compose-toolshop.yml b/docker-compose-toolshop.yml new file mode 100644 index 0000000..4c178c8 --- /dev/null +++ b/docker-compose-toolshop.yml @@ -0,0 +1,37 @@ +version: '2' +services: + laravel-api: + image: testsmith/practice-software-testing-sprint5-api + environment: + - "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1" + - "DB_PORT=3306" + - "DB_HOST=mariadb" + - "host=localhost" + - DISABLE_LOGGING=true + + angular-ui: + image: testsmith/practice-software-testing-sprint5-ui + ports: + - 4200:4200 + command: > + bash -c "ng serve --host 0.0.0.0 --port 4200" + + web: + image: testsmith/practice-software-testing-web + ports: + - 8091:80 + - 8000:81 + depends_on: + - laravel-api + + mariadb: + image: yobasystems/alpine-mariadb:10.6.11 + ports: + - 3306:3306 + expose: + - 3306 + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: user + MYSQL_PASSWORD: root + MYSQL_DATABASE: toolshop diff --git a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java index 2340321..f4ec987 100644 --- a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java +++ b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java @@ -1,13 +1,12 @@ package io.github.mfaisalkhatri.pages; import java.time.Duration; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import io.github.mfaisalkhatri.data.RegistrationData; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.support.ui.WebDriverWait; @@ -29,7 +28,7 @@ public void fillRegistrationForm (final RegistrationData registrationData) { firstNameField ().sendKeys (registrationData.getFirstName ()); lastNameField ().clear (); lastNameField ().sendKeys (registrationData.getLastName ()); - dobField ().sendKeys (dateOfBirth (registrationData.getDob ())); + dobField ().sendKeys (registrationData.getDob ()); streetField ().clear (); streetField ().sendKeys (registrationData.getStreet ()); postalCodeField ().clear (); @@ -54,8 +53,14 @@ public String pageHeader () { } public String passwordAlertMessage () { - return wait.until (ExpectedConditions.visibilityOfElementLocated (By.cssSelector (".alert-danger div"))) - .getText (); + Actions actions = new Actions (driver); + actions.moveToElement (footerField ()).build ().perform (); + WebElement warningMessage = wait.until ( + ExpectedConditions.visibilityOfElementLocated (By.cssSelector ("div.alert"))); + actions.moveToElement (warningMessage) + .build () + .perform (); + return warningMessage.getText (); } private WebElement cityField () { @@ -110,12 +115,8 @@ private WebElement streetField () { return this.driver.findElement (By.id ("street")); } - private String dateOfBirth (String jsonDate) { - - DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern ("dd/MM/yyyy"); - LocalDate date = LocalDate.parse (jsonDate, inputFormat); - - DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern ("MM/dd/yyyy"); - return date.format (outputFormat); + private WebElement footerField () { + return this.driver.findElement (By.cssSelector ("app-footer p")); } + } diff --git a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java index 3d13aee..fc1f1a1 100644 --- a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java +++ b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java @@ -21,7 +21,7 @@ public WebDriver getDriver () { @BeforeClass public void setup () { ChromeOptions chromeOptions = new ChromeOptions (); - chromeOptions.addArguments ("--headless=new","--no-sandbox", "--window-size=1920,1080"); + chromeOptions.addArguments ("--headless=new","--no-sandbox","--window-size=1920,1080"); this.driver = new ChromeDriver (chromeOptions); this.driver.manage () diff --git a/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java b/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java index f460891..645b2a8 100644 --- a/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java +++ b/src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java @@ -32,7 +32,7 @@ public Iterator getValidRegistrationData () { @Test (dataProvider = "getValidRegistrationData") public void testRegistrationPasswordAlert (final RegistrationData registrationData) { this.driver.get ("http://localhost:4200/"); - //this.driver.get ("https://practicesoftwaretesting.com/auth/register"); + // this.driver.get ("https://practicesoftwaretesting.com/auth/register"); HomePage homePage = new HomePage (driver); LoginPage loginPage = homePage.navigateToLoginPage (); diff --git a/src/test/resources/testdata.json b/src/test/resources/testdata.json index 49beac3..9f985c4 100644 --- a/src/test/resources/testdata.json +++ b/src/test/resources/testdata.json @@ -3,7 +3,7 @@ { "firstName": "Jason", "lastName": "Langer", - "dob": "17/05/1987", + "dob": "1987-11-19", "street": "11/2, Fort Street", "postalCode": "113445", "city": "California", @@ -17,7 +17,7 @@ { "firstName": "Michael", "lastName": "Justin", - "dob": "23/07/1985", + "dob": "1985-04-23", "street": "21/4, Dallas Street", "postalCode": "12976", "city": "California", @@ -31,7 +31,7 @@ { "firstName": "Abraham", "lastName": "Lord", - "dob": "16/06/1981", + "dob": "1981-08-30", "street": "30/2, Texas Street", "postalCode": "155642", "city": "California",