-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(integration): defined rulesets fixtures to a failing state
for #732
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
test/integration/features/step_definitions/rulesets-steps.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { dump } from 'js-yaml' | ||
import { StatusCodes } from 'http-status-codes' | ||
|
||
import { Given, Then } from '@cucumber/cucumber' | ||
import assert from 'node:assert' | ||
import { http, HttpResponse } from 'msw' | ||
|
||
import { repository } from './common-steps.mjs' | ||
import settings from '../../../../lib/settings.js' | ||
|
||
Given('no rulesets are defined for the repository', async function () { | ||
this.server.use( | ||
http.get(`https://api.github.com/repos/${repository.owner.name}/${repository.name}/rulesets`, ({ request }) => | ||
HttpResponse.json([]) | ||
) | ||
) | ||
}) | ||
|
||
Given('a ruleset is defined in the config', async function () { | ||
this.server.use( | ||
http.get( | ||
`https://api.github.com/repos/${repository.owner.name}/${repository.name}/contents/${encodeURIComponent( | ||
settings.FILE_NAME | ||
)}`, | ||
({ request }) => HttpResponse.arrayBuffer(Buffer.from(dump({ rulesets: [{}] }))) | ||
), | ||
http.post( | ||
`https://api.github.com/repos/${repository.owner.name}/${repository.name}/rulesets`, | ||
async ({ request }) => { | ||
this.createdRuleset = await request.json() | ||
|
||
return new HttpResponse(null, { status: StatusCodes.CREATED }) | ||
} | ||
) | ||
) | ||
}) | ||
|
||
Then('the ruleset is enabled for the repository', async function () { | ||
assert.deepEqual(this.createdRuleset, {}) | ||
}) |