This repository has been archived by the owner on Mar 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from RaenonX-DL/dev
v2.15.0 Release
- Loading branch information
Showing
22 changed files
with
228 additions
and
23 deletions.
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
Submodule api-def
updated
9 files
+1 −0 | api/endpoints.ts | |
+6 −0 | api/other/lang.ts | |
+3 −1 | api/tier/notes/payload.ts | |
+3 −1 | api/tier/notes/response.ts | |
+0 −1 | resources/types.ts | |
+6 −1 | resources/types/common/text.ts | |
+0 −11 | resources/types/common/unit.ts | |
+3 −2 | resources/types/common/unitInfo.ts | |
+2 −2 | resources/types/simpleInfo.ts |
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
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
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
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,95 @@ | ||
import { | ||
ApiEndPoints, | ||
ApiResponseCode, | ||
SupportedLanguages, | ||
UnitTierNoteSingleResponse, | ||
} from '../../../../api-def/api'; | ||
import {Application, createApp} from '../../../../app'; | ||
import {TierNote, UnitTierNote} from '../model'; | ||
|
||
|
||
describe('Single unit tier note handler', () => { | ||
let app: Application; | ||
|
||
beforeAll(async () => { | ||
app = await createApp(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await app.reset(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await app.close(); | ||
}); | ||
|
||
it('returns null if no corresponding tier note available yet', async () => { | ||
const response = await app.app.inject().get(ApiEndPoints.TIER_UNIT).query({ | ||
uid: '', | ||
lang: SupportedLanguages.CHT, | ||
unitId: 10950101, | ||
}); | ||
expect(response.statusCode).toBe(200); | ||
|
||
const json: UnitTierNoteSingleResponse = response.json() as UnitTierNoteSingleResponse; | ||
expect(json.code).toBe(ApiResponseCode.SUCCESS); | ||
expect(json.success).toBe(true); | ||
expect(json.data).toStrictEqual(null); | ||
}); | ||
|
||
it('returns data in specified language', async () => { | ||
const dataArray = [ | ||
new UnitTierNote({ | ||
unitId: 10950101, | ||
points: [], | ||
tier: {conAi: new TierNote({ranking: 'S', note: {[SupportedLanguages.CHT]: 'A'}, isCompDependent: true})}, | ||
lastUpdateEpoch: 0, | ||
}), | ||
].map((entry) => entry.toObject()); | ||
await UnitTierNote.getCollection(app.mongoClient).insertMany(dataArray); | ||
|
||
const response = await app.app.inject().get(ApiEndPoints.TIER_UNIT).query({ | ||
uid: '', | ||
lang: SupportedLanguages.CHT, | ||
unitId: 10950101, | ||
}); | ||
expect(response.statusCode).toBe(200); | ||
|
||
const json: UnitTierNoteSingleResponse = response.json() as UnitTierNoteSingleResponse; | ||
expect(json.code).toBe(ApiResponseCode.SUCCESS); | ||
expect(json.success).toBe(true); | ||
expect(json.data).toStrictEqual({ | ||
points: [], | ||
tier: {conAi: {ranking: 'S', note: 'A', isCompDependent: true}}, | ||
lastUpdateEpoch: 0, | ||
}); | ||
}); | ||
|
||
it('returns data in alternative language if desired one does not exist', async () => { | ||
const dataArray = [ | ||
new UnitTierNote({ | ||
unitId: 10950101, | ||
points: [], | ||
tier: {conAi: new TierNote({ranking: 'S', note: {[SupportedLanguages.CHT]: 'A'}, isCompDependent: true})}, | ||
lastUpdateEpoch: 0, | ||
}), | ||
].map((entry) => entry.toObject()); | ||
await UnitTierNote.getCollection(app.mongoClient).insertMany(dataArray); | ||
|
||
const response = await app.app.inject().get(ApiEndPoints.TIER_UNIT).query({ | ||
uid: '', | ||
lang: SupportedLanguages.EN, | ||
unitId: 10950101, | ||
}); | ||
expect(response.statusCode).toBe(200); | ||
|
||
const json: UnitTierNoteSingleResponse = response.json() as UnitTierNoteSingleResponse; | ||
expect(json.code).toBe(ApiResponseCode.SUCCESS); | ||
expect(json.success).toBe(true); | ||
expect(json.data).toStrictEqual({ | ||
points: [], | ||
tier: {conAi: {ranking: 'S', note: 'A', isCompDependent: true}}, | ||
lastUpdateEpoch: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {UnitTierNoteEditPayload} from '../../../../api-def/api'; | ||
import {processTierNoteSinglePayload} from '../../../../utils/payload/tier'; | ||
import {HandlerParams} from '../../../lookup'; | ||
import {TierNoteController} from '../controller'; | ||
import {UnitTierNoteSingleResponse} from './response'; | ||
|
||
|
||
export const handleTierNoteSingle = async ({ | ||
payload, | ||
mongoClient, | ||
}: HandlerParams<UnitTierNoteEditPayload>): Promise<UnitTierNoteSingleResponse> => { | ||
payload = processTierNoteSinglePayload(payload); | ||
|
||
const data = await TierNoteController.getUnitTierNoteSingle(mongoClient, payload.lang, payload.unitId); | ||
|
||
return new UnitTierNoteSingleResponse({data}); | ||
}; |
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,40 @@ | ||
import { | ||
ApiResponseCode, | ||
BaseResponse, | ||
UnitTierNote, | ||
UnitTierNoteSingleResponse as UnitTierNoteSingleResponseApi, | ||
} from '../../../../api-def/api'; | ||
import {ApiResponse} from '../../../../base/response'; | ||
|
||
|
||
type UnitTierNoteSingleResponseOptions = Omit<UnitTierNoteSingleResponseApi, keyof BaseResponse>; | ||
|
||
/** | ||
* API response class for the endpoint to get the unit tier notes of a unit. | ||
*/ | ||
export class UnitTierNoteSingleResponse extends ApiResponse { | ||
data: UnitTierNote | null; | ||
|
||
/** | ||
* Construct a single unit tier notes endpoint API response. | ||
* | ||
* @param {UnitTierNoteEditResponseOptions} options options to construct a single unit tier notes response | ||
*/ | ||
constructor(options: UnitTierNoteSingleResponseOptions) { | ||
const responseCode = ApiResponseCode.SUCCESS; | ||
|
||
super(responseCode); | ||
|
||
this.data = options.data; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
toJson(): UnitTierNoteSingleResponseApi { | ||
return { | ||
...super.toJson(), | ||
data: this.data, | ||
}; | ||
} | ||
} |
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.