Skip to content
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

ref: Remove repositoryDeprecated from usePrefetchSingleFileComp #2870

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ const server = setupServer()
const mockSingularImpactedFilesData = {
owner: {
repository: {
__typename: 'Repository',
pull: {
compareWithBase: {
__typename: 'Comparison',
impactedFile: {
headName: 'file A',
hashedPath: 'hashed-path',
isNewFile: true,
isRenamedFile: false,
isDeletedFile: false,
isCriticalFile: false,
changeCoverage: 58.333333333333336,
headCoverage: {
percentCovered: 90.23,
},
Expand All @@ -32,18 +36,22 @@ const mockSingularImpactedFilesData = {
patchCoverage: {
percentCovered: 27.43,
},
changeCoverage: 58.333333333333336,
segments: {
results: [
{
header: '@@ -0,0 1,45 @@',
hasUnintendedChanges: false,
lines: [
{
baseNumber: null,
headNumber: '1',
baseCoverage: null,
headCoverage: 'H',
content: 'export default class Calculator {',
coverageInfo: {
hitCount: null,
hitUploadIds: [],
},
},
],
},
Expand Down Expand Up @@ -136,17 +144,23 @@ describe('NameColumn', () => {
expect(queryClient.getQueryData()).toStrictEqual({
fileLabel: 'New',
headName: 'file A',
hashedPath: 'hashed-path',
isCriticalFile: false,
segments: [
{
header: '@@ -0,0 1,45 @@',
hasUnintendedChanges: false,
lines: [
{
baseCoverage: null,
baseNumber: null,
content: 'export default class Calculator {',
headCoverage: 'H',
headNumber: '1',
coverageInfo: {
hitCount: null,
hitUploadIds: [],
},
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ const server = setupServer()
const mockSingularImpactedFilesData = {
owner: {
repository: {
__typename: 'Repository',
pull: {
compareWithBase: {
__typename: 'Comparison',
impactedFile: {
headName: 'file A',
hashedPath: 'hashed-path',
isNewFile: true,
isRenamedFile: false,
isDeletedFile: false,
Expand All @@ -37,13 +40,18 @@ const mockSingularImpactedFilesData = {
results: [
{
header: '@@ -0,0 1,45 @@',
hasUnintendedChanges: false,
lines: [
{
baseNumber: null,
headNumber: '1',
baseCoverage: null,
headCoverage: 'H',
content: 'export default class Calculator {',
coverageInfo: {
hitCount: null,
hitUploadIds: [],
},
},
],
},
Expand Down Expand Up @@ -135,17 +143,23 @@ describe('NameColumn', () => {
expect(queryClient.getQueryData()).toStrictEqual({
fileLabel: 'New',
headName: 'file A',
hashedPath: 'hashed-path',
isCriticalFile: false,
segments: [
{
header: '@@ -0,0 1,45 @@',
hasUnintendedChanges: false,
lines: [
{
baseCoverage: null,
baseNumber: null,
content: 'export default class Calculator {',
headCoverage: 'H',
headNumber: '1',
coverageInfo: {
hitCount: null,
hitUploadIds: [],
},
},
],
},
Expand Down
55 changes: 55 additions & 0 deletions src/services/pull/fragments.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { z } from 'zod'

export const HeaderOnPullFragment = `
fragment HeaderOnPullFragment on Pull {
pullId
Expand Down Expand Up @@ -253,6 +255,59 @@ fragment FileComparisonWithBase on Pull {
}
}`

const CoverageLineSchema = z.enum(['H', 'M', 'P'])

export const ComparisonSchema = z.object({
__typename: z.literal('Comparison'),
impactedFile: z
.object({
headName: z.string().nullable(),
hashedPath: z.string(),
isNewFile: z.boolean(),
isRenamedFile: z.boolean(),
isDeletedFile: z.boolean(),
isCriticalFile: z.boolean(),
changeCoverage: z.number().nullable(),
baseCoverage: z
.object({
percentCovered: z.number().nullable(),
})
.nullable(),
headCoverage: z
.object({
percentCovered: z.number().nullable(),
})
.nullable(),
patchCoverage: z
.object({
percentCovered: z.number().nullable(),
})
.nullable(),
segments: z.object({
results: z.array(
z.object({
header: z.string(),
hasUnintendedChanges: z.boolean(),
lines: z.array(
z.object({
baseNumber: z.string().nullable(),
headNumber: z.string().nullable(),
baseCoverage: CoverageLineSchema.nullable(),
headCoverage: CoverageLineSchema.nullable(),
content: z.string().nullable(),
coverageInfo: z.object({
hitCount: z.number().nullable(),
hitUploadIds: z.array(z.number()).nullable(),
}),
})
),
})
),
}),
})
.nullable(),
})

export const PullCompareWithBaseFragment = `
fragment PullCompareWithBaseFragment on Pull {
compareWithBase {
Expand Down
54 changes: 0 additions & 54 deletions src/services/pull/usePrefetchSingleFileComp.js

This file was deleted.