Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions cypress/e2e/config_generator_spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// End-to-end coverage for the Tailcall Configuration Generator at /app/config.
// The schema request is intercepted with a fixture so the run is deterministic
// and independent of the network.

describe("Configuration Generator", () => {
beforeEach(() => {
cy.intercept("GET", "**/.tailcallrc.schema.json", {fixture: "tailcallrc.schema.json"}).as("schema")
cy.visit("/app/config/")
})

it("loads the schema and renders a valid starter configuration", () => {
cy.contains("Schema loaded from tailcall").should("be.visible")
cy.get("[data-testid=validation]").should("contain.text", "No schema errors")

// YAML is the default output and reflects the seeded runtime config.
cy.get("[data-testid=output]").should("contain.text", "port: 8000")
cy.get("[data-testid=output]").should("contain.text", "httpCache: 42")
})

it("serializes the same configuration to JSON and GraphQL", () => {
cy.contains("button", "JSON").click()
cy.get("[data-testid=output]").should("contain.text", '"port": 8000')
cy.get("[data-testid=output]").should("contain.text", '"httpCache": 42')

cy.contains("button", "GraphQL").click()
cy.get("[data-testid=output]").should("contain.text", "schema @server(port: 8000")
cy.get("[data-testid=output]").should("contain.text", "@upstream(httpCache: 42")
})

it("regenerates the output when a field changes", () => {
cy.get("input[type=number]").first().clear().type("9000")
cy.get("[data-testid=output]").should("contain.text", "port: 9000")
})

it("exposes copy and download actions", () => {
cy.get("[data-testid=copy]").should("be.visible")
cy.contains("button", "Download").should("be.visible")
})
})
77 changes: 77 additions & 0 deletions cypress/fixtures/tailcallrc.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Config",
"type": "object",
"properties": {
"server": {
"description": "Dictates how the server behaves for all ingress requests.",
"allOf": [{"$ref": "#/definitions/Server"}]
},
"upstream": {
"description": "Dictates how Tailcall handles upstream requests and responses.",
"allOf": [{"$ref": "#/definitions/Upstream"}]
},
"telemetry": {
"description": "Enable OpenTelemetry support.",
"allOf": [{"$ref": "#/definitions/Telemetry"}]
},
"links": {
"description": "A list of all links in the schema.",
"type": "array",
"items": {"$ref": "#/definitions/Link"}
}
},
"definitions": {
"Server": {
"type": "object",
"properties": {
"port": {"type": ["integer", "null"], "description": "The port Tailcall listens on."},
"hostname": {"type": ["string", "null"], "description": "The host address the server binds to."},
"version": {
"description": "The HTTP version to use.",
"anyOf": [{"$ref": "#/definitions/HttpVersion"}, {"type": "null"}]
},
"queryValidation": {"type": ["boolean", "null"], "description": "Validate incoming queries."}
}
},
"Upstream": {
"type": "object",
"properties": {
"httpCache": {"type": ["integer", "null"], "description": "Number of responses to cache."},
"timeout": {"type": ["integer", "null"], "description": "Upstream response timeout in seconds."},
"batch": {
"description": "Group upstream requests.",
"anyOf": [{"$ref": "#/definitions/Batch"}, {"type": "null"}]
},
"allowedHeaders": {"type": ["array", "null"], "items": {"type": "string"}}
}
},
"Batch": {
"type": "object",
"properties": {
"maxSize": {"type": ["integer", "null"], "description": "Maximum requests per batch."},
"delay": {"type": ["integer", "null"], "description": "Delay before dispatch, in ms."}
}
},
"Telemetry": {
"type": "object",
"properties": {
"requestHeaders": {"type": ["array", "null"], "items": {"type": "string"}}
}
},
"Link": {
"type": "object",
"required": ["src", "type"],
"properties": {
"id": {"type": ["string", "null"]},
"src": {"type": "string", "description": "Path or URL of the linked resource."},
"type": {"description": "The type of link.", "allOf": [{"$ref": "#/definitions/LinkType"}]}
}
},
"HttpVersion": {"type": "string", "enum": ["HTTP1", "HTTP2"]},
"LinkType": {
"type": "string",
"enum": ["Config", "Protobuf", "Script", "Cert", "Key", "Operation", "Htpasswd", "Jwks", "Grpc"]
}
}
}
Loading
Loading