Skip to content

Commit

Permalink
included attchments test
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkrishnan committed Oct 3, 2024
1 parent ecd9601 commit f8becf0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"devDependencies": {
"@cap-js/audit-logging": "^0.8.0",
"@cap-js/change-tracking": "^1.0.6",
"@cap-js/attachments": "^1.1.6",
"@cap-js/sqlite": "^1.0.1",
"@sap/ux-specification": "^1.108.4",
"axios": "^1.4.0",
Expand All @@ -32,7 +33,7 @@
"test": "npx jest --silent",
"add-change-tracking": "npm add @cap-js/change-tracking && cp xmpls/change-tracking.cds ./srv",
"add-telemetry": "npm add @cap-js/telemetry",
"add-attachments": "npm add @cap-js/attachments && cp -r xmpls/attachments.cds ./db && cp xmpls/attachments.test.js ./test",
"add-attachments": "npm add @cap-js/attachments && cp -r xmpls/attachments.cds ./srv",
"add-notifications": "npm add @cap-js/notifications && cp xmpls/alert-notifications.js ./srv && cp xmpls/notification-types.json ./srv",
"add-audit-log": "npm add @cap-js/audit-logging && cp xmpls/data-privacy.cds ./srv",
"add-remote-service": "./.github/workflows/checkout remote-service",
Expand Down
16 changes: 13 additions & 3 deletions xmpls/attachments.test.js → test/attachments.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
const cds = require('@sap/cds')
const { GET, POST, PUT, DELETE , expect, axios} = cds.test(__dirname + '/..', '--with-mocks')
const { setup, reset} = require("../.github/workflows/checkout");
const { createReadStream } = cds.utils.fs;
const { join } = cds.utils.path;
axios.defaults.auth = { username: 'alice' }

jest.setTimeout(11111)

beforeAll(async()=> {
await setup("xmpls", ["attachments.cds"])
})

afterAll(async() => {
await reset("srv", ["attachments.cds"])
})

const { GET, POST, PUT, DELETE , expect, axios} = cds.test(__dirname + '/..', '--with-mocks')
axios.defaults.auth = { username: 'alice' }

describe('Test attachments service', () => {
let draftId = null;
let docId = null;
Expand Down Expand Up @@ -39,7 +49,7 @@ describe('Test attachments service', () => {
)


const content = createReadStream(join(__dirname, "../xmpls/SolarPanelReport.pdf"));
const content = createReadStream(join(__dirname, "/../xmpls/SolarPanelReport.pdf"));
const attachRes = await POST(`/odata/v4/processor/Incidents(ID=${draftId},IsActiveEntity=false)/attachments`,
{
up__ID: draftId,
Expand Down
2 changes: 1 addition & 1 deletion xmpls/attachments.cds
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

using { sap.capire.incidents as my } from './schema';
using { sap.capire.incidents as my } from '../db/schema';
using { Attachments } from '@cap-js/attachments';

extend my.Incidents with {
Expand Down

0 comments on commit f8becf0

Please sign in to comment.