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
|
import {
variableTypes,
groupString,
instanceString,
projectString,
} from '~/ci_variable_list/constants';
export const devName = 'dev';
export const prodName = 'prod';
export const mockVariables = (kind) => {
return [
{
__typename: `Ci${kind}Variable`,
id: 1,
key: 'my-var',
masked: false,
protected: true,
value: 'variable_value',
variableType: variableTypes.envType,
},
{
__typename: `Ci${kind}Variable`,
id: 2,
key: 'secret',
masked: true,
protected: false,
value: 'another_value',
variableType: variableTypes.fileType,
},
];
};
export const mockVariablesWithScopes = (kind) =>
mockVariables(kind).map((variable) => {
return { ...variable, environmentScope: '*' };
});
const createDefaultVars = ({ withScope = true, kind } = {}) => {
let base = mockVariables(kind);
if (withScope) {
base = mockVariablesWithScopes(kind);
}
return {
__typename: `Ci${kind}VariableConnection`,
nodes: base,
};
};
const defaultEnvs = {
__typename: 'EnvironmentConnection',
nodes: [
{
__typename: 'Environment',
id: 1,
name: prodName,
},
{
__typename: 'Environment',
id: 2,
name: devName,
},
],
};
export const mockEnvs = defaultEnvs.nodes;
export const mockProjectEnvironments = {
data: {
project: {
__typename: 'Project',
id: 1,
environments: defaultEnvs,
},
},
};
export const mockProjectVariables = {
data: {
project: {
__typename: 'Project',
id: 1,
ciVariables: createDefaultVars({ kind: projectString }),
},
},
};
export const mockGroupVariables = {
data: {
group: {
__typename: 'Group',
id: 1,
ciVariables: createDefaultVars({ kind: groupString }),
},
},
};
export const mockAdminVariables = {
data: {
ciVariables: createDefaultVars({ withScope: false, kind: instanceString }),
},
};
export const newVariable = {
id: 3,
environmentScope: 'new',
key: 'AWS_RANDOM_THING',
masked: true,
protected: false,
value: 'devops',
variableType: variableTypes.variableType,
};
|