-
-
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
base: v2
Are you sure you want to change the base?
Changes from 2 commits
bacd4e7
2ee8dda
94011f1
81753ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" | ||
} | ||
} | ||
|
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/1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I would use
instead of
to populate the stakeholder id in path dynamically. And this should apply to all other paths in this test file if you are modifying any of them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @yunchipang , thanks for your suggestion! I've just changed it. I agree it will make my code look cleaner. |
||
statusCode: 200, | ||
body: stakeholder, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: |
||
}); | ||
|
||
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(); | ||
}); | ||
}); |
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.
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.
nit: I'd rename this fixture to be
planter.json
(I assume he's a planter)