Skip to content

Commit 918f4b5

Browse files
Fixed the failing tests (#39)
* fixed the tests, but the website is not working, POST /register api throws 500 due to which the error is not shown * fixed the test and updated the docker compose file with the fixes provided by Roy
1 parent 27cde2e commit 918f4b5

7 files changed

Lines changed: 53 additions & 12 deletions

File tree

docker-compose-toolshop.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ services:
77
- "DB_PORT=3306"
88
- "DB_HOST=mariadb"
99
- "host=localhost"
10-
- DISABLE_LOGGING=true
10+
- DISABLE_LOGGING=${DISABLE_LOGGING}
11+
volumes:
12+
- laravel-app-code:/var/www
1113

1214
angular-ui:
1315
image: testsmith/practice-software-testing-sprint5-ui
@@ -16,13 +18,33 @@ services:
1618
command: >
1719
bash -c "ng serve --host 0.0.0.0 --port 4200"
1820
21+
# The Web Server
1922
web:
2023
image: testsmith/practice-software-testing-web
2124
ports:
2225
- 8091:80
2326
- 8000:81
2427
depends_on:
2528
- laravel-api
29+
volumes:
30+
- laravel-app-code:/var/www
31+
32+
cron:
33+
image: testsmith/practice-software-testing-cron
34+
restart: always
35+
depends_on:
36+
- mariadb
37+
- laravel-api
38+
volumes:
39+
- laravel-app-code:/var/www
40+
working_dir: /var/www
41+
command: sh -c "crond -f -l 8"
42+
environment:
43+
- "PHP_OPCACHE_VALIDATE_TIMESTAMPS=1"
44+
- "DB_PORT=3306"
45+
- "DB_HOST=mariadb"
46+
- "host=localhost"
47+
- DISABLE_LOGGING=${DISABLE_LOGGING}
2648

2749
mariadb:
2850
image: yobasystems/alpine-mariadb:10.6.11
@@ -35,3 +57,12 @@ services:
3557
MYSQL_USER: user
3658
MYSQL_PASSWORD: root
3759
MYSQL_DATABASE: toolshop
60+
61+
mailcatcher:
62+
image: dockage/mailcatcher:0.9.0
63+
ports:
64+
- 1025:1025 # smtp server
65+
- 1080:1080 # web ui
66+
67+
volumes:
68+
laravel-app-code:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<surefire-version>3.5.5</surefire-version>
2222
<maven.source.encoding>UTF-8</maven.source.encoding>
2323
<suite-xml>testng.xml</suite-xml>
24-
<argLine>-Dfile.encoding=UTF-8 -Xdebug -Xnoagent</argLine>
24+
<argLine>-Dfile.encoding=UTF-8</argLine>
2525
</properties>
2626
<dependencies>
2727
<dependency>

src/test/java/io/github/mfaisalkhatri/data/RegistrationData.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class RegistrationData {
1111
private String lastName;
1212
private String dob;
1313
private String street;
14+
private String houseNumber;
1415
private String postalCode;
1516
private String city;
1617
private String state;

src/test/java/io/github/mfaisalkhatri/pages/RegistrationPage.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ public void fillRegistrationForm (final RegistrationData registrationData) {
2929
lastNameField ().clear ();
3030
lastNameField ().sendKeys (registrationData.getLastName ());
3131
dobField ().sendKeys (registrationData.getDob ());
32-
streetField ().clear ();
33-
streetField ().sendKeys (registrationData.getStreet ());
32+
selectCountryVisibleText (registrationData.getCountry ());
3433
postalCodeField ().clear ();
3534
postalCodeField ().sendKeys (registrationData.getPostalCode ());
36-
cityField ().clear ();
37-
cityField ().sendKeys (registrationData.getCity ());
38-
stateField ().clear ();
39-
stateField ().sendKeys (registrationData.getState ());
40-
selectCountryVisibleText (registrationData.getCountry ());
35+
houseNumber().clear();
36+
houseNumber().sendKeys(registrationData.getHouseNumber());
37+
//streetField ().clear ();
38+
//streetField ().sendKeys (registrationData.getStreet ());
39+
//cityField ().clear ();
40+
//cityField ().sendKeys (registrationData.getCity ());
41+
//stateField ().clear ();
42+
//stateField ().sendKeys (registrationData.getState ());
4143
phoneField ().clear ();
4244
phoneField ().sendKeys (registrationData.getPhone ());
4345
emailAddressField ().clear ();
@@ -103,6 +105,10 @@ private WebElement registerButton () {
103105
return this.driver.findElement (By.cssSelector (".btnSubmit"));
104106
}
105107

108+
private WebElement houseNumber () {
109+
return this.driver.findElement(By.id("house_number"));
110+
}
111+
106112
private void selectCountryVisibleText (final String countryName) {
107113
new Select (countryField ()).selectByVisibleText (countryName);
108114
}

src/test/java/io/github/mfaisalkhatri/test/BaseTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
public class BaseTest implements WebDriverProvider {
1313

14-
protected WebDriver driver;
14+
protected WebDriver driver;
1515

1616
@Override
1717
public WebDriver getDriver () {
@@ -21,7 +21,7 @@ public WebDriver getDriver () {
2121
@BeforeClass
2222
public void setup () {
2323
ChromeOptions chromeOptions = new ChromeOptions ();
24-
chromeOptions.addArguments ("--headless=new","--no-sandbox","--window-size=1920,1080");
24+
chromeOptions.addArguments ("--headless=new", "--no-sandbox", "--window-size=1920,1080");
2525

2626
this.driver = new ChromeDriver (chromeOptions);
2727
this.driver.manage ()

src/test/java/io/github/mfaisalkhatri/test/JsonDataProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Iterator<RegistrationData> getValidRegistrationData () {
3232
@Test (dataProvider = "getValidRegistrationData")
3333
public void testRegistrationPasswordAlert (final RegistrationData registrationData) {
3434
this.driver.get ("http://localhost:4200/");
35-
// this.driver.get ("https://practicesoftwaretesting.com/auth/register");
35+
// this.driver.get ("https://practicesoftwaretesting.com/auth/register");
3636

3737
HomePage homePage = new HomePage (driver);
3838
LoginPage loginPage = homePage.navigateToLoginPage ();

src/test/resources/testdata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dob": "1987-11-19",
77
"street": "11/2, Fort Street",
88
"postalCode": "113445",
9+
"houseNumber": 25,
910
"city": "California",
1011
"state": "Holland",
1112
"country": "Benin",
@@ -20,6 +21,7 @@
2021
"dob": "1985-04-23",
2122
"street": "21/4, Dallas Street",
2223
"postalCode": "12976",
24+
"houseNumber": 11,
2325
"city": "California",
2426
"state": "Dallas",
2527
"country": "American Samoa",
@@ -35,6 +37,7 @@
3537
"street": "30/2, Texas Street",
3638
"postalCode": "155642",
3739
"city": "California",
40+
"houseNumber": 30,
3841
"state": "Duckberg",
3942
"country": "Austria",
4043
"phone": "0483678",

0 commit comments

Comments
 (0)