Skip to content

Commit

Permalink
Merge branch 'Test_Malware_Scanning' of https://github.com/cap-js/att…
Browse files Browse the repository at this point in the history
…achments into Test_Malware_Scanning
  • Loading branch information
SoujitD-SAP committed Oct 17, 2024
2 parents b7f2dd8 + 1029c86 commit e2f5dec
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/integration/attachments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory
incidentID = "3ccf474c-3881-44b7-99fb-59a2a4668418";
utils = new RequestSend(POST);
});

//Draft mode uploading attachment
it("Uploading attachment in draft mode with scanning enabled", async () => {
//function to upload attachment
let action = await POST.bind(
{},
`odata/v4/processor/Incidents(ID=${incidentID},IsActiveEntity=false)/attachments`,
Expand All @@ -45,6 +46,7 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory
);

try {
//trigger to upload attachment
await utils.draftModeActions(
"processor",
"Incidents",
Expand All @@ -56,18 +58,22 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory
expect(err).to.be.undefined;
}

//read attachments list for Incident
try {
const response = await GET(
`odata/v4/processor/Incidents(ID=${incidentID},IsActiveEntity=true)/attachments`
);
//the data should have only one attachment
expect(response.status).to.equal(200);
expect(response.data.value.length).to.equal(1);
//to make sure content is not read
expect(response.data.value[0].content).to.be.undefined;
sampleDocID = response.data.value[0].ID;
} catch (err) {
expect(err).to.be.undefined;
}

//read attachment in active table
try {
const response = await GET(
`odata/v4/processor/Incidents(ID=${incidentID},IsActiveEntity=true)/attachments(up__ID=${incidentID},ID=${sampleDocID},IsActiveEntity=true)/content`
Expand Down Expand Up @@ -109,7 +115,9 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory
}
});

//Deleting the attachment
it("Deleting the attachment", async () => {
//check the content of the uploaded attachment in main table
try {
const response = await GET(
`odata/v4/processor/Incidents(ID=${incidentID},IsActiveEntity=true)/attachments(up__ID=${incidentID},ID=${sampleDocID},IsActiveEntity=true)/content`
Expand All @@ -118,12 +126,13 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory
} catch (err) {
expect(err).to.be.undefined;
}

//delete attachment
let action = await DELETE.bind(
{},
`odata/v4/processor/Incidents_attachments(up__ID=${incidentID},ID=${sampleDocID},IsActiveEntity=false)`
);
try {
//trigger to delete attachment
await utils.draftModeActions(
"processor",
"Incidents",
Expand All @@ -135,16 +144,19 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory
expect(err).to.be.undefined;
}

//read attachments list for Incident
try {
const response = await GET(
`odata/v4/processor/Incidents(ID=${incidentID},IsActiveEntity=true)/attachments`
);
//the data should have no attachments
expect(response.status).to.equal(200);
expect(response.data.value.length).to.equal(0);
} catch (err) {
expect(err).to.be.undefined;
}

//content should not be there
try {
const response = await GET(

Check warning on line 161 in tests/integration/attachments.test.js

View workflow job for this annotation

GitHub Actions / lint

'response' is assigned a value but never used
`odata/v4/processor/Incidents(ID=${incidentID},IsActiveEntity=true)/attachments(up__ID=${incidentID},ID=${sampleDocID},IsActiveEntity=true)/content`
Expand Down

0 comments on commit e2f5dec

Please sign in to comment.