(
feature: CreateFeatureSchema,
strategies: CreateFeatureStrategySchema[] = [mockStrategy()],
project = DEFAULT_PROJECT,
environment = DEFAULT_ENV,
expectStatusCode = 201,
expectSegmentStatusCodes: { status: number; message?: string }[] = [
{ status: 200 },
],
)
| 106 | }; |
| 107 | |
| 108 | const createFeatureToggle = async ( |
| 109 | feature: CreateFeatureSchema, |
| 110 | strategies: CreateFeatureStrategySchema[] = [mockStrategy()], |
| 111 | project = DEFAULT_PROJECT, |
| 112 | environment = DEFAULT_ENV, |
| 113 | expectStatusCode = 201, |
| 114 | expectSegmentStatusCodes: { status: number; message?: string }[] = [ |
| 115 | { status: 200 }, |
| 116 | ], |
| 117 | ): Promise<void> => { |
| 118 | await app.createFeature(feature, project, expectStatusCode); |
| 119 | let processed = 0; |
| 120 | for (const strategy of strategies) { |
| 121 | const { body, status } = await app.request |
| 122 | .post( |
| 123 | `/api/admin/projects/${project}/features/${feature.name}/environments/${environment}/strategies`, |
| 124 | ) |
| 125 | .send(strategy); |
| 126 | const expectation = expectSegmentStatusCodes[processed++]; |
| 127 | expect(status).toBe(expectation.status); |
| 128 | if (expectation.message) { |
| 129 | expect(JSON.stringify(body)).toContain(expectation.message); |
| 130 | } |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | const updateFeatureStrategy = async ( |
| 135 | featureName: string, |
no test coverage detected