Skip to content

Commit

Permalink
Fixed Playground Options Path Logic (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Aug 9, 2019
1 parent 3e742a7 commit 1820eba
Show file tree
Hide file tree
Showing 79 changed files with 2,419 additions and 207 deletions.
17 changes: 17 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ Task("Build")
DotNetCoreBuild("./tools/Build.sln", settings);
});

Task("BuildDebug")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
{
var buildSettings = new DotNetCoreBuildSettings
{
Configuration = "Debug"
};

DotNetCoreBuild("./tools/Build.sln", buildSettings);
});

Task("BuildCore")
.IsDependentOn("EnvironmentSetup")
.Does(() =>
Expand Down Expand Up @@ -324,6 +336,11 @@ Task("Sonar")
.IsDependentOn("Tests")
.IsDependentOn("SonarEnd");

Task("SonarSlim")
.IsDependentOn("SonarBegin")
.IsDependentOn("BuildDebug")
.IsDependentOn("SonarEnd");

Task("Release")
.IsDependentOn("Sonar")
.IsDependentOn("Publish")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schema {
query: Query
}

type Query {
foo: String
}

input FooFilter {
AND: [FooFilter!]
OR: [FooFilter!]
}

"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text."
scalar String
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schema {
query: Query
}

type Query {
foo: String
}

input FooFilter {
AND: [FooFilter!]
OR: [FooFilter!]
}

"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text."
scalar String
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<PackageReference Include="Microsoft.Owin.StaticFiles" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AspNetClassic.Abstractions\AspNetClassic.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Core\Core\Core.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Core\Core\Core.csproj" />
<ProjectReference Include="..\AspNetClassic.Abstractions\AspNetClassic.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Server/AspNetClassic.Tests/ApplicationBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Http;
using System.Threading.Tasks;
using HotChocolate.Utilities;
using HotChocolate.StarWars;
using Moq;
using Owin;
using Snapshooter.Xunit;
Expand Down
8 changes: 8 additions & 0 deletions src/Server/AspNetClassic.Tests/AspNetClassic.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
<ProjectReference Include="..\..\Core\StarWars\StarWars.csproj" />
<ProjectReference Include="..\..\Core\Subscriptions.InMemory\Subscriptions.InMemory.csproj" />
<ProjectReference Include="..\AspNetClassic.Authorization\AspNetClassic.Authorization.csproj" />
<ProjectReference Include="..\AspNetClassic.GraphiQL\AspNetClassic.GraphiQL.csproj" />
<ProjectReference Include="..\AspNetClassic.Playground\AspNetClassic.Playground.csproj" />
<ProjectReference Include="..\AspNetClassic.Voyager\AspNetClassic.Voyager.csproj" />
<ProjectReference Include="..\AspNetClassic\AspNetClassic.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="GraphiQL\__snapshots__\__mismatch__\" />
<Folder Include="Playground\__snapshots__\__mismatch__\" />
</ItemGroup>

</Project>
193 changes: 193 additions & 0 deletions src/Server/AspNetClassic.Tests/GraphiQL/GraphiQLMiddlewareTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
using System.Net.Http;
using System.Threading.Tasks;
using Snapshooter.Xunit;
using Xunit;
using HotChocolate.AspNetClassic.GraphiQL;
using Microsoft.Owin.Testing;
using Microsoft.Owin;

namespace HotChocolate.AspNetClassic
{
public class GraphiQLMiddlewareTests
: ServerTestBase
{
public GraphiQLMiddlewareTests(TestServerFactory serverFactory)
: base(serverFactory)
{
}

[Fact]
public async Task Default_Values()
{
// arrange
var options = new GraphiQLOptions();

TestServer server = CreateServer(options);
string settingsUri = "/graphiql/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task Disable_Subscriptions()
{
// arrange
var options = new GraphiQLOptions();
options.EnableSubscription = false;

TestServer server = CreateServer(options);
string settingsUri = "/graphiql/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetPath()
{
// arrange
var options = new GraphiQLOptions();
options.Path = new PathString("/foo");

TestServer server = CreateServer(options);
string settingsUri = "/foo/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetPath_Then_SetQueryPath()
{
// arrange
var options = new GraphiQLOptions();
options.Path = new PathString("/foo");
options.QueryPath = new PathString("/bar");

TestServer server = CreateServer(options);
string settingsUri = "/foo/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetQueryPath()
{
// arrange
var options = new GraphiQLOptions();
options.QueryPath = new PathString("/foo");

TestServer server = CreateServer(options);
string settingsUri = "/foo/graphiql/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetQueryPath_Then_SetPath()
{
// arrange
var options = new GraphiQLOptions();
options.QueryPath = new PathString("/foo");
options.Path = new PathString("/bar");

TestServer server = CreateServer(options);
string settingsUri = "/bar/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetQueryPath_Then_SetSubscriptionPath()
{
// arrange
var options = new GraphiQLOptions();
options.QueryPath = new PathString("/foo");
options.SubscriptionPath = new PathString("/bar");

TestServer server = CreateServer(options);
string settingsUri = "/foo/graphiql/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetSubscriptionPath()
{
// arrange
var options = new GraphiQLOptions();
options.SubscriptionPath = new PathString("/foo");

TestServer server = CreateServer(options);
string settingsUri = "/graphiql/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

[Fact]
public async Task SetSubscriptionPath_Then_SetQueryPath()
{
// arrange
var options = new GraphiQLOptions();
options.SubscriptionPath = new PathString("/foo");
options.QueryPath = new PathString("/bar");

TestServer server = CreateServer(options);
string settingsUri = "/bar/graphiql/settings.js";

// act
string settings_js = await GetSettingsAsync(server, settingsUri);

// act
settings_js.MatchSnapshot();
}

private TestServer CreateServer(GraphiQLOptions options)
{
return ServerFactory.Create(
services => services.AddStarWars(),
(app, sp) => app.UseGraphQL(sp).UseGraphiQL(options));
}

private async Task<string> GetSettingsAsync(
TestServer server,
string path)
{
HttpResponseMessage response =
await server.HttpClient.GetAsync(
TestServerExtensions.CreateUrl(path));
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}
}
Loading

0 comments on commit 1820eba

Please sign in to comment.