Skip to content

Commit 1d09e41

Browse files
authored
fix: outdated testing (#502)
* fix: outdated testing * fix: nor running workflow services * refactor: remove unused imports in object.spec.ts and api.ts * refactor: remove unused getIntent function from api service
1 parent 45d9e2d commit 1d09e41

File tree

6 files changed

+5
-41
lines changed

6 files changed

+5
-41
lines changed

.github/workflows/services.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
branches:
66
- main
77
paths:
8-
- "backend/**" # Only trigger on changes within auth or backend
9-
- "auth/**"
8+
- "apps/backend/**" # Only trigger on changes within auth or backend
9+
- "apps/auth/**"
1010
- ".github/**"
1111
pull_request:
1212
paths:
13-
- "backend/**" # Only trigger on changes within auth or backend
14-
- "auth/**"
13+
- "apps/backend/**" # Only trigger on changes within auth or backend
14+
- "apps/auth/**"
1515
- ".github/**"
1616
workflow_dispatch:
1717

apps/backend/__tests__/e2e/objects/nodes.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,10 @@ describe('Nodes', () => {
200200
})
201201
expect(processArchivalSpy).toHaveBeenCalledTimes(1)
202202

203-
const populateCachesSpy = jest
204-
.spyOn(ObjectUseCases, 'populateCaches')
205-
.mockResolvedValue()
206203
// Mock the callback execution of the event above
207204
await ObjectUseCases.onObjectArchived(cidToString(cid))
208205

209206
const metadata = await metadataRepository.getMetadata(cidToString(cid))
210-
expect(populateCachesSpy).toHaveBeenCalledWith(cidToString(cid))
211207
expect(metadata).toBeDefined()
212208
expect(metadata?.is_archived).toBe(true)
213209
})

apps/backend/__tests__/e2e/objects/object.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
import { uploadFile } from '../../utils/uploads.js'
1111
import { jest } from '@jest/globals'
1212
import { v4 } from 'uuid'
13-
import { downloadService } from '../../../src/infrastructure/services/download/index.js'
14-
import { Readable } from 'stream'
1513
import { ForbiddenError } from '../../../src/errors/index.js'
1614
import { nodesRepository } from '../../../src/infrastructure/repositories/index.js'
1715

@@ -72,14 +70,6 @@ describe('Object', () => {
7270
})
7371

7472
it('isArchived should return true for archived object', async () => {
75-
const downloadSpy = jest.spyOn(downloadService, 'download')
76-
downloadSpy.mockResolvedValueOnce(
77-
new Readable({
78-
read: async function () {
79-
this.push(null)
80-
},
81-
}),
82-
)
8373
await nodesRepository.saveNode({
8474
cid: fileCid,
8575
root_cid: fileCid,
@@ -94,7 +84,6 @@ describe('Object', () => {
9484
await ObjectUseCases.onObjectArchived(fileCid)
9585
const isArchived = await ObjectUseCases.isArchived(fileCid)
9686
expect(isArchived).toBe(true)
97-
expect(downloadSpy).toHaveBeenCalledTimes(1)
9887
})
9988

10089
it('should get listed in user objects', async () => {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
ALTER TABLE nodes ADD CONSTRAINT nodes_pkey PRIMARY KEY (cid);

apps/backend/src/infrastructure/repositories/objects/nodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const saveNodes = async (nodes: Node[]) => {
4242

4343
return db.query({
4444
text: pgFormat(
45-
'INSERT INTO nodes (cid, root_cid, head_cid, type, encoded_node, piece_index, piece_offset, block_published_on, tx_published_on) VALUES %L ON CONFLICT (cid) DO NOTHING',
45+
'INSERT INTO nodes (cid, root_cid, head_cid, type, encoded_node, piece_index, piece_offset, block_published_on, tx_published_on) VALUES %L',
4646
nodes.map((node) => [
4747
node.cid,
4848
node.root_cid,

apps/frontend/src/services/api.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
AccountModel,
55
ObjectInformation,
66
DownloadStatus,
7-
Intent,
87
} from '@auto-drive/models';
98
import { getAuthSession } from 'utils/auth';
109
import { uploadFileContent } from 'utils/file';
@@ -68,25 +67,6 @@ export const createApiService = ({
6867
throw new Error(`Network response was not ok: ${response.statusText}`);
6968
}
7069
},
71-
getIntent: async (intentId: string): Promise<Intent> => {
72-
const session = await getAuthSession();
73-
if (!session?.authProvider || !session.accessToken) {
74-
throw new Error('No session');
75-
}
76-
77-
const response = await fetch(`${apiBaseUrl}/intents/${intentId}`, {
78-
headers: {
79-
Authorization: `Bearer ${session.accessToken}`,
80-
'X-Auth-Provider': session.authProvider,
81-
},
82-
});
83-
84-
if (!response.ok) {
85-
throw new Error(`Network response was not ok: ${response.statusText}`);
86-
}
87-
88-
return response.json() as Promise<Intent>;
89-
},
9070
getAccount: async (): Promise<AccountInfo> => {
9171
const session = await getAuthSession();
9272
if (!session?.authProvider || !session.accessToken) {

0 commit comments

Comments
 (0)