Skip to content
Merged
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
31 changes: 31 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Builds the suite and runs the tests that need no browser, no cloud and no
# keys, so a change here is checked before a language repository picks it up.
name: Build and test

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Build
run: dotnet build -c Release

# No environment variables are set, which is the point: the suite must
# not demand settings that the tests being run do not use.
- name: Test
run: >
dotnet test -c Release --no-build
--filter "TestCategory!=Contract&TestCategory!=CloudInternal"
26 changes: 7 additions & 19 deletions BrowserCache/SessionStorageCacheTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using FiftyOne.Pipeline.Cloud.SeleniumTests.Examples;
using FiftyOne.Pipeline.Cloud.SeleniumTests.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common;
using FiftyOne.Pipeline.Cloud.Tests.Common.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
Expand Down Expand Up @@ -41,31 +40,20 @@ public class SessionStorageCacheTests
[ClassInitialize]
public static void ClassInit(TestContext context)
{
string rootUrl;
string resourceKey;
try
{
rootUrl = TestConfig.Instance().RootUrl;
resourceKey = TestConfig.Instance().PaidResourceKey;
}
catch (InvalidOperationException ex)
{
Assert.Inconclusive(ex.Message);
return;
}

if (!ExampleApps.TryCreate(out _app, out var skipReason))
{
Assert.Inconclusive(skipReason);
return;
}

// An example that is already running (EXAMPLE_URL) was pointed at
// its cloud and given its key by whoever started it, so neither is
// required here. One this suite launches needs both, and a missing
// one fails this class naming the variable.
var options = ExampleApps.BuildOptions(
_app, TestHelpers.GetRandomUnusedPort());

_appTokenSource = new CancellationTokenSource();
var options = new ExampleAppOptions(
TestHelpers.GetRandomUnusedPort(),
new Uri(rootUrl),
resourceKey,
new Dictionary<string, string>());
_app.StartAsync(options, _appTokenSource.Token)
.GetAwaiter().GetResult();
}
Expand Down
21 changes: 6 additions & 15 deletions ClientSideOverrides/ExampleClientSideOverridePageContentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using FiftyOne.Pipeline.Cloud.SeleniumTests.Examples;
using FiftyOne.Pipeline.Cloud.SeleniumTests.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common.TestElements;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
Expand Down Expand Up @@ -55,21 +54,13 @@ public async Task Init()
}
_example = app;

var cloudEndpoint = TestHelpers.GetActualRootUrl(TestInitialiser.CloudServerUrl);
if (string.IsNullOrEmpty(cloudEndpoint))
{
Assert.Inconclusive(
"No external cloud configured. Set CLOUD_ROOT_URL " +
"(e.g. https://cloud.51degrees.com/).");
return;
}

// An example that is already running (EXAMPLE_URL) was pointed at
// its cloud and given its key by whoever started it, so neither is
// required here. One this suite launches needs both, and a missing
// one fails this test naming the variable.
await _example.StartAsync(
new ExampleAppOptions(
Port: TestHelpers.GetRandomUnusedPort(),
CloudEndpoint: new Uri(cloudEndpoint),
ResourceKey: TestResourceKey.PaidResourceKey,
ExtraEnv: new Dictionary<string, string>()),
ExampleApps.BuildOptions(
_example, TestHelpers.GetRandomUnusedPort()),
CancellationToken.None);

// Front the example with a proxy that disables UA client hints, so they
Expand Down
21 changes: 6 additions & 15 deletions ClientSideOverrides/ExampleClientSideOverrideTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using FiftyOne.Pipeline.Cloud.SeleniumTests.Examples;
using FiftyOne.Pipeline.Cloud.SeleniumTests.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common.TestElements;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
Expand Down Expand Up @@ -40,21 +39,13 @@ public async Task Init()
}
_example = app;

var cloudEndpoint = TestHelpers.GetActualRootUrl(TestInitialiser.CloudServerUrl);
if (string.IsNullOrEmpty(cloudEndpoint))
{
Assert.Inconclusive(
"No external cloud configured. Set CLOUD_ROOT_URL " +
"(e.g. https://cloud.51degrees.com/).");
return;
}

// An example that is already running (EXAMPLE_URL) was pointed at
// its cloud and given its key by whoever started it, so neither is
// required here. One this suite launches needs both, and a missing
// one fails this test naming the variable.
await _example.StartAsync(
new ExampleAppOptions(
Port: TestHelpers.GetRandomUnusedPort(),
CloudEndpoint: new Uri(cloudEndpoint),
ResourceKey: TestResourceKey.PaidResourceKey,
ExtraEnv: new Dictionary<string, string>()),
ExampleApps.BuildOptions(
_example, TestHelpers.GetRandomUnusedPort()),
CancellationToken.None);

// Front the example with a proxy that disables UA client hints, so they
Expand Down
33 changes: 12 additions & 21 deletions ClientSideOverrides/ExampleRenderTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using FiftyOne.Pipeline.Cloud.SeleniumTests.Examples;
using FiftyOne.Pipeline.Cloud.SeleniumTests.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common.Helpers;
using FiftyOne.Pipeline.Cloud.Tests.Common.TestElements;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
Expand All @@ -16,8 +14,8 @@
namespace FiftyOne.Pipeline.Cloud.SeleniumTests.ClientSideOverrides
{
/// <summary>
/// Loads a real example app the way an ordinary visitor would — plain
/// desktop Chrome, no mobile emulation and no header-injecting proxy — and
/// Loads a real example app the way an ordinary visitor would, with plain
/// desktop Chrome, no mobile emulation and no header-injecting proxy, and
/// checks that the page the example renders server-side actually contains a
/// real device-detection result. This is the "does the example work at all"
/// counterpart to <see cref="ExampleClientSideOverrideTests"/>, which only
Expand Down Expand Up @@ -68,21 +66,13 @@ public async Task Init()
}
_example = app;

var cloudEndpoint = TestHelpers.GetActualRootUrl(TestInitialiser.CloudServerUrl);
if (string.IsNullOrEmpty(cloudEndpoint))
{
Assert.Inconclusive(
"No external cloud configured. Set CLOUD_ROOT_URL " +
"(e.g. https://cloud.51degrees.com/).");
return;
}

// An example that is already running (EXAMPLE_URL) was pointed at
// its cloud and given its key by whoever started it, so neither is
// required here. One this suite launches needs both, and a missing
// one fails this test naming the variable.
await _example.StartAsync(
new ExampleAppOptions(
Port: TestHelpers.GetRandomUnusedPort(),
CloudEndpoint: new Uri(cloudEndpoint),
ResourceKey: TestResourceKey.PaidResourceKey,
ExtraEnv: new Dictionary<string, string>()),
ExampleApps.BuildOptions(
_example, TestHelpers.GetRandomUnusedPort()),
CancellationToken.None);
}

Expand Down Expand Up @@ -122,9 +112,10 @@ public void Example_RendersRealDetectionResult()
"example did not render a real detection result server-side");

// The device id is the compact form of the whole result, so check it
// where it is rendered. java and rust do not render one server-side,
// and that is a property of those pages rather than of detection, so
// it is checked where present rather than demanded everywhere.
// where it is rendered. The java example renders no device id
// server-side, and that is a property of that page rather than of
// detection, so the id is checked where present rather than
// demanded everywhere.
var deviceId = ValueOfCellAfter(_driver, DeviceIdCellInSameTable);
if (deviceId != null)
{
Expand Down
Loading
Loading