Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 50 additions & 68 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
- 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
target/
.idea/
/screenshots/
/API
/UI

### VS Code ###
.vscode/
Expand Down
6 changes: 0 additions & 6 deletions UI/package-lock.json

This file was deleted.

37 changes: 37 additions & 0 deletions docker-compose-toolshop.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 13 additions & 12 deletions src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 ();
Expand All @@ -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 () {
Expand Down Expand Up @@ -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"));
}

}
2 changes: 1 addition & 1 deletion src/test/java/io/github/mfaisalkhatri/test/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Iterator<RegistrationData> 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 ();
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/testdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Loading