Skip to content

Commit

Permalink
changes to account for special measure in the test
Browse files Browse the repository at this point in the history
  • Loading branch information
shaed-parkar committed Dec 6, 2024
1 parent 301534e commit 8ae0b44
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
8 changes: 3 additions & 5 deletions UI.AutomationTests/Admin/AdminWebUITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ protected virtual void TearDown()
var passed = TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Skipped ||
TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed;

UiTestReport?.AddScreenshotsToReport(VhDriver.GetDriver());
UiTestReport?.ProcessTest(VhDriver.GetDriver());
UiTestReport?.Flush();

BuildUiReport(VhDriver);

VhDriver.PublishTestResult(passed);
VhDriver.Terminate();
}

/// <summary>
/// Run ad-hoc clean up tasks for a test
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion UI.AutomationTests/Admin/Booking/BookHearingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public void BookAHearing()

var videoAccessPointsPage = addParticipantPage.GoToVideoAccessPointsPage();
videoAccessPointsPage.AddVideoAccessPoints(_bookingDto.VideoAccessPoints);
var otherInformationPage = videoAccessPointsPage.GoToOtherInformationPage();

var otherInformationPage = FeatureToggle.Instance().SpecialMeasuresEnabled() ?
videoAccessPointsPage.GoToSpecialMeasuresPage().GoToOtherInformationPage() :
videoAccessPointsPage.GoToOtherInformationPage();
otherInformationPage.TurnOffAudioRecording();
otherInformationPage.EnterOtherInformation(_bookingDto.OtherInformation);

Expand Down
7 changes: 7 additions & 0 deletions UI.AutomationTests/CommonUiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ protected void SetupUiTestReport()
UiTestReport.SetupTest(testName, description, categories);
}

protected void BuildUiReport(IVhDriver vhDriver)
{
UiTestReport?.AddScreenshotsToReport(vhDriver.GetDriver());
UiTestReport?.ProcessTest(vhDriver.GetDriver());
UiTestReport?.Flush();
}

private async Task DeleteUsers()
{
foreach (var userPrincipleName in CreatedUsers)
Expand Down
5 changes: 0 additions & 5 deletions UI.AutomationTests/Drivers/RemoteChromeVhDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,4 @@ public void PublishTestResult(bool passed)
TestContext.Out.WriteLine($"<{e.GetType().Name}> Failed to report test status to SauceLabs: {e.Message}");
}
}

public void CaptureScreenShot()
{
throw new NotImplementedException();
}
}
6 changes: 5 additions & 1 deletion UI.AutomationTests/Reporters/TestReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public void ProcessTest(IWebDriver driver)
var logStatus = ConvertNUnitTestResultToExtentReportLogStatus();
var test = _tests[TestContext.CurrentContext.Test.Name];
var sb = new StringBuilder(TestContext.CurrentContext.Result.Message);
sb.AppendLine(TestContext.CurrentContext.Result.StackTrace);
if (logStatus != Status.Pass)
{
sb.AppendLine(TestContext.CurrentContext.Result.StackTrace);
}

LogEntry(test, logStatus, sb.ToString(), driver.TakeScreenshotAsBase64());
_extent.Flush();
}
Expand Down
3 changes: 3 additions & 0 deletions UI.AutomationTests/Video/VideoWebUiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected virtual void Setup()
{
Environment.SetEnvironmentVariable(VhPage.VHTestNameKey, TestContext.CurrentContext.Test.Name);
AdminWebDriver = CreateDriver("AdminWeb");
SetupUiTestReport();
}

[TearDown]
Expand All @@ -49,12 +50,14 @@ public void TearDown()
TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed;

AdminWebDriver.PublishTestResult(passed);
BuildUiReport(AdminWebDriver);
AdminWebDriver.Terminate();
AdminWebDriver = null;

ParticipantDrivers.Values.ToList().ForEach(x =>
{
x.Driver.PublishTestResult(passed);
BuildUiReport(x.Driver);
x.Driver.Terminate();
});
ParticipantDrivers.Clear();
Expand Down
4 changes: 0 additions & 4 deletions UI.Common/UI.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
<PackageReference Include="Microsoft.Identity.Client" Version="4.66.2" />
</ItemGroup>

<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions UI.PageModels/Pages/Admin/Booking/BookingDetailsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public BookingConfirmationPage AddParticipantsToBooking(List<BookingParticipantD
var participantsPage = new ParticipantsPage(Driver, DefaultWaitTime);
participantsPage.AddParticipants(participantsToAdd);
var videoAccessPointsPage = participantsPage.GoToVideoAccessPointsPage();
// use existing booking flow (i.e. next on vap goes to summary page)
var summaryPage = videoAccessPointsPage.GoToSummaryPage();
// use existing booking flow (i.e. next on vap goes screening (if enabled) and then to summary page)
var summaryPage = FeatureToggle.Instance().SpecialMeasuresEnabled() ?
videoAccessPointsPage.GoToSpecialMeasuresPage().GoToSummaryPage()
: videoAccessPointsPage.GoToSummaryPage();
return summaryPage.ClickBookButton();
}

Expand Down
8 changes: 6 additions & 2 deletions UI.PageModels/Pages/Admin/Booking/HearingDetailsPage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace UI.PageModels.Pages.Admin.Booking;
using UI.Common.Utilities;

namespace UI.PageModels.Pages.Admin.Booking;

public class HearingDetailsPage(IWebDriver driver, int defaultWaitTime) : VhAdminWebPage(driver, defaultWaitTime)
{
Expand Down Expand Up @@ -59,7 +61,9 @@ public SummaryPage BookAHearingJourney(BookingDto bookingDto, bool isMultiDay =

var videoAccessPointsPage = addParticipantPage.GoToVideoAccessPointsPage();
videoAccessPointsPage.AddVideoAccessPoints(bookingDto.VideoAccessPoints);
var otherInformationPage = videoAccessPointsPage.GoToOtherInformationPage();
var otherInformationPage = FeatureToggle.Instance().SpecialMeasuresEnabled() ?
videoAccessPointsPage.GoToSpecialMeasuresPage().GoToOtherInformationPage() :
videoAccessPointsPage.GoToOtherInformationPage();
otherInformationPage.TurnOffAudioRecording();
otherInformationPage.EnterOtherInformation(bookingDto.OtherInformation);

Expand Down

0 comments on commit 8ae0b44

Please sign in to comment.