mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-09 09:20:54 +00:00
UBERF-11206: Few more fixes related to Github (#9117)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
a9cc6fef61
commit
9c416cb841
16
packages/core/src/__tests__/contexts.test.ts
Normal file
16
packages/core/src/__tests__/contexts.test.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { MeasureMetricsContext } from '../measurements'
|
||||
|
||||
describe('context tests', () => {
|
||||
it('check withLog proper catch', async () => {
|
||||
const ctx = new MeasureMetricsContext('test', {})
|
||||
|
||||
try {
|
||||
await ctx.withLog('failed op', {}, async () => {
|
||||
throw new Error('failed')
|
||||
})
|
||||
expect(true).toBe(false)
|
||||
} catch (err: any) {
|
||||
expect(err.message).toBe('failed')
|
||||
}
|
||||
})
|
||||
})
|
@ -168,7 +168,9 @@ export class MeasureMetricsContext implements MeasureContext {
|
||||
): Promise<T> {
|
||||
const st = platformNow()
|
||||
const r = this.with(name, params, op, fullParams)
|
||||
void r.finally(() => {
|
||||
r.catch(() => {
|
||||
// Ignore logging errors to prevent unhandled rejections
|
||||
}).finally(() => {
|
||||
this.logger.logOperation(name, platformNowDiff(st), { ...params, ...fullParams })
|
||||
})
|
||||
return r
|
||||
|
@ -20,6 +20,10 @@ describe('makeRank', () => {
|
||||
expect(makeRank(undefined, undefined)).toBe('0|hzzzzz:')
|
||||
})
|
||||
|
||||
it('check rank on empty string', () => {
|
||||
expect(makeRank(undefined, '')).toBe('0|hzzzzz:')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['0|hzzzzz:', '0|i00007:'],
|
||||
['0|i00007:', '0|i0000f:'],
|
||||
|
@ -35,6 +35,12 @@ export function genRanks (count: number): Rank[] {
|
||||
/** @public */
|
||||
export function makeRank (prev: Rank | undefined, next: Rank | undefined): Rank {
|
||||
try {
|
||||
if (prev != null && prev.trim() === '') {
|
||||
prev = undefined
|
||||
}
|
||||
if (next != null && next.trim() === '') {
|
||||
next = undefined
|
||||
}
|
||||
if (prev !== undefined && next !== undefined) {
|
||||
const prevLexoRank = LexoRank.parse(prev)
|
||||
const nextLexoRank = LexoRank.parse(next)
|
||||
|
@ -99,7 +99,7 @@ export abstract class IssueSyncManagerBase {
|
||||
// Find Assignees and reviewers
|
||||
const assignees: PersonId[] = []
|
||||
|
||||
for (const o of issue.assignees.nodes) {
|
||||
for (const o of issue.assignees.nodes ?? []) {
|
||||
const acc = await this.provider.getAccount(o)
|
||||
if (acc !== undefined) {
|
||||
assignees.push(acc)
|
||||
@ -477,7 +477,7 @@ export abstract class IssueSyncManagerBase {
|
||||
: undefined
|
||||
// Check external
|
||||
|
||||
const currentAssignees = issueExternal.assignees.nodes.map((it) => it.id)
|
||||
const currentAssignees = (issueExternal.assignees.nodes ?? []).map((it) => it.id)
|
||||
currentAssignees.sort((a, b) => a.localeCompare(b))
|
||||
|
||||
issueUpdate.assigneeIds = info !== undefined ? [info.id] : []
|
||||
|
@ -299,7 +299,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
|
||||
async getReviewers (issue: PullRequestExternalData): Promise<PersonId[]> {
|
||||
// Find Assignees and reviewers
|
||||
const ids: UserInfo[] = issue.reviewRequests.nodes.map((it: any) => it.requestedReviewer)
|
||||
const ids: UserInfo[] = (issue.reviewRequests.nodes ?? []).map((it: any) => it.requestedReviewer)
|
||||
|
||||
const values: PersonId[] = []
|
||||
|
||||
@ -310,7 +310,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
}
|
||||
}
|
||||
|
||||
for (const n of issue.latestReviews.nodes) {
|
||||
for (const n of issue.latestReviews.nodes ?? []) {
|
||||
const acc = await this.provider.getAccount(n.author)
|
||||
if (acc !== undefined) {
|
||||
values.push(acc)
|
||||
@ -629,14 +629,14 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
const approvedOrChangesRequested = new Map<PersonId, PullRequestReviewState>()
|
||||
const reviewStates = new Map<PersonId, PullRequestReviewState[]>()
|
||||
|
||||
const sortedReviews: (Review & { date: number })[] = external.reviews.nodes
|
||||
const sortedReviews: (Review & { date: number })[] = (external.reviews.nodes ?? [])
|
||||
.filter((it) => it != null)
|
||||
.map((it) => ({
|
||||
...it,
|
||||
date: new Date(it.updatedAt ?? it.submittedAt ?? it.createdAt).getTime()
|
||||
}))
|
||||
|
||||
for (const it of external.latestReviews.nodes) {
|
||||
for (const it of external.latestReviews.nodes ?? []) {
|
||||
if (sortedReviews.some((qt) => it.id === qt.id)) {
|
||||
continue
|
||||
}
|
||||
@ -700,7 +700,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
const changeRequestPersons = await this.getPersonsFromId(Array.from(changeRequestPersonsIds))
|
||||
|
||||
let allResolved = true
|
||||
for (const r of external.reviewThreads.nodes) {
|
||||
for (const r of external.reviewThreads.nodes ?? []) {
|
||||
if (!r.isResolved) {
|
||||
allResolved = false
|
||||
for (const c of changeRequestPersons) {
|
||||
@ -1209,11 +1209,11 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
if (ext == null) {
|
||||
continue
|
||||
}
|
||||
if (ext.reviews.nodes.length < ext.reviews.totalCount) {
|
||||
if ((ext.reviews.nodes ?? []).length < ext.reviews.totalCount) {
|
||||
// TODO: We need to fetch missing items.
|
||||
}
|
||||
|
||||
if (ext.reviewThreads.nodes.length < ext.reviewThreads.totalCount) {
|
||||
if ((ext.reviewThreads.nodes ?? []).length < ext.reviewThreads.totalCount) {
|
||||
// TODO: We need to fetch missing items.
|
||||
}
|
||||
|
||||
@ -1225,10 +1225,10 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
repo,
|
||||
github.class.GithubReview,
|
||||
{},
|
||||
(ext) => ext.reviews.nodes
|
||||
(ext) => ext.reviews.nodes ?? []
|
||||
)
|
||||
await syncDerivedDocuments(derivedClient, d, ext, prj, repo, github.class.GithubReviewThread, {}, (ext) =>
|
||||
ext.reviewThreads.nodes.map((it) => ({
|
||||
(ext.reviewThreads.nodes ?? []).map((it) => ({
|
||||
...it,
|
||||
url: it.id,
|
||||
createdAt: new Date(it.comments.nodes[0].createdAt ?? Date.now()).toISOString(),
|
||||
|
Loading…
Reference in New Issue
Block a user