-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add scripts for test pipeline #47
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37e0483
copy scripts & tests
navinkrishnan 6fd38b1
npm script to add all xmpls
navinkrishnan 55a491c
additional tests for xmpls
navinkrishnan 86584fd
copy scripts for tests
navinkrishnan 1bc7739
copy test scripts
navinkrishnan 8d1fc99
scripts
navinkrishnan 6f13d18
Merge branch 'main' into add-scripts-test
navinkrishnan 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const cds = require("@sap/cds"); | ||
const { GET, POST, PATCH, DELETE, expect, axios, assert } = cds.test(__dirname + '/..', '--with-mocks') | ||
|
||
axios.defaults.auth = { username: "alice" }; | ||
describe("Integration Test for AuditLog", () => { | ||
let customerID,audit; | ||
beforeAll(async () => { | ||
audit = await cds.connect.to('audit-log') | ||
}); | ||
|
||
it("Should return list of Customers", async () => { | ||
const response = await GET("/odata/v4/processor/Customers"); | ||
|
||
audit.on('SensitiveDataRead', function (req) { | ||
const { event, data } = req | ||
assert.ok(event.includes("SensitiveDataRead")) | ||
}) | ||
expect(response.status).to.eql(200); | ||
}); | ||
|
||
|
||
it("Should return list of Customers data by explicitly selecting the fields", async () => { | ||
const response = await GET("/odata/v4/processor/Customers?$select=name"); | ||
expect(response.status).to.eql(200); | ||
}); | ||
|
||
|
||
it('Creating a customer with personal data', async () => { | ||
const response = await POST(`/odata/v4/admin/Customers`, { | ||
ID: "{{$guid}}", | ||
firstName: "Bob", | ||
lastName: "Builder", | ||
email: "[email protected]" | ||
}); | ||
audit.on('PersonalDataModified', function (req) { | ||
const { event, data } = req | ||
assert.ok(event.includes("PersonalDataModified")) | ||
}) | ||
customerID = response.data.ID; | ||
expect(response.status).to.equal(201); | ||
}); | ||
|
||
|
||
it('Updating a customer with personal data details', async () => { | ||
const audit = await cds.connect.to('audit-log') | ||
audit.on('PersonalDataModified', function (req) { | ||
const { event, data } = req | ||
assert.ok(event.includes("PersonalDataModified")) | ||
}) | ||
const response = await PATCH(`/odata/v4/admin/Customers('${customerID}')`, { | ||
"addresses": [ | ||
{ | ||
"city": "Walldorf", | ||
"postCode": "69190", | ||
"streetAddress": "Dietmar-Hopp-Allee 16" | ||
} | ||
] | ||
}); | ||
expect(response.status).to.equal(200); | ||
}); | ||
|
||
}); |
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,133 @@ | ||
const cds = require("@sap/cds"); | ||
const { GET, POST, PATCH, DELETE , expect, axios} = cds.test(__dirname + '/..', '--with-mocks') | ||
|
||
describe("Integration Test for ChangeTracking", () => { | ||
let draftId,incidentId; | ||
axios.defaults.auth = { username: "alice" }; | ||
let processorService = null; | ||
let ChangeView = null; | ||
beforeAll(async () => { | ||
processorService = await cds.connect.to('ProcessorService'); | ||
ChangeView = processorService.entities.ChangeView; | ||
}); | ||
it('Create an incident ', async () => { | ||
const { status, statusText, data } = await POST(`/odata/v4/processor/Incidents`, { | ||
title: 'Urgent attention required !', | ||
status_code: 'N', | ||
"customer": {ID:"1004100"} | ||
}); | ||
draftId = data.ID; | ||
expect(status).to.equal(201); | ||
expect(statusText).to.equal('Created'); | ||
}); | ||
|
||
it('+ Activate the draft & check Urgency code as H using custom logic', async () => { | ||
const response = await POST( | ||
`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=false)/ProcessorService.draftActivate` | ||
); | ||
expect(response.status).to.eql(201); | ||
expect(response.data.urgency_code).to.eql('H'); | ||
}); | ||
|
||
it('+ Test the incident status', async () => { | ||
const { status, data: { status_code, ID } } = await GET(`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=true)`); | ||
incidentId = ID; | ||
expect(status).to.eql(200); | ||
expect(status_code).to.eql('N'); | ||
}); | ||
|
||
it('+ Test the title detail in ChangeView', async () => { | ||
const response = await GET(`/odata/v4/processor/Incidents?$filter=ID eq ${draftId}`); | ||
const incidentChanges = await SELECT.from(ChangeView).where({ | ||
entity: "sap.capire.incidents.Incidents", | ||
attribute: "title", | ||
}) | ||
expect(incidentChanges.length).to.equal(1); | ||
const incidentChange = incidentChanges[0]; | ||
expect(incidentChange.entityKey).to.equal(draftId); | ||
expect(incidentChange.attribute).to.equal("title"); | ||
expect(incidentChange.modification).to.equal("create"); | ||
expect(incidentChange.valueChangedFrom).to.equal(""); | ||
expect(incidentChange.valueChangedTo).to.equal("Urgent attention required !"); | ||
}); | ||
|
||
it('+ Test the status detail in ChangeView', async () => { | ||
const response = await GET(`/odata/v4/processor/Incidents?$filter=ID eq ${draftId}`); | ||
const incidentChanges = await SELECT.from(ChangeView).where({ | ||
entity: "sap.capire.incidents.Incidents", | ||
attribute: "status", | ||
}) | ||
expect(incidentChanges.length).to.equal(1); | ||
const incidentChange = incidentChanges[0]; | ||
expect(incidentChange.entityKey).to.equal(draftId); | ||
expect(incidentChange.attribute).to.equal("status"); | ||
expect(incidentChange.modification).to.equal("create"); | ||
expect(incidentChange.valueChangedFrom).to.equal(""); | ||
expect(incidentChange.valueChangedTo).to.equal("N"); | ||
}); | ||
|
||
it('+ Test the customer detail in ChangeView', async () => { | ||
const response = await GET(`/odata/v4/processor/Incidents?$filter=ID eq ${draftId}`); | ||
const incidentChanges = await SELECT.from(ChangeView).where({ | ||
entity: "sap.capire.incidents.Incidents", | ||
attribute: "customer", | ||
}) | ||
expect(incidentChanges.length).to.equal(1); | ||
const incidentChange = incidentChanges[0]; | ||
expect(incidentChange.entityKey).to.equal(draftId); | ||
expect(incidentChange.attribute).to.equal("customer"); | ||
expect(incidentChange.modification).to.equal("create"); | ||
expect(incidentChange.valueChangedFrom).to.equal(""); | ||
expect(incidentChange.valueChangedTo).to.equal("Sunny Sunshine"); | ||
}); | ||
|
||
describe("Test Changes for Update Incident", () => { | ||
it(`Should Close the Incident-${draftId}`, async ()=>{ | ||
const {status} = await POST(`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=true)/ProcessorService.draftEdit`, | ||
{ | ||
"PreserveChanges": true | ||
}); | ||
expect(status).to.equal(201); | ||
}); | ||
it(`Should Close the Incident-${draftId}`, async ()=>{ | ||
const {status } = await PATCH(`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=false)`,{status_code: 'C'}); | ||
expect(status).to.equal(200); | ||
}); | ||
it('+ Activate the draft & check Status code as C using custom logic', async () => { | ||
const response = await POST( | ||
`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=false)/ProcessorService.draftActivate` | ||
); | ||
expect(response.status).to.eql(200); | ||
}); | ||
it('+ Test the status detail in ChangeView', async () => { | ||
const response = await GET(`/odata/v4/processor/Incidents?$filter=ID eq ${draftId}`); | ||
const incidentChanges = await SELECT.from(ChangeView).where({ | ||
entity: "sap.capire.incidents.Incidents", | ||
attribute: "status", | ||
modification: 'update', | ||
}) | ||
expect(incidentChanges.length).to.equal(1); | ||
const incidentChange = incidentChanges[0]; | ||
expect(incidentChange.entityKey).to.equal(draftId); | ||
expect(incidentChange.attribute).to.equal("status"); | ||
expect(incidentChange.modification).to.equal("update"); | ||
expect(incidentChange.valueChangedFrom).to.equal("N"); | ||
expect(incidentChange.valueChangedTo).to.equal("C"); | ||
}); | ||
}); | ||
|
||
describe("Test Changes for Delete Incident", () => { | ||
it('- Delete the Incident', async () => { | ||
const response = await DELETE(`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=true)`); | ||
expect(response.status).to.eql(204); | ||
}); | ||
|
||
it('+ Test the status detail in ChangeView', async () => { | ||
const incidentChanges = await SELECT.from(ChangeView).where({ | ||
entity: "sap.capire.incidents.Incidents", | ||
attribute: "status", | ||
}) | ||
expect(incidentChanges.length).to.equal(0); | ||
}); | ||
}); | ||
}); |
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
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,106 @@ | ||
const cds = require("@sap/cds"); | ||
const { GET, POST, PATCH, DELETE, expect, axios } = cds.test(__dirname + '/..', '--with-mocks') | ||
|
||
describe("Integration Test for Eventing", () => { | ||
let draftId,incidentId; | ||
axios.defaults.auth = { username: "alice" }; | ||
describe("GET should return 200", () => { | ||
|
||
it("Should return list of Business Partners", async () => { | ||
const response = await GET("/odata/v4/api-business-partner/A_BusinessPartner"); | ||
expect(response.status).to.eql(200); | ||
}); | ||
|
||
it("Should return list of Business Partners Address", async () => { | ||
const response = await GET("/odata/v4/api-business-partner/A_BusinessPartnerAddress"); | ||
expect(response.status).to.eql(200); | ||
}); | ||
it("Should return list of Business Partners Email Address", async () => { | ||
const response = await GET("/odata/v4/api-business-partner/A_AddressEmailAddress"); | ||
expect(response.status).to.eql(200); | ||
}); | ||
it("Should return list of Business Partners Address PhoneNumber", async () => { | ||
const response = await GET("/odata/v4/api-business-partner/A_AddressPhoneNumber"); | ||
expect(response.status).to.eql(200); | ||
}); | ||
}); | ||
|
||
describe('Draft Choreography APIs', () => { | ||
it('Create an incident ', async () => { | ||
const { status, statusText, data } = await POST(`/odata/v4/processor/Incidents`, { | ||
title: 'Urgent attention required !', | ||
status_code: 'N', | ||
"customer": {ID:"1004100"} | ||
}); | ||
draftId = data.ID; | ||
expect(status).to.equal(201); | ||
expect(statusText).to.equal('Created'); | ||
}); | ||
it('+ Activate the draft & check Urgency code as H using custom logic', async () => { | ||
const response = await POST( | ||
`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=false)/ProcessorService.draftActivate` | ||
); | ||
expect(response.status).to.eql(201); | ||
expect(response.data.urgency_code).to.eql('H'); | ||
}); | ||
it('+ Test the customer detail', async () => { | ||
const response = await GET(`/odata/v4/processor/Incidents?$filter=ID eq ${draftId}`); | ||
expect(response.status).to.eql(200); | ||
expect(response.data.value).to.exist; | ||
expect(response.data.value[0]).to.contains({ | ||
"customer_ID": "1004100" | ||
}); | ||
incidentId = response.data.ID; | ||
}); | ||
|
||
describe("Create annd Update Business Partner", () => { | ||
it("Update Business Partner", async () => { | ||
const response = await PATCH( | ||
`/odata/v4/api-business-partner/A_BusinessPartner('1004100')`, | ||
{ | ||
to_BusinessPartnerAddress: [{ | ||
AddressID: "457", | ||
to_EmailAddress:[{ | ||
AddressID: "457", | ||
Person: "johnson", | ||
OrdinalNumber: "334", | ||
EmailAddress: "[email protected]" | ||
}] | ||
}] | ||
} | ||
); | ||
expect(response.status).to.eql(200); | ||
}); | ||
describe("Verify the updated Business Partner", () => { | ||
it("Verify the Address of Business Partner", async () => { | ||
const response = await GET(`/odata/v4/api-business-partner/A_BusinessPartnerAddress?$filter=BusinessPartner eq '1004100'`); | ||
expect(response.status).to.eql(200); | ||
expect(response.data.value).to.exist; | ||
expect(response.data.value[0]).to.contains({ | ||
AddressID: "457", | ||
}); | ||
}); | ||
|
||
it("Verify the Email address of Business Partner", async () => { | ||
const response = await GET(`/odata/v4/api-business-partner/A_AddressEmailAddress?$filter=AddressID eq '457'`); | ||
expect(response.status).to.eql(200); | ||
expect(response.data.value).to.exist; | ||
expect(response.data.value[0]).to.contains({ | ||
AddressID: "457", | ||
Person: "johnson", | ||
OrdinalNumber: "334", | ||
EmailAddress: "[email protected]" | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
it(`Should Close the Incident-${draftId}`, async ()=>{ | ||
const {status} = await POST(`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=true)/ProcessorService.draftEdit`, | ||
{ | ||
"PreserveChanges": true | ||
}); | ||
expect(status).to.equal(201); | ||
}); | ||
}); | ||
}); |
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.
why is the --with-mocks options needed?
It's only needed for the remote service consumption, correct?
Is it so that other test still work once remote service consumption is added?
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.
@DanSchlachter Yes, it was required to run along with other tests. So far, there are no conflicts.
add-all-xmpls
script will copy multiple samples (Remote service, messaging, audit log, change tracking) and runs all the test at once.