graphql-engine/console/cypress/helpers/webhookTransformHelpers.ts
Stefano Magni fb1dc2e0ba console: improve actions E2E tests with rest connectors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4520
GitOrigin-RevId: 24d9176dc5f93747e4b3a12ed08171064e75900e
2022-06-28 05:40:36 +00:00

83 lines
2.2 KiB
TypeScript

import { getElementFromAlias } from './dataHelpers';
export const togglePayloadTransformSection = () => {
cy.getBySel('toggle-payload-transform').click({
force: true,
});
};
export const toggleRequestTransformSection = () => {
cy.getBySel('toggle-request-transform').click({
force: true,
});
};
export const clearRequestUrl = () => {
cy.get(
getElementFromAlias('transform-requestUrl')
).type('{selectall}{backspace}', { force: true });
};
export const typeIntoRequestUrl = (content: string) => {
cy.getBySel('transform-requestUrl').type(content, {
parseSpecialCharSequences: false,
});
};
export const checkTransformRequestUrlError = (
exists: boolean,
error?: string
) => {
if (exists) {
if (error) {
cy.getBySel('transform-requestUrl-error')
.should('exist')
.and('contain', error);
} else {
cy.getBySel('transform-requestUrl-error').should('exist');
}
} else {
cy.getBySel('transform-requestUrl-error').should('not.exist');
}
};
export const typeIntoRequestQueryParams = (
queryParams: { key: string; value: string }[]
) => {
queryParams.forEach((q, i) => {
cy.getBySel(`transform-query-params-kv-key-${i}`).type(q.key, {
parseSpecialCharSequences: false,
});
cy.getBySel(`transform-query-params-kv-value-${i}`).type(q.value, {
parseSpecialCharSequences: false,
});
});
};
export const checkTransformRequestUrlPreview = (previewText: string) => {
cy.getBySel('transform-requestUrl-preview').should('have.value', previewText);
};
export const clearPayloadTransformBody = (textArea: number) => {
cy.get('textarea').eq(textArea).type('{selectall}', { force: true });
cy.get('textarea').eq(textArea).trigger('keydown', {
keyCode: 46,
which: 46,
force: true,
});
};
export const typeIntoTransformBody = (content: string, textArea: number) => {
cy.get('textarea')
.eq(textArea)
.type(content, { force: true, parseSpecialCharSequences: false });
};
export const checkTransformRequestBodyError = (exists: boolean) => {
if (exists) {
cy.getBySel('transform-requestBody-error').should('exist');
} else {
cy.getBySel('transform-requestBody-error').should('not.exist');
}
};