1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
export const simpleViewerMock = {
__typename: 'RepositoryBlob',
id: '1',
name: 'some_file.js',
size: 123,
rawSize: 123,
rawTextBlob: 'raw content',
fileType: 'text',
language: 'javascript',
path: 'some_file.js',
webPath: 'some_file.js',
blamePath: 'blame/file.js',
editBlobPath: 'some_file.js/edit',
gitpodBlobUrl: 'https://gitpod.io#path/to/blob.js',
ideEditPath: 'some_file.js/ide/edit',
forkAndEditPath: 'some_file.js/fork/edit',
ideForkAndEditPath: 'some_file.js/fork/ide',
forkAndViewPath: 'some_file.js/fork/view',
codeNavigationPath: '',
projectBlobPathRoot: '',
environmentFormattedExternalUrl: '',
environmentExternalUrlForRouteMap: '',
canModifyBlob: true,
canCurrentUserPushToBranch: true,
archived: false,
storedExternally: false,
externalStorageUrl: '',
externalStorage: 'lfs',
rawPath: 'some_file.js',
replacePath: 'some_file.js/replace',
pipelineEditorPath: 'path/to/pipeline/editor',
simpleViewer: {
fileType: 'text',
tooLarge: false,
type: 'simple',
renderError: null,
},
richViewer: null,
};
export const richViewerMock = {
...simpleViewerMock,
richViewer: {
fileType: 'markup',
tooLarge: false,
type: 'rich',
renderError: null,
},
};
export const userPermissionsMock = {
pushCode: true,
forkProject: true,
downloadCode: true,
createMergeRequestIn: true,
};
export const projectMock = {
__typename: 'Project',
id: '1234',
userPermissions: userPermissionsMock,
pathLocks: {
nodes: [
{
id: 'test',
path: 'locked_file.js',
user: { id: '123', username: 'root' },
},
],
},
repository: {
empty: false,
},
};
export const userInfoMock = {
currentUser: {
id: '123',
gitpodEnabled: true,
preferencesGitpodPath: '/-/profile/preferences#user_gitpod_enabled',
profileEnableGitpodPath: '/-/profile?user%5Bgitpod_enabled%5D=true',
},
};
export const applicationInfoMock = { gitpodEnabled: true };
export const propsMock = { path: 'some_file.js', projectPath: 'some/path' };
export const refMock = 'default-ref';
export const refWithSpecialCharMock = 'feat/selected-#-ref-#';
export const encodedRefWithSpecialCharMock = 'feat/selected-%23-ref-%23';
export const blobControlsDataMock = {
id: '1234',
repository: {
blobs: {
nodes: [
{
id: '5678',
findFilePath: 'find/file.js',
blamePath: 'blame/file.js',
historyPath: 'history/file.js',
permalinkPath: 'permalink/file.js',
storedExternally: false,
externalStorage: '',
},
],
},
},
};
export const graphQLErrors = [
{
message: '14:failed to connect to all addresses.',
locations: [{ line: 16, column: 7 }],
path: ['project', 'repository', 'paginatedTree'],
extensions: { code: 'unavailable', gitaly_code: 14, service: 'git' },
},
];
export const propsForkInfo = {
projectPath: 'nataliia/myGitLab',
selectedBranch: 'main',
sourceName: 'gitLab',
sourcePath: 'gitlab-org/gitlab',
canSyncBranch: true,
aheadComparePath: '/nataliia/myGitLab/-/compare/main...ref?from_project_id=1',
behindComparePath: 'gitlab-org/gitlab/-/compare/ref...main?from_project_id=2',
createMrPath: 'path/to/new/mr',
};
export const propsConflictsModal = {
sourceDefaultBranch: 'branch-name',
sourceName: 'source-name',
sourcePath: 'path/to/project',
selectedBranch: 'my-branch',
};
export const paginatedTreeResponseFactory = ({
numberOfBlobs = 3,
numberOfTrees = 3,
hasNextPage = false,
blobHasReadme = false,
} = {}) => ({
data: {
project: {
id: 'gid://gitlab/Project/278964',
__typename: 'Project',
repository: {
__typename: 'Repository',
paginatedTree: {
__typename: 'TreeConnection',
pageInfo: {
__typename: 'PageInfo',
endCursor: hasNextPage ? 'aaa' : '',
startCursor: '',
hasNextPage,
},
nodes: [
{
__typename: 'Tree',
trees: {
__typename: 'TreeEntryConnection',
nodes: new Array(numberOfTrees).fill({
__typename: 'TreeEntry',
id:
'gid://gitlab/Gitlab::Graphql::Representation::TreeEntry/dc36320ac91aca2f890a31458c9e9920159e68a3',
sha: 'dc36320ac91aca2f890a31458c9e9920159e68ae',
name: 'gitlab-resize-image',
flatPath: 'workhorse/cmd/gitlab-resize-image',
type: 'tree',
webPath: '/gitlab-org/gitlab/-/tree/master/workhorse/cmd/gitlab-resize-image',
}),
},
submodules: {
__typename: 'SubmoduleConnection',
nodes: [],
},
blobs: {
__typename: 'BlobConnection',
nodes: new Array(numberOfBlobs).fill({
__typename: 'Blob',
id:
'gid://gitlab/Gitlab::Graphql::Representation::TreeEntry/99712dbc6b26ff92c15bf93449ea09df38adfb10',
sha: '99712dbc6b26ff92c15bf93449ea09df38adfb1b',
name: blobHasReadme ? 'README.md' : 'fakeBlob',
flatPath: blobHasReadme ? 'README.md' : 'fakeBlob',
type: 'blob',
mode: '100644',
webPath: '/gitlab-org/gitlab-build-images/-/blob/master/README.md',
lfsOid: null,
}),
},
},
],
},
},
},
},
});
|