5af2d37253
## Description - Created a Dashboard duplication action - Created a new duplication custom resolver - Created the service using the v2 of the API - Created the integration tests following the v2 methodology ## Video QA https://github.com/user-attachments/assets/e409951a-5946-4da0-91a0-1f7d2ecadb08
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { makeGraphqlAPIRequest } from 'test/integration/graphql/utils/make-graphql-api-request.util';
|
|
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
|
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
|
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
|
|
|
import { type DuplicatedDashboardDTO } from 'src/modules/dashboard/dtos/duplicated-dashboard.dto';
|
|
|
|
import {
|
|
type DuplicateOneDashboardFactoryInput,
|
|
duplicateOneDashboardQueryFactory,
|
|
} from './duplicate-one-dashboard-query-factory.util';
|
|
|
|
export const duplicateOneDashboard = async ({
|
|
input,
|
|
gqlFields,
|
|
expectToFail = false,
|
|
token,
|
|
}: {
|
|
input: DuplicateOneDashboardFactoryInput;
|
|
gqlFields?: string;
|
|
expectToFail?: boolean;
|
|
token?: string;
|
|
}): CommonResponseBody<{
|
|
duplicateDashboard: DuplicatedDashboardDTO;
|
|
}> => {
|
|
const graphqlOperation = duplicateOneDashboardQueryFactory({
|
|
input,
|
|
gqlFields,
|
|
});
|
|
|
|
const response = await makeGraphqlAPIRequest(graphqlOperation, token);
|
|
|
|
if (expectToFail === true) {
|
|
warnIfNoErrorButExpectedToFail({
|
|
response,
|
|
errorMessage: 'Dashboard duplication should have failed but did not',
|
|
});
|
|
}
|
|
|
|
if (expectToFail === false) {
|
|
warnIfErrorButNotExpectedToFail({
|
|
response,
|
|
errorMessage: 'Dashboard duplication has failed but should not',
|
|
});
|
|
}
|
|
|
|
return { data: response.body.data, errors: response.body.errors };
|
|
};
|