-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests for accepting rejecting cancelling cases (#826)
* Added test class * Added End to End tests for acceepting / rejecting / cancelling cases * Amended to run tests for both change of name and change of date of birth scenarios
- Loading branch information
Showing
4 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
141 changes: 141 additions & 0 deletions
141
TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/CaseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using TeachingRecordSystem.TestCommon; | ||
|
||
namespace TeachingRecordSystem.SupportUi.EndToEndTests; | ||
|
||
public class CaseTests : TestBase | ||
{ | ||
public CaseTests(HostFixture hostFixture) | ||
: base(hostFixture) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public async Task SelectCaseAndApprove(bool isNameChange) | ||
{ | ||
var createPersonResult = await TestData.CreatePerson(); | ||
string caseReference; | ||
if (isNameChange) | ||
{ | ||
var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); | ||
caseReference = createIncidentResult.TicketNumber; | ||
} | ||
else | ||
{ | ||
var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); | ||
caseReference = createIncidentResult.TicketNumber; | ||
} | ||
|
||
await using var context = await HostFixture.CreateBrowserContext(); | ||
var page = await context.NewPageAsync(); | ||
|
||
await page.GoToHomePage(); | ||
|
||
await page.ClickOpenCasesLinkInNavigationBar(); | ||
|
||
await page.AssertOnOpenCasesPage(); | ||
|
||
await page.ClickCaseReferenceLinkOpenCasesPage(caseReference); | ||
|
||
await page.AssertOnCaseDetailPage(caseReference); | ||
|
||
await page.ClickAcceptChangeButton(); | ||
|
||
await page.AssertOnAcceptCasePage(caseReference); | ||
|
||
await page.ClickConfirmButton(); | ||
|
||
await page.AssertOnOpenCasesPage(); | ||
|
||
await page.AssertFlashMessage("The request has been accepted"); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public async Task SelectCaseAndReject(bool isNameChange) | ||
{ | ||
var createPersonResult = await TestData.CreatePerson(); | ||
string caseReference; | ||
if (isNameChange) | ||
{ | ||
var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); | ||
caseReference = createIncidentResult.TicketNumber; | ||
} | ||
else | ||
{ | ||
var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); | ||
caseReference = createIncidentResult.TicketNumber; | ||
} | ||
|
||
await using var context = await HostFixture.CreateBrowserContext(); | ||
var page = await context.NewPageAsync(); | ||
|
||
await page.GoToHomePage(); | ||
|
||
await page.ClickOpenCasesLinkInNavigationBar(); | ||
|
||
await page.AssertOnOpenCasesPage(); | ||
|
||
await page.ClickCaseReferenceLinkOpenCasesPage(caseReference); | ||
|
||
await page.AssertOnCaseDetailPage(caseReference); | ||
|
||
await page.ClickRejectChangeButton(); | ||
|
||
await page.AssertOnRejectCasePage(caseReference); | ||
|
||
await page.CheckAsync("label:text-is('Request and proof don’t match')"); | ||
|
||
await page.ClickConfirmButton(); | ||
|
||
await page.AssertOnOpenCasesPage(); | ||
|
||
await page.AssertFlashMessage("The request has been rejected"); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public async Task SelectCaseAndCancel(bool isNameChange) | ||
{ | ||
var createPersonResult = await TestData.CreatePerson(); | ||
string caseReference; | ||
if (isNameChange) | ||
{ | ||
var createIncidentResult = await TestData.CreateNameChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); | ||
caseReference = createIncidentResult.TicketNumber; | ||
} | ||
else | ||
{ | ||
var createIncidentResult = await TestData.CreateDateOfBirthChangeIncident(b => b.WithCustomerId(createPersonResult.ContactId)); | ||
caseReference = createIncidentResult.TicketNumber; | ||
} | ||
|
||
await using var context = await HostFixture.CreateBrowserContext(); | ||
var page = await context.NewPageAsync(); | ||
|
||
await page.GoToHomePage(); | ||
|
||
await page.ClickOpenCasesLinkInNavigationBar(); | ||
|
||
await page.AssertOnOpenCasesPage(); | ||
|
||
await page.ClickCaseReferenceLinkOpenCasesPage(caseReference); | ||
|
||
await page.AssertOnCaseDetailPage(caseReference); | ||
|
||
await page.ClickRejectChangeButton(); | ||
|
||
await page.AssertOnRejectCasePage(caseReference); | ||
|
||
await page.CheckAsync("label:text-is('Change no longer required')"); | ||
|
||
await page.ClickConfirmButton(); | ||
|
||
await page.AssertOnOpenCasesPage(); | ||
|
||
await page.AssertFlashMessage("The request has been cancelled"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/PageExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Microsoft.Playwright; | ||
|
||
namespace TeachingRecordSystem.SupportUi.EndToEndTests; | ||
|
||
public static class PageExtensions | ||
{ | ||
public static Task WaitForUrlPathAsync(this IPage page, string path) => | ||
page.WaitForURLAsync(url => | ||
{ | ||
var asUri = new Uri(url); | ||
return asUri.LocalPath == path; | ||
}); | ||
|
||
public static async Task GoToHomePage(this IPage page) | ||
{ | ||
await page.GotoAsync("/"); | ||
} | ||
|
||
public static async Task ClickOpenCasesLinkInNavigationBar(this IPage page) | ||
{ | ||
await page.ClickAsync("a:text-is('Open cases')"); | ||
} | ||
|
||
public static async Task AssertOnOpenCasesPage(this IPage page) | ||
{ | ||
await page.WaitForUrlPathAsync("/cases"); | ||
} | ||
|
||
public static async Task ClickCaseReferenceLinkOpenCasesPage(this IPage page, string caseReference) | ||
{ | ||
await page.ClickAsync($"a:text-is('{caseReference}')"); | ||
} | ||
|
||
public static async Task AssertOnCaseDetailPage(this IPage page, string caseReference) | ||
{ | ||
await page.WaitForUrlPathAsync($"/cases/{caseReference}"); | ||
} | ||
|
||
public static async Task AssertOnAcceptCasePage(this IPage page, string caseReference) | ||
{ | ||
await page.WaitForUrlPathAsync($"/cases/{caseReference}/accept"); | ||
} | ||
|
||
public static async Task AssertOnRejectCasePage(this IPage page, string caseReference) | ||
{ | ||
await page.WaitForUrlPathAsync($"/cases/{caseReference}/reject"); | ||
} | ||
|
||
public static async Task AssertFlashMessage(this IPage page, string expectedHeader) | ||
{ | ||
Assert.Equal(expectedHeader, await page.InnerTextAsync($".govuk-notification-banner__heading:text-is('{expectedHeader}')")); | ||
} | ||
|
||
public static Task ClickAcceptChangeButton(this IPage page) | ||
=> ClickButton(page, "Accept change"); | ||
|
||
public static Task ClickRejectChangeButton(this IPage page) | ||
=> ClickButton(page, "Reject change"); | ||
|
||
public static Task ClickConfirmButton(this IPage page) | ||
=> ClickButton(page, "Confirm"); | ||
|
||
private static Task ClickButton(this IPage page, string text) => | ||
page.ClickAsync($".govuk-button:text-is('{text}')"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters