mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { ProjectType } from '@app/gql/graphql';
|
|
import { createOrganization, createProject, renameTarget } from '../../../testkit/flow';
|
|
import { authenticate } from '../../../testkit/auth';
|
|
|
|
test('renaming a target should result changing its cleanId', async () => {
|
|
const { access_token } = await authenticate('main');
|
|
const orgResult = await createOrganization(
|
|
{
|
|
name: 'foo',
|
|
},
|
|
access_token,
|
|
);
|
|
const org = orgResult.body.data!.createOrganization.ok!.createdOrganizationPayload.organization;
|
|
|
|
const projectResult = await createProject(
|
|
{
|
|
organization: org.cleanId,
|
|
type: ProjectType.Single,
|
|
name: 'foo',
|
|
},
|
|
access_token,
|
|
);
|
|
|
|
const project = projectResult.body.data!.createProject.ok!.createdProject;
|
|
const target = projectResult.body.data?.createProject.ok?.createdTargets.find(
|
|
t => t.name === 'production',
|
|
);
|
|
|
|
expect(target).toBeDefined();
|
|
|
|
const renamedTargetResult = await renameTarget(
|
|
{
|
|
organization: org.cleanId,
|
|
project: project.cleanId,
|
|
target: target!.cleanId,
|
|
name: 'bar',
|
|
},
|
|
access_token,
|
|
);
|
|
|
|
expect(renamedTargetResult.body.errors).not.toBeDefined();
|
|
|
|
expect(renamedTargetResult.body.data?.updateTargetName.error).toBeNull();
|
|
expect(renamedTargetResult.body.data?.updateTargetName.ok?.updatedTarget.name).toBe('bar');
|
|
expect(renamedTargetResult.body.data?.updateTargetName.ok?.updatedTarget.cleanId).toBe('bar');
|
|
expect(renamedTargetResult.body.data?.updateTargetName.ok?.selector.target).toBe('bar');
|
|
});
|