diff --git a/agent/workers/trigger/triggerer.go b/agent/workers/trigger/triggerer.go
index dc3dda2851..f3dda8e7ea 100644
--- a/agent/workers/trigger/triggerer.go
+++ b/agent/workers/trigger/triggerer.go
@@ -55,6 +55,10 @@ func (r *Registry) Get(triggererType trigger.TriggerType) (Triggerer, error) {
r.Lock()
defer r.Unlock()
+ if triggererType.IsTraceIDBased() {
+ triggererType = trigger.TriggerTypeTraceID
+ }
+
t, found := r.reg[triggererType]
if !found {
return nil, fmt.Errorf(`cannot get trigger type "%s": %w`, triggererType, ErrTriggererTypeNotRegistered)
diff --git a/api/triggers.yaml b/api/triggers.yaml
index dc9192d46a..de8b0dadc1 100644
--- a/api/triggers.yaml
+++ b/api/triggers.yaml
@@ -6,7 +6,7 @@ components:
properties:
type:
type: string
- enum: ["http", "grpc", "traceid", "kafka"]
+ enum: ["http", "grpc", "traceid", "kafka", "cypress"]
httpRequest:
$ref: "./http.yaml#/components/schemas/HTTPRequest"
grpc:
@@ -21,7 +21,7 @@ components:
properties:
type:
type: string
- enum: ["http", "grpc", "traceid", "kafka"]
+ enum: ["http", "grpc", "traceid", "kafka", "cypress"]
triggerResult:
type: object
properties:
diff --git a/server/executor/trigger/traceid.go b/server/executor/trigger/traceid.go
index b3d2ed81dd..830c6f3cc5 100644
--- a/server/executor/trigger/traceid.go
+++ b/server/executor/trigger/traceid.go
@@ -8,6 +8,8 @@ import (
"github.com/kubeshop/tracetest/server/test/trigger"
)
+const TRACEID_EXPRESSION = "${env:TRACE_ID}"
+
func TRACEID() Triggerer {
return &traceidTriggerer{}
}
@@ -17,7 +19,7 @@ type traceidTriggerer struct{}
func (t *traceidTriggerer) Trigger(ctx context.Context, test test.Test, opts *TriggerOptions) (Response, error) {
response := Response{
Result: trigger.TriggerResult{
- Type: t.Type(),
+ Type: test.Trigger.Type,
TraceID: &trigger.TraceIDResponse{ID: test.Trigger.TraceID.ID},
},
}
@@ -30,6 +32,10 @@ func (t *traceidTriggerer) Type() trigger.TriggerType {
}
func (t *traceidTriggerer) Resolve(ctx context.Context, test test.Test, opts *ResolveOptions) (test.Test, error) {
+ if test.Trigger.Type.IsFrontendE2EBased() {
+ test.Trigger.TraceID = &trigger.TraceIDRequest{ID: TRACEID_EXPRESSION}
+ }
+
traceid := test.Trigger.TraceID
if traceid == nil {
return test, fmt.Errorf("no settings provided for TRACEID triggerer")
diff --git a/server/executor/trigger/triggerer.go b/server/executor/trigger/triggerer.go
index 3451d9d58b..5f8e976f89 100644
--- a/server/executor/trigger/triggerer.go
+++ b/server/executor/trigger/triggerer.go
@@ -61,6 +61,10 @@ func (r *Registry) Get(triggererType trigger.TriggerType) (Triggerer, error) {
r.Lock()
defer r.Unlock()
+ if triggererType.IsTraceIDBased() {
+ triggererType = trigger.TriggerTypeTraceID
+ }
+
t, found := r.reg[triggererType]
if !found {
return nil, fmt.Errorf(`cannot get trigger type "%s": %w`, triggererType, ErrTriggererTypeNotRegistered)
diff --git a/server/executor/trigger_resolver_worker.go b/server/executor/trigger_resolver_worker.go
index d615c00814..b3a3ec9517 100644
--- a/server/executor/trigger_resolver_worker.go
+++ b/server/executor/trigger_resolver_worker.go
@@ -10,7 +10,6 @@ import (
"github.com/kubeshop/tracetest/server/model/events"
"github.com/kubeshop/tracetest/server/pkg/pipeline"
"github.com/kubeshop/tracetest/server/test"
- "github.com/kubeshop/tracetest/server/test/trigger"
"github.com/kubeshop/tracetest/server/tracedb"
"go.opentelemetry.io/otel/trace"
)
@@ -132,8 +131,8 @@ func (r triggerResolverWorker) ProcessItem(ctx context.Context, job Job) {
r.handleError(job.Run, err)
}
- if job.Test.Trigger.Type == trigger.TriggerTypeTraceID {
- traceIDFromParam, err := trace.TraceIDFromHex(job.Test.Trigger.TraceID.ID)
+ if job.Test.Trigger.Type.IsTraceIDBased() {
+ traceIDFromParam, err := trace.TraceIDFromHex(resolvedTest.Trigger.TraceID.ID)
if err == nil {
run.TraceID = traceIDFromParam
}
diff --git a/server/http/mappings/tests.go b/server/http/mappings/tests.go
index 69a048bf84..6926fcb131 100644
--- a/server/http/mappings/tests.go
+++ b/server/http/mappings/tests.go
@@ -465,13 +465,17 @@ func (m Model) TriggerResult(in openapi.TriggerResult) trigger.TriggerResult {
Type: trigger.TriggerType(in.Type),
Error: m.TriggerError(in.TriggerResult.Error),
}
+
+ if tr.Type.IsTraceIDBased() {
+ tr.TraceID = m.TraceIDResponse(in.TriggerResult.Traceid)
+ return tr
+ }
+
switch in.Type {
case "http":
tr.HTTP = m.HTTPResponse(in.TriggerResult.Http)
case "grpc":
tr.GRPC = m.GRPCResponse(in.TriggerResult.Grpc)
- case "traceid":
- tr.TraceID = m.TraceIDResponse(in.TriggerResult.Traceid)
case "kafka":
tr.Kafka = m.KafkaResponse(in.TriggerResult.Kafka)
}
diff --git a/server/test/trigger/traceid.go b/server/test/trigger/traceid.go
index 84d40173c5..ff4f65eab2 100644
--- a/server/test/trigger/traceid.go
+++ b/server/test/trigger/traceid.go
@@ -1,6 +1,9 @@
package trigger
const TriggerTypeTraceID TriggerType = "traceid"
+const TriggerTypeCypress TriggerType = "cypress"
+
+var traceIDBasedTriggers = []TriggerType{TriggerTypeTraceID, TriggerTypeCypress}
type TraceIDRequest struct {
ID string `json:"id,omitempty" expr_enabled:"true"`
diff --git a/server/test/trigger/trigger.go b/server/test/trigger/trigger.go
index 758c84258a..5841f4a0a7 100644
--- a/server/test/trigger/trigger.go
+++ b/server/test/trigger/trigger.go
@@ -1,6 +1,10 @@
package trigger
-import "errors"
+import (
+ "errors"
+
+ "golang.org/x/exp/slices"
+)
type (
TriggerType string
@@ -33,3 +37,11 @@ type (
func (e TriggerError) Error() error {
return errors.New(e.ErrorMessage)
}
+
+func (t TriggerType) IsTraceIDBased() bool {
+ return slices.Contains(traceIDBasedTriggers, t)
+}
+
+func (t TriggerType) IsFrontendE2EBased() bool {
+ return t == TriggerTypeCypress
+}
diff --git a/server/test/trigger/trigger_json.go b/server/test/trigger/trigger_json.go
index c56f42b621..7d67c68e95 100644
--- a/server/test/trigger/trigger_json.go
+++ b/server/test/trigger/trigger_json.go
@@ -17,11 +17,11 @@ type triggerJSONV3 struct {
func (v3 triggerJSONV3) valid() bool {
// has a valid type and at least one not nil trigger type settings
- return v3.Type != "" &&
+ return (v3.Type != "" &&
(v3.HTTP != nil ||
v3.GRPC != nil ||
v3.TraceID != nil ||
- v3.Kafka != nil)
+ v3.Kafka != nil)) || v3.Type == TriggerTypeCypress
}
type triggerJSONV2 struct {
diff --git a/web/src/components/CreateTest/Header.tsx b/web/src/components/CreateTest/Header.tsx
index 1d1497cafc..d1e93f264e 100644
--- a/web/src/components/CreateTest/Header.tsx
+++ b/web/src/components/CreateTest/Header.tsx
@@ -3,6 +3,7 @@ import AllowButton, {Operation} from 'components/AllowButton';
import CreateButton from 'components/CreateButton';
import {TriggerTypes} from 'constants/Test.constants';
import EntryPointFactory from 'components/TestPlugins/EntryPointFactory';
+import Test from 'models/Test.model';
import * as S from './CreateTest.styled';
interface IProps {
@@ -21,18 +22,20 @@ const Header = ({isLoading, isValid, triggerType}: IProps) => {
- form.submit()}
- operation={Operation.Edit}
- type="primary"
- >
- Run
-
+ {Test.shouldAllowRun(triggerType) && (
+ form.submit()}
+ operation={Operation.Edit}
+ type="primary"
+ >
+ Run
+
+ )}
);
diff --git a/web/src/components/ResourceCard/TestCard.tsx b/web/src/components/ResourceCard/TestCard.tsx
index 49930702eb..eb40a447bd 100644
--- a/web/src/components/ResourceCard/TestCard.tsx
+++ b/web/src/components/ResourceCard/TestCard.tsx
@@ -50,17 +50,19 @@ const TestCard = ({onEdit, onDelete, onDuplicate, onRun, onViewAll, test}: IProp
- {
- event.stopPropagation();
- onRun(test, ResourceType.Test);
- }}
- type="primary"
- >
- Run
-
+ {Test.shouldAllowRun(test.trigger.type) && (
+ {
+ event.stopPropagation();
+ onRun(test, ResourceType.Test);
+ }}
+ type="primary"
+ >
+ Run
+
+ )}
{
+const HeaderRight = ({testId, triggerType}: IProps) => {
const {isDraftMode: isTestSpecsDraftMode} = useTestSpecs();
const {isDraftMode: isTestOutputsDraftMode} = useTestOutput();
const isDraftMode = isTestSpecsDraftMode || isTestOutputsDraftMode;
@@ -48,7 +51,7 @@ const HeaderRight = ({testId}: IProps) => {
)}
- {!isDraftMode && state && isRunStateFinished(state) && (
+ {!isDraftMode && state && isRunStateFinished(state) && Test.shouldAllowRun(triggerType) && (
onRun()} type="primary">
Run Test
diff --git a/web/src/components/RunDetailLayout/RunDetailLayout.tsx b/web/src/components/RunDetailLayout/RunDetailLayout.tsx
index a6c5e3435c..e1bb71022e 100644
--- a/web/src/components/RunDetailLayout/RunDetailLayout.tsx
+++ b/web/src/components/RunDetailLayout/RunDetailLayout.tsx
@@ -63,7 +63,7 @@ const RunDetailLayout = ({test: {id, name, trigger, skipTraceCollection}, test}:
const tabBarExtraContent = useMemo(
() => ({
left: ,
- right: ,
+ right: ,
}),
[id, name, trigger.type, runOriginPath]
);
diff --git a/web/src/components/RunDetailTriggerResponse/RunDetailTriggerResponseFactory.tsx b/web/src/components/RunDetailTriggerResponse/RunDetailTriggerResponseFactory.tsx
index 4b30c5ea5d..700b178316 100644
--- a/web/src/components/RunDetailTriggerResponse/RunDetailTriggerResponseFactory.tsx
+++ b/web/src/components/RunDetailTriggerResponse/RunDetailTriggerResponseFactory.tsx
@@ -15,8 +15,9 @@ export interface IPropsComponent {
const ComponentMap: Record React.ReactElement> = {
[TriggerTypes.http]: RunDetailTriggerResponse,
[TriggerTypes.grpc]: RunDetailTriggerResponse,
- [TriggerTypes.traceid]: RunDetailTriggerData,
[TriggerTypes.kafka]: RunDetailTriggerResponse,
+ [TriggerTypes.traceid]: RunDetailTriggerData,
+ [TriggerTypes.cypress]: RunDetailTriggerData,
};
interface IProps extends IPropsComponent {
diff --git a/web/src/components/TestHeader/TestHeader.tsx b/web/src/components/TestHeader/TestHeader.tsx
index e483a24a85..528c4e8f9e 100644
--- a/web/src/components/TestHeader/TestHeader.tsx
+++ b/web/src/components/TestHeader/TestHeader.tsx
@@ -11,7 +11,7 @@ interface IProps {
onDelete(): void;
onDuplicate(): void;
title: string;
- runButton: React.ReactElement;
+ runButton: React.ReactNode;
}
const TestHeader = ({description, id, shouldEdit, onEdit, onDelete, onDuplicate, title, runButton}: IProps) => {
diff --git a/web/src/components/TestPlugins/EntryPointFactory.tsx b/web/src/components/TestPlugins/EntryPointFactory.tsx
index 77f2f3a520..cc1319cb96 100644
--- a/web/src/components/TestPlugins/EntryPointFactory.tsx
+++ b/web/src/components/TestPlugins/EntryPointFactory.tsx
@@ -7,8 +7,9 @@ import TriggerHeaderBarKafka from './EntryPoint/Kafka';
const EntryPointFactoryMap = {
[TriggerTypes.http]: TriggerHeaderBarHttp,
[TriggerTypes.grpc]: TriggerHeaderBarGrpc,
- [TriggerTypes.traceid]: TriggerHeaderBarTraceID,
[TriggerTypes.kafka]: TriggerHeaderBarKafka,
+ [TriggerTypes.traceid]: TriggerHeaderBarTraceID,
+ [TriggerTypes.cypress]: () => null,
};
interface IProps {
diff --git a/web/src/components/TestPlugins/FormFactory.tsx b/web/src/components/TestPlugins/FormFactory.tsx
index 5b07861e6a..565e4f8398 100644
--- a/web/src/components/TestPlugins/FormFactory.tsx
+++ b/web/src/components/TestPlugins/FormFactory.tsx
@@ -7,8 +7,9 @@ import {TDraftTestForm} from 'types/Test.types';
const FormFactoryMap = {
[TriggerTypes.http]: Rest,
[TriggerTypes.grpc]: Grpc,
- [TriggerTypes.traceid]: () => null,
[TriggerTypes.kafka]: Kafka,
+ [TriggerTypes.traceid]: () => null,
+ [TriggerTypes.cypress]: () => null,
};
export interface IFormProps {
diff --git a/web/src/components/TriggerTypeModal/TriggerTypeModal.tsx b/web/src/components/TriggerTypeModal/TriggerTypeModal.tsx
index 27d632fd21..a5b6572f48 100644
--- a/web/src/components/TriggerTypeModal/TriggerTypeModal.tsx
+++ b/web/src/components/TriggerTypeModal/TriggerTypeModal.tsx
@@ -1,10 +1,10 @@
-import {TriggerTypeToPlugin} from 'constants/Plugins.constants';
+import {CreateTriggerTypeToPlugin} from 'constants/Plugins.constants';
import {useDashboard} from 'providers/Dashboard/Dashboard.provider';
import CreateTestAnalyticsService from 'services/Analytics/CreateTestAnalytics.service';
import TriggerTypeCard from './TriggerTypeCard';
import * as S from './TriggerTypeModal.styled';
-const pluginList = Object.values(TriggerTypeToPlugin);
+const pluginList = Object.values(CreateTriggerTypeToPlugin);
interface IProps {
isOpen: boolean;
diff --git a/web/src/constants/Common.constants.ts b/web/src/constants/Common.constants.ts
index d72c0283bb..46e831a632 100644
--- a/web/src/constants/Common.constants.ts
+++ b/web/src/constants/Common.constants.ts
@@ -66,6 +66,7 @@ export enum RouterSearchFields {
export enum SupportedPlugins {
REST = 'REST',
GRPC = 'GRPC',
- TraceID = 'TraceID',
Kafka = 'Kafka',
+ TraceID = 'TraceID',
+ Cypress = 'Cypress',
}
diff --git a/web/src/constants/Demo.constants.ts b/web/src/constants/Demo.constants.ts
index 976583a8c2..0c7221c077 100644
--- a/web/src/constants/Demo.constants.ts
+++ b/web/src/constants/Demo.constants.ts
@@ -228,6 +228,7 @@ export function getDemoByPluginMap(demos: Demo[]) {
...((otelDemoMap && otelDemoMap[SupportedPlugins.GRPC]) || []),
],
[SupportedPlugins.TraceID]: [],
+ [SupportedPlugins.Cypress]: [],
[SupportedPlugins.Kafka]: (pokeshopDemoMap && pokeshopDemoMap[SupportedPlugins.Kafka]) || [],
};
}
diff --git a/web/src/constants/Plugins.constants.ts b/web/src/constants/Plugins.constants.ts
index 99a595852d..97be5ffa5f 100644
--- a/web/src/constants/Plugins.constants.ts
+++ b/web/src/constants/Plugins.constants.ts
@@ -48,11 +48,22 @@ const TraceID: IPlugin = {
type: TriggerTypes.traceid,
};
+const Cypress: IPlugin = {
+ name: SupportedPlugins.Cypress,
+ title: 'Cypress',
+ description: 'Define your test via Cypress',
+ isActive: true,
+ demoList: [],
+ type: TriggerTypes.cypress,
+ requestType: TriggerTypes.traceid,
+};
+
export const Plugins = {
[SupportedPlugins.REST]: Rest,
[SupportedPlugins.GRPC]: GRPC,
[SupportedPlugins.Kafka]: Kafka,
[SupportedPlugins.TraceID]: TraceID,
+ [SupportedPlugins.Cypress]: Cypress,
} as const;
export const TriggerTypeToPlugin = {
@@ -60,4 +71,12 @@ export const TriggerTypeToPlugin = {
[TriggerTypes.grpc]: Plugins.GRPC,
[TriggerTypes.kafka]: Plugins.Kafka,
[TriggerTypes.traceid]: Plugins.TraceID,
+ [TriggerTypes.cypress]: Plugins.Cypress,
+} as const;
+
+export const CreateTriggerTypeToPlugin = {
+ [TriggerTypes.http]: Plugins.REST,
+ [TriggerTypes.grpc]: Plugins.GRPC,
+ [TriggerTypes.kafka]: Plugins.Kafka,
+ [TriggerTypes.traceid]: Plugins.TraceID,
} as const;
diff --git a/web/src/constants/Test.constants.ts b/web/src/constants/Test.constants.ts
index bc8902577a..b0c26eeecd 100644
--- a/web/src/constants/Test.constants.ts
+++ b/web/src/constants/Test.constants.ts
@@ -10,6 +10,7 @@ export enum TriggerTypes {
grpc = 'grpc',
traceid = 'traceid',
kafka = 'kafka',
+ cypress = 'cypress',
}
export enum ImportTypes {
diff --git a/web/src/models/Test.model.ts b/web/src/models/Test.model.ts
index f3bfd74d26..7a3cb48808 100644
--- a/web/src/models/Test.model.ts
+++ b/web/src/models/Test.model.ts
@@ -1,3 +1,4 @@
+import {TriggerTypes} from 'constants/Test.constants';
import {load} from 'js-yaml';
import {Model, TTestSchemas} from 'types/Common.types';
import TestOutput from './TestOutput.model';
@@ -54,4 +55,8 @@ Test.FromDefinition = (definition: string): Test => {
return Test(raw);
};
+Test.shouldAllowRun = (triggerType: TriggerTypes): boolean => {
+ return triggerType !== TriggerTypes.cypress;
+};
+
export default Test;
diff --git a/web/src/models/Trigger.model.ts b/web/src/models/Trigger.model.ts
index eed1bec54c..12947b8e7b 100644
--- a/web/src/models/Trigger.model.ts
+++ b/web/src/models/Trigger.model.ts
@@ -15,26 +15,34 @@ type Trigger = {
request: TTriggerRequest;
};
+type TRequest = object | null;
+
const EntryData = {
- [TriggerTypes.http](request: object) {
+ [TriggerTypes.http](request: TRequest) {
return {
entryPoint: get(request, 'url', ''),
method: get(request, 'method', ''),
};
},
- [TriggerTypes.grpc](request: object) {
+ [TriggerTypes.grpc](request: TRequest) {
return {
entryPoint: get(request, 'address', ''),
method: get(request, 'method', ''),
};
},
- [TriggerTypes.traceid](request: object) {
+ [TriggerTypes.traceid](request: TRequest) {
return {
entryPoint: get(request, 'id', ''),
method: 'TraceID',
};
},
- [TriggerTypes.kafka](request: object) {
+ [TriggerTypes.cypress](request: TRequest) {
+ return {
+ entryPoint: get(request, 'id', ''),
+ method: 'Cypress',
+ };
+ },
+ [TriggerTypes.kafka](request: TRequest) {
let entryPoint = '';
const kafkaRequest = request as KafkaRequest;
@@ -49,7 +57,13 @@ const EntryData = {
},
};
-const Trigger = ({type: rawType = 'http', httpRequest = {}, grpc = {}, traceid = {}, kafka = {}}: TRawTrigger): Trigger => {
+const Trigger = ({
+ type: rawType = 'http',
+ httpRequest = {},
+ grpc = {},
+ traceid = {},
+ kafka = {},
+}: TRawTrigger): Trigger => {
const type = rawType as TriggerTypes;
let request = {} as TTriggerRequest;
@@ -57,7 +71,7 @@ const Trigger = ({type: rawType = 'http', httpRequest = {}, grpc = {}, traceid =
request = HttpRequest(httpRequest);
} else if (type === TriggerTypes.grpc) {
request = GrpcRequest(grpc);
- } else if (type === TriggerTypes.traceid) {
+ } else if ([TriggerTypes.traceid, TriggerTypes.cypress].includes(type)) {
request = TraceIDRequest(traceid);
} else if (type === TriggerTypes.kafka) {
request = KafkaRequest(kafka);
diff --git a/web/src/models/TriggerResult.model.ts b/web/src/models/TriggerResult.model.ts
index 1d016e3a03..cd092fafcf 100644
--- a/web/src/models/TriggerResult.model.ts
+++ b/web/src/models/TriggerResult.model.ts
@@ -34,6 +34,13 @@ const ResponseData = {
statusCode: 200,
};
},
+ [TriggerTypes.cypress](response: object) {
+ return {
+ body: get(response, 'id', ''),
+ headers: [],
+ statusCode: 200,
+ };
+ },
[TriggerTypes.kafka](response: object) {
const kafkaResult = {
offset: get(response, 'offset', ''),
@@ -59,7 +66,7 @@ const TriggerResult = ({
request = http;
} else if (type === TriggerTypes.grpc) {
request = grpc;
- } else if (type === TriggerTypes.traceid) {
+ } else if ([TriggerTypes.traceid, TriggerTypes.cypress].includes(type)) {
request = traceid;
} else if (type === TriggerTypes.kafka) {
request = kafka;
diff --git a/web/src/pages/Test/Content.tsx b/web/src/pages/Test/Content.tsx
index a1dc8d2f36..899b87d598 100644
--- a/web/src/pages/Test/Content.tsx
+++ b/web/src/pages/Test/Content.tsx
@@ -5,6 +5,7 @@ import TestRunCard from 'components/RunCard/TestRunCard';
import TestHeader from 'components/TestHeader';
import useDeleteResource from 'hooks/useDeleteResource';
import useDocumentTitle from 'hooks/useDocumentTitle';
+import Test from 'models/Test.model';
import TestRun from 'models/TestRun.model';
import {useDashboard} from 'providers/Dashboard/Dashboard.provider';
import {useTest} from 'providers/Test/Test.provider';
@@ -51,15 +52,17 @@ const Content = () => {
shouldEdit={shouldEdit}
title={`${test.name} (v${test.version})`}
runButton={
- runTest({test})}
- type="primary"
- >
- Run Test
-
+ Test.shouldAllowRun(test.trigger.type) ? (
+ runTest({test})}
+ type="primary"
+ >
+ Run Test
+
+ ) : null
}
/>
diff --git a/web/src/services/Test.service.ts b/web/src/services/Test.service.ts
index b59d772c33..80216ec04a 100644
--- a/web/src/services/Test.service.ts
+++ b/web/src/services/Test.service.ts
@@ -10,6 +10,7 @@ import TestDefinitionService from './TestDefinition.service';
import GrpcService from './Triggers/Grpc.service';
import HttpService from './Triggers/Http.service';
import TraceIDService from './Triggers/TraceID.service';
+import CypressService from './Triggers/Cypress.service';
import KafkaService from './Triggers/Kafka.service';
const authValidation = ({auth}: TDraftTest): boolean => {
@@ -34,17 +35,23 @@ const TriggerServiceMap = {
[SupportedPlugins.REST]: HttpService,
[SupportedPlugins.Kafka]: KafkaService,
[SupportedPlugins.TraceID]: TraceIDService,
+ [SupportedPlugins.Cypress]: CypressService,
} as const;
const TriggerServiceByTypeMap = {
[TriggerTypes.grpc]: GrpcService,
[TriggerTypes.http]: HttpService,
[TriggerTypes.traceid]: TraceIDService,
+ [TriggerTypes.cypress]: CypressService,
[TriggerTypes.kafka]: KafkaService,
} as const;
const TestService = () => ({
- async getRequest({type, name: pluginName}: IPlugin, draft: TDraftTest, original?: Test): Promise {
+ async getRequest(
+ {type, requestType, name: pluginName}: IPlugin,
+ draft: TDraftTest,
+ original?: Test
+ ): Promise {
const {name, description, skipTraceCollection = false} = draft;
const triggerService = TriggerServiceMap[pluginName];
const request = await triggerService.getRequest(draft);
@@ -52,7 +59,7 @@ const TestService = () => ({
const trigger = {
type,
triggerType: type,
- [type]: request,
+ ...(request && {[requestType ?? type]: request}),
};
return {
diff --git a/web/src/services/Triggers/Cypress.service.ts b/web/src/services/Triggers/Cypress.service.ts
new file mode 100644
index 0000000000..8456317f27
--- /dev/null
+++ b/web/src/services/Triggers/Cypress.service.ts
@@ -0,0 +1,21 @@
+import {ITraceIDValues, ITriggerService} from 'types/Test.types';
+import Validator from 'utils/Validator';
+
+const CypressTriggerService = (): ITriggerService => ({
+ async getRequest() {
+ return null;
+ },
+
+ async validateDraft(draft) {
+ const {id} = draft as ITraceIDValues;
+ return Validator.required(id);
+ },
+
+ getInitialValues(request) {
+ const {id} = request as ITraceIDValues;
+
+ return {id};
+ },
+});
+
+export default CypressTriggerService();
diff --git a/web/src/types/Generated.types.ts b/web/src/types/Generated.types.ts
index 03b7ad774f..b38c6d33ab 100644
--- a/web/src/types/Generated.types.ts
+++ b/web/src/types/Generated.types.ts
@@ -2062,7 +2062,7 @@ export interface external {
schemas: {
Trigger: {
/** @enum {string} */
- type?: "http" | "grpc" | "traceid" | "kafka";
+ type?: "http" | "grpc" | "traceid" | "kafka" | "cypress";
httpRequest?: external["http.yaml"]["components"]["schemas"]["HTTPRequest"];
grpc?: external["grpc.yaml"]["components"]["schemas"]["GRPCRequest"];
traceid?: external["traceid.yaml"]["components"]["schemas"]["TRACEIDRequest"];
@@ -2070,7 +2070,7 @@ export interface external {
};
TriggerResult: {
/** @enum {string} */
- type?: "http" | "grpc" | "traceid" | "kafka";
+ type?: "http" | "grpc" | "traceid" | "kafka" | "cypress";
triggerResult?: {
http?: external["http.yaml"]["components"]["schemas"]["HTTPResponse"];
grpc?: external["grpc.yaml"]["components"]["schemas"]["GRPCResponse"];
diff --git a/web/src/types/Plugins.types.ts b/web/src/types/Plugins.types.ts
index 079c5a55c6..9fca24bd32 100644
--- a/web/src/types/Plugins.types.ts
+++ b/web/src/types/Plugins.types.ts
@@ -1,6 +1,6 @@
import {SupportedPlugins} from 'constants/Common.constants';
import {TriggerTypes} from '../constants/Test.constants';
-import { TDraftTest } from './Test.types';
+import {TDraftTest} from './Test.types';
export type TStepStatus = 'complete' | 'pending' | 'selected';
@@ -20,6 +20,7 @@ export interface IPlugin {
demoList: TDraftTest[];
isActive: boolean;
type: TriggerTypes;
+ requestType?: TriggerTypes;
}
export interface IPluginStepProps {}
diff --git a/web/src/types/Test.types.ts b/web/src/types/Test.types.ts
index 6a02f6179e..06b3f66a32 100644
--- a/web/src/types/Test.types.ts
+++ b/web/src/types/Test.types.ts
@@ -83,7 +83,7 @@ export type TTestRequestDetailsValues = IRpcValues | IHttpValues | IPostmanValue
export type TDraftTest = Partial;
export type TDraftTestForm = FormInstance>;
-export type TTriggerRequest = HttpRequest | GRPCRequest | TraceIDRequest | KafkaRequest;
+export type TTriggerRequest = HttpRequest | GRPCRequest | TraceIDRequest | KafkaRequest | null;
export interface ITriggerService {
getRequest(values: TDraftTest): Promise;
validateDraft(draft: TDraftTest): Promise;