-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: add integration test for the stakeholder #1774
Open
GuningShen
wants to merge
4
commits into
Greenstand:v2
Choose a base branch
from
GuningShen:feat/stakeholder
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bacd4e7
feat: add integration test for the stakeholder
GuningShen 2ee8dda
fix: change mock data and unit test
GuningShen 94011f1
Merge remote-tracking branch 'upstream/v2' into feat/stakeholder
GuningShen 81753ef
fix: change mock query path
GuningShen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"id": 940, | ||
"first_name": "Sebastian ", | ||
"last_name": "Gaertner", | ||
"image_url": "https://treetracker-dev-images.s3.eu-central-1.amazonaws.com/2020.10.19.09.47.53_-5.508107173727935_38.981361706266256_39f0cc9d-0f13-4547-8142-150f15cabb67_IMG_20201019_094513_6614320100195503436.jpg", | ||
"trees_planted": 4, | ||
"about": "Greenway is a Youth-Driven Environmental Protection Organization providing alternative solutions to single-use plastic and planting carbon-sucking trees for socio-economic development and reducing climate crisis. Our social work includes reforestation, landscape restoration, climate education, awareness campaign, conducting research, outreach activities, and collaborating with key stakeholders to implement sustainable solutions.", | ||
"mission": "To combat climate change, desertification, land degradation, carbon emission by inspiring healthier communities affected by severe climate disorder and modestly reducing pollution by 2050.", | ||
"created_time": "2018-01-01", | ||
"country": "Tanzania", | ||
"links": { | ||
"featured_trees": "/trees?planter_id=940&limit=4", | ||
"associated_organizations": "/organizations?planter_id=940", | ||
"species": "/species?planter_id=940" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
cypress/tests/integration/stakeholder/[stakeholderid].cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import species from '../../../../doc/examples/species/1.json'; | ||
import stakeholder from '../../../../doc/examples/stakeholders/180Earth.json'; | ||
import planter from '../../../fixtures/940.json'; | ||
import exampleTreeData from '../../../fixtures/tree186734.json'; | ||
import { prepareNocks, clearNocks } from '../nockRoutes'; | ||
|
||
beforeEach(() => { | ||
clearNocks(); | ||
}); | ||
|
||
describe('Stakeholder', () => { | ||
const imageFixturePath = `images/organization.png`; | ||
return it(`stakeholder test`, () => { | ||
const path = `/stakeholder/${stakeholder.id}`; | ||
cy.fixture(imageFixturePath).then((image) => { | ||
const blob = Cypress.Blob.base64StringToBlob(image, 'images/png'); | ||
const photo_url = Cypress.Blob.createObjectURL(blob); | ||
prepareNocks({ stakeholder: { ...stakeholder, photo_url } }); | ||
}); | ||
|
||
cy.task('nockIntercept', { | ||
hostname: 'https://dev-k8s.treetracker.org', | ||
method: 'get', | ||
path: `/query/v2/stakeholder/${stakeholder.id}`, | ||
statusCode: 200, | ||
body: stakeholder, | ||
}); | ||
|
||
cy.task('nockIntercept', { | ||
hostname: 'https://dev-k8s.treetracker.org', | ||
method: 'get', | ||
path: '/query/v2/trees?stakeholder_id=1', | ||
statusCode: 200, | ||
body: { total: 1, offset: 0, limit: 4, trees: [exampleTreeData] }, | ||
}); | ||
|
||
cy.task('nockIntercept', { | ||
hostname: 'https://dev-k8s.treetracker.org', | ||
method: 'get', | ||
path: '/query/v2/planters?stakeholder_id=1', | ||
statusCode: 200, | ||
body: { total: 1, offset: 0, limit: 4, planters: [planter] }, | ||
}); | ||
|
||
cy.task('nockIntercept', { | ||
hostname: 'https://dev-k8s.treetracker.org', | ||
method: 'get', | ||
path: '/query/v2/species?stakeholder_id=1', | ||
statusCode: 200, | ||
body: { total: 1, offset: 0, limit: 4, species: [species] }, | ||
}); | ||
|
||
cy.visit(path, { | ||
failOnStatusCode: false, | ||
}); | ||
|
||
cy.url().should('include', '/stakeholder'); | ||
cy.screenshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"id": 1, | ||
"type": "organization", | ||
"org_name": "180Earth", | ||
"first_name": "John", | ||
"last_name": "Doe", | ||
"email": "[email protected]", | ||
"phone": "1234567890", | ||
"website": "www.180earth.com", | ||
"logo_url": "https://180.earth/wp-content/uploads/2020/01/Asset-1.png", | ||
"map": "Shirimatunda, Tanzania", | ||
"created_at": "November 11, 2019", | ||
"updated_at": "April 1, 2024", | ||
"active": "true", | ||
"entity_id": 1 | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The organization mock json is deprecated, please create a new fixture (under fixture folder) json file for stakeholder , the spec of stakeholder is defined in our query api doc here:
https://github.com/Greenstand/treetracker-query-api/blob/fa194cb4a274ee688c2b26b58596147368d08b9e/docs/api/spec/query-api.yaml#L1542-L1559