using w4c_workflows.Models.Nodes; using w4c_workflows.Services.Nodes; using w4c_workflows.Services.Nodes.Connectors; using Xunit; namespace w4c_workflows.Tests; /// /// Proves the embedded connector blueprints load from catalog JSON and become /// runnable once a is registered for them — /// i.e. adding an integration is data, not a new executor. /// public class ConnectorCatalogTests { private sealed class NoopFactory : IHttpClientFactory { public HttpClient CreateClient(string name) => new(new HttpClientHandler(), disposeHandler: false); } [Fact] public void Embedded_catalog_exposes_the_telegram_connector() { var blueprint = NodeTestData.CoreCatalog().Get("telegram"); Assert.NotNull(blueprint); Assert.Equal(NodeOrigin.Connector, blueprint!.Origin); Assert.NotNull(blueprint.Connector); Assert.Equal("https://api.telegram.org", blueprint.Connector!.BaseUrl); Assert.Contains("{credential.token}", blueprint.Connector.Path); Assert.Contains(blueprint.Credentials, c => c.Alias == "telegram" && c.Required); } [Fact] public void Embedded_catalog_exposes_the_discord_connector() { var blueprint = NodeTestData.CoreCatalog().Get("discord"); Assert.NotNull(blueprint?.Connector); Assert.Equal("{credential.url}", blueprint!.Connector!.BaseUrl); Assert.Contains(blueprint.Credentials, c => c.Alias == "discord"); } [Fact] public void Connector_blueprints_become_runnable_when_an_executor_is_registered() { var catalog = NodeTestData.CoreCatalog(); var executors = catalog.All .Where(b => b.Connector != null) .Select(b => (INodeExecutor)new RestConnectorExecutor( b, new NoopFactory(), EgressTestData.Guard(), EgressTestData.Quota())) .ToList(); var registry = new NodeExecutorRegistry(executors); Assert.True(registry.CanRun("telegram")); Assert.True(registry.CanRun("discord")); } [Fact] public void Catalog_category_rail_includes_the_integration_category() { Assert.Contains("Communication", NodeTestData.CoreCatalog().Categories); } }