From 96cc12818149c087ec345534c01bc070d0094144 Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 19:06:09 +0300 Subject: [PATCH 01/12] fixed the date of birth field format in the test, added docker compose for toolshop website, updated the github actions workflow to use docker compose --- .github/workflows/maven.yml | 19 +++------- .gitignore | 2 + UI/package-lock.json | 6 --- docker-compose-toolshop.yml | 37 +++++++++++++++++++ .../mfaisalkhatri/pages/RegistrationPage.java | 10 +---- .../test/JsonDataProviderTest.java | 2 +- src/test/resources/testdata.json | 6 +-- 7 files changed, 50 insertions(+), 32 deletions(-) delete mode 100644 UI/package-lock.json create mode 100644 docker-compose-toolshop.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ec35210..cf1b32f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -46,15 +46,8 @@ jobs: 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: Start Practice Software Testing ToolShop Website with Docker Compose + run: docker compose -f docker-compose-toolshop.yml up -d - name: Sleep for 60 seconds run: sleep 60s @@ -63,10 +56,7 @@ jobs: - 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 + docker compose exec -f docker-compose-toolshop.yml laravel-api php artisan migrate:fresh --seed - name: Build Project and run tests run: mvn clean install @@ -78,6 +68,9 @@ jobs: name: test-screenshots path: screenshots + - name: Stop Practice Software Testing ToolShop Website + run: docker compose -f docker-compose-toolshop.yml down --remove-orphans + - name: Test Report uses: dorny/test-reporter@v2 if: success() || failure() 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..49965e1 100644 --- a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java +++ b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java @@ -29,7 +29,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 (); @@ -110,12 +110,4 @@ 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); - } } 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", From 58b00ca33cf758841df1aa9ba30f2223eb0170f1 Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 19:09:57 +0300 Subject: [PATCH 02/12] fixed github actions issue by removing the working directory for seeding the db --- .github/workflows/maven.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index cf1b32f..cc4813d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -54,9 +54,7 @@ jobs: shell: bash - name: Create and Seed Database - working-directory: practice-repo - run: | - docker compose exec -f docker-compose-toolshop.yml laravel-api php artisan migrate:fresh --seed + run: docker compose exec -f docker-compose-toolshop.yml laravel-api php artisan migrate:fresh --seed - name: Build Project and run tests run: mvn clean install From 9bf5b6610ef63d6386211114919c1ab1471ca57b Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 19:13:19 +0300 Subject: [PATCH 03/12] fixed github actions workflow issue by updating the command to seed db and removed 60s sleep --- .github/workflows/maven.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index cc4813d..76da304 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -49,12 +49,8 @@ jobs: - name: Start Practice Software Testing ToolShop Website with Docker Compose run: docker compose -f docker-compose-toolshop.yml up -d - - name: Sleep for 60 seconds - run: sleep 60s - shell: bash - - name: Create and Seed Database - run: docker compose exec -f docker-compose-toolshop.yml laravel-api php artisan migrate:fresh --seed + run: docker compose -f docker-compose-toolshop.yml exec laravel-api php artisan migrate:fresh --seed - name: Build Project and run tests run: mvn clean install From c12fa7a6c749b79d1ed461735c9fcffad19a045c Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 19:17:21 +0300 Subject: [PATCH 04/12] added 60s delay before seeding the DB --- .github/workflows/maven.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 76da304..c08c038 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -49,6 +49,10 @@ jobs: - name: Start Practice Software Testing ToolShop Website with Docker Compose run: docker compose -f docker-compose-toolshop.yml up -d + - name: Sleep for 60 seconds + run: sleep 60s + shell: bash + - name: Create and Seed Database run: docker compose -f docker-compose-toolshop.yml exec laravel-api php artisan migrate:fresh --seed From d7234119cdac064aff2584127f0743c9f9b1381c Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 19:49:26 +0300 Subject: [PATCH 05/12] added new logic to move to the warning message and get its text as it was not coming into view --- .../github/mfaisalkhatri/pages/RegistrationPage.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java index 49965e1..f198c1e 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; @@ -54,8 +53,13 @@ public String pageHeader () { } public String passwordAlertMessage () { - return wait.until (ExpectedConditions.visibilityOfElementLocated (By.cssSelector (".alert-danger div"))) - .getText (); + WebElement warningMessage = wait.until ( + ExpectedConditions.visibilityOfElementLocated (By.cssSelector (".alert-danger div"))); + Actions actions = new Actions (driver); + actions.moveToElement (warningMessage) + .build () + .perform (); + return warningMessage.getText (); } private WebElement cityField () { From da2492542b573f7eb656028a073c506a56013348 Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 20:00:18 +0300 Subject: [PATCH 06/12] changed window size --- src/test/java/io/github/mfaisalkhatri/test/BaseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java index 3d13aee..02594ee 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=1280,720"); this.driver = new ChromeDriver (chromeOptions); this.driver.manage () From 5b70869bd34d0d7ce6afa19572d7fec24a49cc48 Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 20:24:38 +0300 Subject: [PATCH 07/12] changed warning message locator --- .../java/io/github/mfaisalkhatri/pages/RegistrationPage.java | 2 +- src/test/java/io/github/mfaisalkhatri/test/BaseTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java index f198c1e..da9f214 100644 --- a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java +++ b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java @@ -54,7 +54,7 @@ public String pageHeader () { public String passwordAlertMessage () { WebElement warningMessage = wait.until ( - ExpectedConditions.visibilityOfElementLocated (By.cssSelector (".alert-danger div"))); + ExpectedConditions.visibilityOfElementLocated (By.cssSelector ("div.alert"))); Actions actions = new Actions (driver); actions.moveToElement (warningMessage) .build () diff --git a/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java b/src/test/java/io/github/mfaisalkhatri/test/BaseTest.java index 02594ee..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=1280,720"); + chromeOptions.addArguments ("--headless=new","--no-sandbox","--window-size=1920,1080"); this.driver = new ChromeDriver (chromeOptions); this.driver.manage () From b06004ce8a7e7635bf3706459c7982019a169872 Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 20:41:40 +0300 Subject: [PATCH 08/12] added footer link to check footer verifying that the message is displayed --- .../io/github/mfaisalkhatri/pages/RegistrationPage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java index da9f214..f4ec987 100644 --- a/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java +++ b/src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java @@ -53,9 +53,10 @@ public String pageHeader () { } public String passwordAlertMessage () { + Actions actions = new Actions (driver); + actions.moveToElement (footerField ()).build ().perform (); WebElement warningMessage = wait.until ( ExpectedConditions.visibilityOfElementLocated (By.cssSelector ("div.alert"))); - Actions actions = new Actions (driver); actions.moveToElement (warningMessage) .build () .perform (); @@ -114,4 +115,8 @@ private WebElement streetField () { return this.driver.findElement (By.id ("street")); } + private WebElement footerField () { + return this.driver.findElement (By.cssSelector ("app-footer p")); + } + } From 7fef93a55d6397db8d6c1962a2d51f1c627ff3cf Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 20:52:19 +0300 Subject: [PATCH 09/12] increased delay to 90s --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c08c038..e9184a2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -49,8 +49,8 @@ jobs: - name: Start Practice Software Testing ToolShop Website with Docker Compose run: docker compose -f docker-compose-toolshop.yml up -d - - name: Sleep for 60 seconds - run: sleep 60s + - name: Sleep for 90 seconds + run: sleep 90s shell: bash - name: Create and Seed Database From 149627c152da8b4274edd7a7c808c6e8ecfc01fc Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 20:53:31 +0300 Subject: [PATCH 10/12] removed install java step as it is already available in checkout step --- .github/workflows/maven.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e9184a2..fda8704 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -39,13 +39,6 @@ jobs: distribution: 'temurin' cache: maven - - name: Install Java and Maven - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'adopt' - cache: maven - - name: Start Practice Software Testing ToolShop Website with Docker Compose run: docker compose -f docker-compose-toolshop.yml up -d From 3a711ee5f6aa89a9e7b8de179f1c585500c78b5a Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 21:01:59 +0300 Subject: [PATCH 11/12] added steps to get version and post login after DB seeding --- .github/workflows/maven.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fda8704..94534d3 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: @@ -49,6 +41,15 @@ jobs: - name: Create and Seed Database run: docker compose -f docker-compose-toolshop.yml exec laravel-api php artisan migrate:fresh --seed + - name: GET Version + run: curl -v -X GET 'http://localhost:8091/status' + + - name: POST login + run: | + curl -v -X POST 'http://localhost:8091/users/login' \ + -H 'Content-Type: application/json' \ + --data-raw '{"email":"customer@practicesoftwaretesting.com","password":"welcome01"}' + - name: Build Project and run tests run: mvn clean install From 15862f40dcfd01886344b952d770d421f1025e6a Mon Sep 17 00:00:00 2001 From: "mohammadfaisalkhatri@gmail.com" Date: Sun, 13 Jul 2025 21:15:16 +0300 Subject: [PATCH 12/12] reverted to old github actions workflow --- .github/workflows/maven.yml | 89 ++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 94534d3..b497ffd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -12,62 +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 + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven - - name: Start Practice Software Testing ToolShop Website with Docker Compose - run: docker compose -f docker-compose-toolshop.yml up -d + - name: Checkout Practice Software Testing repo + uses: actions/checkout@v4 + with: + repository: testsmith-io/practice-software-testing + path: practice-repo - - name: Sleep for 90 seconds - run: sleep 90s - shell: bash + - name: Start Practice Software Testing with Docker Compose + working-directory: practice-repo + run: docker compose -f docker-compose.yml up -d - - name: Create and Seed Database - run: docker compose -f docker-compose-toolshop.yml exec laravel-api php artisan migrate:fresh --seed + - name: Sleep for 60 seconds + run: sleep 60s + shell: bash - - name: GET Version - run: curl -v -X GET 'http://localhost:8091/status' + - name: Create and Seed Database + working-directory: practice-repo + run: | + docker compose exec laravel-api php artisan migrate:fresh --seed - - name: POST login - run: | - curl -v -X POST 'http://localhost:8091/users/login' \ - -H 'Content-Type: application/json' \ - --data-raw '{"email":"customer@practicesoftwaretesting.com","password":"welcome01"}' + - name: Build Project and run tests + run: mvn clean install - - 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: Upload screenshots - if: always() - uses: actions/upload-artifact@v4 - with: - name: test-screenshots - path: screenshots - - - name: Stop Practice Software Testing ToolShop Website - run: docker compose -f docker-compose-toolshop.yml down --remove-orphans - - - 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 + - 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