mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com> Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com> Co-authored-by: Laurin Quast <laurinquast@googlemail.com> Co-authored-by: Dotan Simha <dotansimha@gmail.com>
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { ProjectType } from 'testkit/gql/graphql';
|
|
import { initSeed } from '../../../testkit/seed';
|
|
|
|
describe('Preflight Script', () => {
|
|
describe('CRUD', () => {
|
|
const rawJs = 'console.log("Hello World")';
|
|
|
|
it.concurrent('Update a Preflight Script', async () => {
|
|
const { updatePreflightScript } = await initSeed()
|
|
.createOwner()
|
|
.then(r => r.createOrg())
|
|
.then(r => r.createProject(ProjectType.Single));
|
|
|
|
const { error, ok } = await updatePreflightScript({ sourceCode: rawJs });
|
|
expect(error).toEqual(null);
|
|
expect(ok?.updatedTarget.preflightScript?.id).toBeDefined();
|
|
expect(ok?.updatedTarget.preflightScript?.sourceCode).toBe(rawJs);
|
|
});
|
|
|
|
describe('Permissions Check', () => {
|
|
it('Prevent updating a Preflight Script without the write permission to the target', async () => {
|
|
const { updatePreflightScript, createTargetAccessToken } = await initSeed()
|
|
.createOwner()
|
|
.then(r => r.createOrg())
|
|
.then(r => r.createProject(ProjectType.Single));
|
|
|
|
const { secret: readOnlyToken } = await createTargetAccessToken({ mode: 'readOnly' });
|
|
|
|
await expect(
|
|
updatePreflightScript({ sourceCode: rawJs, token: readOnlyToken }),
|
|
).rejects.toEqual(
|
|
expect.objectContaining({
|
|
message: expect.stringContaining(
|
|
`No access (reason: "Missing permission for performing 'laboratory:modifyPreflightScript' on resource")`,
|
|
),
|
|
}),
|
|
);
|
|
});
|
|
});
|
|
});
|
|
});
|