Skip to content

Commit

Permalink
🔧 fix failed test example & update version
Browse files Browse the repository at this point in the history
  • Loading branch information
depapp committed Aug 27, 2024
1 parent 10d2ad4 commit a0ce8b7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 63 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ jobs:
if: matrix.node-version != '22.x'

- name: run pusakatest
run: pusakatest -y
run: |
node -v
pusakatest -y
if: matrix.node-version != '22.x'
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pusakatest",
"version": "2.2.3",
"version": "2.3.0",
"description": "pusakatest is an automation testing tool based on pactum using bdd (cucumber) style",
"main": "index.js",
"bin": "bin/create-project",
Expand Down
98 changes: 41 additions & 57 deletions templates/english/features/example-authentication.feature
Original file line number Diff line number Diff line change
@@ -1,97 +1,81 @@
Feature: Authentication on ADEQUATESHOP API
Feature: DummyJSON API

API Automation with Authentication example
API Automation with DummyJSON API

Scenario: User Registration using Registered Data
Given I make a "POST" request to "http://restapi.adequateshop.com/api/authaccount/registration"
Scenario: User Login using Valid Credentials
Given I make a "POST" request to "https://dummyjson.com/auth/login"
And I set body to
"""
{
"name": "PactumJS 01",
"email": "pactumjs01@gmail.com",
"password": 123456
"username": "emilys",
"password": "emilyspass"
}
"""
When I receive a response
Then I expect response should have a status "200"
And I expect response should have a json
And I expect response should contain a json
"""
{
"code": 1,
"message": "The email address you have entered is already registered",
"data": null
"id": 1,
"email": "emily.johnson@x.dummyjson.com",
"username": "emilys",
"firstName": "Emily",
"lastName": "Johnson",
"gender": "female"
}
"""

Scenario: User Registration using Invalid Data
Given I make a "POST" request to "http://restapi.adequateshop.com/api/authaccount/registration"
Scenario: User Login using Invalid Credentials
Given I make a "POST" request to "https://dummyjson.com/auth/login"
And I set body to
"""
{
"name": "PactumJS XXX",
"email": "pactumjsxxx",
"password": 123456
"username": "notfounduser",
"password": "invalidpassword"
}
"""
When I receive a response
Then I expect response should have a status "400"
And I expect response should have a json at "ModelState"
And I expect response should have a json
"""
{
"User.email": [
"Enter valid email address"
]
"message": "Invalid credentials"
}
"""

Scenario: User Login using Valid Data
Given I make a "POST" request to "http://restapi.adequateshop.com/api/authaccount/login"
Scenario: Add New User using Valid Data
Given I make a "POST" request to "https://dummyjson.com/users/add"
And I set body to
"""
{
"email": "pactumjs001@gmail.com",
"password": 123456
"firstName": "Ujang",
"lastName": "Tea",
"maidenName": "Jajang",
"age": 17,
"gender": "male",
"email": "ujang.jajang@x.dummyjson.com",
"phone": "+62 812-1234-1234",
"username": "ujangjajang",
"password": "123123123"
}
"""
When I receive a response
Then I expect response should have a status "200"
And I expect response should have a json schema at "data"
"""
{
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Email": {
"type": "string"
},
"Token": {
"type": "string"
}
}
}
"""
Then I expect response should have a status "201"
And I log the response body

Scenario: User Login using Invalid Data
Given I make a "POST" request to "http://restapi.adequateshop.com/api/authaccount/login"
And I set body to
"""
{
"email": "invalidaccount@email.com",
"password": 111222333
}
"""
Scenario: Get Valid Single User Data
Given I make a "GET" request to "https://dummyjson.com/users/1"
When I receive a response
Then I expect response should have a status "200"
And I log the response body

Scenario: Get Invalid Single User Data
Given I make a "GET" request to "https://dummyjson.com/users/99999"
When I receive a response
Then I expect response should have a status "404"
And I expect response should have a json
"""
{
"code": 1,
"message": "invalid username or password",
"data": null
"message": "User with id '99999' not found"
}
"""
12 changes: 11 additions & 1 deletion templates/english/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ Then(/^I store response at "(.*)" as "(.*)"$/, function (path, name) {
spec.stores(name, path)
})

Then(/^I expect response should contain a json$/, function (json) {
spec.response().should.have.jsonLike(JSON.parse(json))
})

Then('I log the response body', async function () {
const response = await spec.toss().then((res) => res.json);
console.log(response);
this.attach(JSON.stringify(response, null, 2), 'application/json');
});

After(() => {
spec.end()
})
})
2 changes: 1 addition & 1 deletion templates/english/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pusakatest",
"version": "2.2.3",
"version": "2.3.0",
"description": "pusakatest is an automation testing tool based on pactum using bdd (cucumber) style",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a0ce8b7

Please sign in to comment.