-
Notifications
You must be signed in to change notification settings - Fork 2
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: support pushing app by app id instead of app version id #45
Merged
tsemachLi
merged 5 commits into
master
from
feat/tsemach/support_pushing_code_by_app_id
Oct 19, 2023
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function makeModuleNameMapper(srcPath, tsconfigPath) { | ||
// Get paths from tsconfig | ||
const tsConfig = require(tsconfigPath); | ||
const {paths} = tsConfig.compilerOptions; | ||
|
||
const aliases = {}; | ||
|
||
// Iterate over paths and convert them into moduleNameMapper format | ||
Object.entries(paths).forEach(([item, itemPaths]) => { | ||
const key = `^${item.replace('/*', '/(.*)')}$`; | ||
const {jestPath, basePath} = srcPath[itemPaths[0].split('/')[1]]; | ||
const path = paths[item][0].replace(basePath, '').replace('*', '$1'); | ||
aliases[key] = jestPath + '/' + path; | ||
}); | ||
return aliases; | ||
} | ||
|
||
const TS_CONFIG_PATH = './tsconfig.json'; | ||
const SRC_PATH_MAPPING = { | ||
src: {jestPath: '<rootDir>/src', basePath: './src/'}, | ||
test: {jestPath: '<rootDir>/test', basePath: './test/'}, | ||
}; | ||
|
||
module.exports = { | ||
moduleNameMapper: makeModuleNameMapper(SRC_PATH_MAPPING, TS_CONFIG_PATH), | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
setupFiles: ['<rootDir>/test/test-setup.ts'], | ||
testPathIgnorePatterns: ['/node_modules/', '/dist/'], | ||
coverageReporters: ['json', 'lcov'], | ||
coveragePathIgnorePatterns: [ | ||
'/node_modules/', | ||
'<rootDir>/src/types', | ||
'<rootDir>/src/dotenv-override.ts', | ||
'<rootDir>/src/utils/validation-utils.ts', | ||
], | ||
clearMocks: true, | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/test/jest.tsconfig.json', | ||
}, | ||
}, | ||
testTimeout: 10000, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
// eslint-disable-next-line node/no-extraneous-import,n/no-extraneous-import | ||
import { describe, expect, it, jest } from '@jest/globals'; | ||
|
||
import { APP_VERSION_STATUS } from 'consts/app-versions'; | ||
import * as appVersionService from 'services/app-versions-service'; | ||
|
||
const appId = 1; | ||
|
||
const appWithDraftsVersions = [ | ||
{ | ||
id: 1, | ||
name: 'name', | ||
versionNumber: 'versionNumber', | ||
appId: appId, | ||
status: APP_VERSION_STATUS.DRAFT, | ||
}, | ||
{ | ||
id: 2, | ||
name: 'name', | ||
versionNumber: 'versionNumber', | ||
appId: appId, | ||
status: APP_VERSION_STATUS.DRAFT, | ||
}, | ||
]; | ||
|
||
const appWithLiveVersion = [ | ||
{ | ||
id: 1, | ||
name: 'name', | ||
versionNumber: 'versionNumber', | ||
appId: appId, | ||
status: APP_VERSION_STATUS.LIVE, | ||
}, | ||
]; | ||
|
||
const mockedListAppVersionsByAppId = jest.spyOn(appVersionService, 'listAppVersionsByAppId'); | ||
|
||
describe('AppVersionsService', () => { | ||
describe('defaultVersionByAppId', () => { | ||
it('should return the latest draft version for the app', async () => { | ||
mockedListAppVersionsByAppId.mockResolvedValue(appWithDraftsVersions); | ||
const defaultVersion = await appVersionService.defaultVersionByAppId(appId); | ||
expect(defaultVersion?.id).toEqual(2); | ||
}); | ||
|
||
it('should return the latest draft version for the app', async () => { | ||
mockedListAppVersionsByAppId.mockResolvedValue(appWithLiveVersion); | ||
const defaultVersion = await appVersionService.defaultVersionByAppId(appId); | ||
expect(defaultVersion?.id).not.toBeDefined(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { APP_VERSION_STATUS } from 'consts/app-versions'; | ||
import { listAppVersionsByAppIdUrl } from 'consts/urls'; | ||
import { execute } from 'services/api-service'; | ||
import { listAppVersionsSchema } from 'services/schemas/app-versions-schemas'; | ||
|
@@ -28,3 +29,9 @@ export const listAppVersionsByAppId = async (appId: AppId): Promise<Array<AppVer | |
throw new Error('Failed to list app versions.'); | ||
} | ||
}; | ||
|
||
export const defaultVersionByAppId = async (appId: AppId): Promise<AppVersion | undefined> => { | ||
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. add unit test |
||
const appVersions = await listAppVersionsByAppId(appId); | ||
const latestVersion = appVersions.sort((a, b) => b.id - a.id)[0]; | ||
return latestVersion.status === APP_VERSION_STATUS.DRAFT ? latestVersion : undefined; | ||
}; |
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,7 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["node", "jest"], | ||
"sourceMap": true | ||
} | ||
} |
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,6 @@ | ||
process.on('unhandledRejection', (err) => { | ||
console.log(err); | ||
throw new Error( | ||
"Got unhandled rejection (see above)! maybe you missed await on 'expect(..).rejects...' or 'expect(..).resolves...' ?" | ||
); | ||
}); |
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
Oops, something went wrong.
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.
Rename