Skip to content

Commit 0fcf8e1

Browse files
authored
Merge branch 'main' into feat/DTOSS-8352-PDS-add-record
2 parents 0140845 + 8193c6f commit 0fcf8e1

7 files changed

Lines changed: 170 additions & 7 deletions

File tree

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/TransformDataService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public async Task<CohortDistributionParticipant> TransformParticipantAsync(Cohor
141141

142142
var resultList = await re.ExecuteAllRulesAsync("Common", ruleParameters);
143143

144-
if (!participant.ReferralFlag.Value)
144+
if (!participant.ReferralFlag ?? false)
145145
{
146146
resultList.AddRange(await re.ExecuteAllRulesAsync("Routine", ruleParameters));
147147
}

application/CohortManager/src/Functions/CohortDistributionServices/TransformDataService/characterRules.json

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,103 @@
165165
"OnSuccess": {
166166
"Name": "OutputExpression",
167167
"Context": {
168-
"Expression": "'/'"
168+
"Expression": "'-'"
169+
}
170+
}
171+
}
172+
},
173+
{
174+
"RuleName": "Forwardslash",
175+
"Expression": "input1 == 47",
176+
"Actions": {
177+
"OnSuccess": {
178+
"Name": "OutputExpression",
179+
"Context": {
180+
"Expression": "'-'"
181+
}
182+
}
183+
}
184+
},
185+
{
186+
"RuleName": "Quote",
187+
"Expression": "input1 == 34",
188+
"Actions": {
189+
"OnSuccess": {
190+
"Name": "OutputExpression",
191+
"Context": {
192+
"Expression": "' '"
193+
}
194+
}
195+
}
196+
},
197+
{
198+
"RuleName": "LessThan",
199+
"Expression": "input1 == 60",
200+
"Actions": {
201+
"OnSuccess": {
202+
"Name": "OutputExpression",
203+
"Context": {
204+
"Expression": "' '"
205+
}
206+
}
207+
}
208+
},
209+
{
210+
"RuleName": "Equals",
211+
"Expression": "input1 == 61",
212+
"Actions": {
213+
"OnSuccess": {
214+
"Name": "OutputExpression",
215+
"Context": {
216+
"Expression": "' '"
217+
}
218+
}
219+
}
220+
},
221+
{
222+
"RuleName": "GreaterThan",
223+
"Expression": "input1 == 62",
224+
"Actions": {
225+
"OnSuccess": {
226+
"Name": "OutputExpression",
227+
"Context": {
228+
"Expression": "' '"
229+
}
230+
}
231+
}
232+
},
233+
{
234+
"RuleName": "SemiColon",
235+
"Expression": "input1 == 59",
236+
"Actions": {
237+
"OnSuccess": {
238+
"Name": "OutputExpression",
239+
"Context": {
240+
"Expression": "':'"
241+
}
242+
}
243+
}
244+
},
245+
{
246+
"RuleName": "Percentage",
247+
"Expression": "input1 == 37",
248+
"Actions": {
249+
"OnSuccess": {
250+
"Name": "OutputExpression",
251+
"Context": {
252+
"Expression": "' '"
253+
}
254+
}
255+
}
256+
},
257+
{
258+
"RuleName": "Ampersand",
259+
"Expression": "input1 == 38",
260+
"Actions": {
261+
"OnSuccess": {
262+
"Name": "OutputExpression",
263+
"Context": {
264+
"Expression": "' and '"
169265
}
170266
}
171267
}

application/CohortManager/src/Web/app/components/sortExceptionsForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default function SortExceptionsForm({
3838
className="nhsuk-button app-button--small"
3939
data-module="nhsuk-button"
4040
type="submit"
41+
data-testid="apply-button"
4142
>
4243
Apply
4344
</button>

application/CohortManager/src/Web/tests/features/notRaisedExceptionOverview.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,18 @@ Feature: testing Breast screening - Not raisedexception overview page
3333
Scenario: verify navigation to cookies screen
3434
And the user clicks on cookies link
3535
Then they should navigate to 'Cookies on Cohort Manager - Cohort Manager - NHS'
36+
37+
@epic_4a @req_6975 @test_9966
38+
Scenario: verify sorting by with Date exception created (newest first)
39+
When the user sorts the exception summary table by 'Date exception created (newest first)'
40+
Then the exception summary table should be sorted by Date exception created in descending order
41+
42+
@epic_4a @req_6975 @test_9974
43+
Scenario: verify sorting by with Date exception created (oldest first)
44+
When the user sorts the exception summary table by 'Date exception created (oldest first)'
45+
Then the exception summary table should be sorted by Date exception created in ascending order
46+
47+
@epic_4a @req_6975 @test_9968
48+
Scenario: verify sorting by with unsupported sort option
49+
When the user sorts with unsupported options by 'exception created (oldest first)'
50+
Then the error message should thrown

application/CohortManager/src/Web/tests/features/pages/exceptionOverviewPage.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect, Locator, Page } from "@playwright/test";
22
import BasePage from "./basePage";
3-
4-
53
export class ExceptionOverviewPage extends BasePage {
64
readonly page!: Page;
75
readonly exceptionTable: Locator;
86
readonly exceptiontableHeaders: Locator;
97
readonly homepageLink: Locator;
108
readonly exceptionIDLink: Locator;
9+
readonly sortByDateExceptionCreated: Locator;
10+
readonly applyButton: Locator;
1111

1212
constructor(page: Page) {
1313
super(page)
@@ -17,6 +17,8 @@ export class ExceptionOverviewPage extends BasePage {
1717
this.homepageLink = page.getByRole('link', { name: 'Home', exact: true });
1818
this.exceptionIDLink = page.locator('[data-testid="exceptions-table"] tbody tr:first-child td:nth-child(1) a');
1919
//this.exceptionIDLink = page.locator('[data-testid="exceptions-table"] tbody tr:nth-child(2) td:nth-child(1) a');
20+
this.sortByDateExceptionCreated = page.locator('[data-testid="sort-not-raised-exceptions"]');
21+
this.applyButton = page.locator('[data-testid="apply-button"]');
2022
}
2123
async getTableHeaders(): Promise<string[]> {
2224
return this.page.$$eval('[data-testid="exceptions-table"] th', headers =>
@@ -39,11 +41,20 @@ export class ExceptionOverviewPage extends BasePage {
3941
// Optionally, check for clickable/sortable role
4042
const role = await headers.nth(i).getAttribute('role');
4143
expect(role).not.toBe('button');
42-
4344
}
4445
}
4546
async clickOnexceptionID() {
4647
await this.clickElement(this.exceptionIDLink)
4748
}
49+
async sortByDateExceptionCreatedDescending(optionText: string) {
50+
// Adjust selector to match your sortable column header
51+
await this.sortByDateExceptionCreated.selectOption({ label: optionText });
52+
await this.applyButton.click();
53+
}
54+
async getDateExceptionCreatedColumn(): Promise<Date[]> {
55+
// Adjust selector to match the correct column index for "Date exception created"
56+
const dateCells = await this.page.locator('[data-testid="exceptions-table"] tbody tr td:nth-child(3)').allTextContents();
57+
return dateCells.map(text => new Date(text.trim()));
58+
}
4859

4960
}

application/CohortManager/src/Web/tests/features/steps/exceptionoverviewSteps.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,43 @@ Given('the user navigate to not raised exception overview page', async ({ page }
4444
await page.waitForTimeout(3000);
4545

4646
});
47+
When('the user sorts the exception summary table by {string}', async ({ page }, sortOption: string) => {
48+
const exceptionOverviewPage = new ExceptionOverviewPage(page);
49+
await exceptionOverviewPage.sortByDateExceptionCreatedDescending(sortOption);
50+
await page.waitForTimeout(3000);
51+
});
52+
Then('the exception summary table should be sorted by Date exception created in descending order', async ({ page }) => {
53+
const exceptionOverviewPage = new ExceptionOverviewPage(page);
54+
const dates = await exceptionOverviewPage.getDateExceptionCreatedColumn();
55+
const sorted = [...dates].sort((a, b) => b.getTime() - a.getTime());
56+
expect(dates).toEqual(sorted);
57+
});
58+
Then('the exception summary table should be sorted by Date exception created in ascending order', async ({ page }) => {
59+
const exceptionOverviewPage = new ExceptionOverviewPage(page);
60+
const dates = await exceptionOverviewPage.getDateExceptionCreatedColumn();
61+
const sorted = [...dates].sort((a, b) => a.getTime() - b.getTime());
62+
expect(dates).toEqual(sorted);
63+
});
64+
// Use a WeakMap to store sort errors per context
65+
const sortErrorMap = new WeakMap();
66+
When('the user sorts with unsupported options by {string}', async ({ page }, sortOption: string) => {
67+
const exceptionOverviewPage = new ExceptionOverviewPage(page);
68+
try {
69+
await Promise.race([
70+
exceptionOverviewPage.sortByDateExceptionCreatedDescending(sortOption),
71+
new Promise((_, reject) => setTimeout(() => reject(new Error('Custom timeout')), 3000))
72+
]);
73+
sortErrorMap.set(page.context(), null);
74+
} catch (error) {
75+
sortErrorMap.set(page.context(), error);
76+
}
77+
});
78+
Then('the error message should thrown', async ({ page }) => {
79+
// Retrieve the error from the WeakMap for this context
80+
const error = sortErrorMap.get(page.context());
81+
expect(error).toBeDefined();
82+
expect(
83+
error.message.includes('did not find some options') ||
84+
error.message.includes('Custom timeout')
85+
).toBe(true);
86+
});

tests/UnitTests/TransformDataServiceTests/TransformDataServiceTests/TransformDataServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ public void GetAddress_AddressFieldsBlankPostcodeNotNull_ReturnAddress()
399399
//[DataRow("John.,-()/='+:?!\"%&;<>*", "John.,-()/='+:?!\"%&;<>*")]
400400
[DataRow("abby{}", "abby()")]
401401
[DataRow("abc_", "abc-")]
402-
[DataRow("abc\\", "abc/")]
403-
[DataRow("{[Smith£$^`~#@_|\\]}", "((Smith ' -:/))")]
402+
[DataRow("abc\\", "abc-")]
403+
[DataRow("{[Smith£$^`~#@_|\\]}", "((Smith ' -:-))")]
404404
public async Task Run_InvalidCharsInParticipant_ReturnTransformedFields(string name, string transformedName)
405405
{
406406
// Arrange

0 commit comments

Comments
 (0)