Skip to content

Commit

Permalink
Merge branch 'master' into exui-2078-high-vuln
Browse files Browse the repository at this point in the history
  • Loading branch information
RiteshHMCTS committed Jul 22, 2024
2 parents 6bb6f4c + f8a56b3 commit 88251fd
Show file tree
Hide file tree
Showing 36 changed files with 1,402 additions and 1,473 deletions.
3 changes: 2 additions & 1 deletion api/workAllocation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ export async function getRolesCategory(req: EnhancedRequest, res: Response) {
const personRoles = [
{ roleId: 'judicial', roleName: 'Judicial' },
{ roleId: 'legalOps', roleName: 'Legal Ops' },
{ roleId: 'admin', roleName: 'Admin' }];
{ roleId: 'admin', roleName: 'Admin' },
{ roleId: 'ctsc', roleName: 'CTSC' }];
return res.send(personRoles).status(200);
}

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rpx-exui",
"version": "7.0.6",
"version": "7.0.10",
"engines": {
"node": ">=18.17.0"
},
Expand Down Expand Up @@ -53,7 +53,7 @@
"test:smoke:local": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/smoke.conf.js --local",
"test:crossbrowser": "protractor ./test/e2e/config/crossbrowser.conf.js",
"test:fullfunctional": "yarn run test:xuiIntegration && yarn run test:functionalApiE2e",
"test:fullfunctional2": "yarn playwright install && npx playwright test --project MicrosoftEdge",
"test:fullfunctional2": "yarn playwright install && npx playwright test --project chromium",
"test:fullfunctional:local": "webdriver-manager update --versions.chrome 2.40 && protractor ./test/e2e/config/fullfunctional.conf.js --local",
"test:functional1": "yarn run test:xuiIntegration && yarn run test:functionalApiE2e",
"test:functional_old": "yarn test:api && yarn run test:xuiIntegration && yarn run test:codeceptE2E",
Expand Down Expand Up @@ -92,13 +92,13 @@
"@angular/router": "^17.3.6",
"@angular/ssr": "^17.3.6",
"@edium/fsm": "^2.1.2",
"@hmcts/ccd-case-ui-toolkit": "7.0.46",
"@hmcts/ccd-case-ui-toolkit": "7.0.50",
"@hmcts/ccpay-web-component": "6.2.1",
"@hmcts/frontend": "0.0.50-alpha",
"@hmcts/media-viewer": "4.0.4",
"@hmcts/nodejs-healthcheck": "1.7.0",
"@hmcts/properties-volume": "^0.0.13",
"@hmcts/rpx-xui-common-lib": "2.0.23",
"@hmcts/rpx-xui-common-lib": "2.0.24",
"@hmcts/rpx-xui-node-lib": "2.29.0",
"@microsoft/applicationinsights-web": "^3.1.0",
"@ng-idle/core": "^14.0.0",
Expand Down
20 changes: 11 additions & 9 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { defineConfig, devices } from "@playwright/test";

const headlessMode = process.env.HEAD !== 'true';

module.exports = defineConfig({
testDir: "./playwright_tests/E2E",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: 4, // Set the number of retries for all projects
retries: 3, // Set the number of retries for all projects

timeout: 10 * 60 * 1000, // 10 minutes
timeout: 3 * 60 * 1000,
expect: {
timeout: 5 * 60 * 1000, // 5 minutes
timeout: 1 * 60 * 1000,
},
reportSlowTests: null,

Expand All @@ -23,39 +25,39 @@ module.exports = defineConfig({
name: "chromium",
use: { ...devices["Desktop Chrome"],
channel: "chrome",
headless: false,
headless: headlessMode,
trace: "on-first-retry",
},
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"],
screenshot: 'only-on-failure',
headless: false,
headless: headlessMode,
trace: 'off'
},
},
{
name: "webkit",
use: { ...devices["Desktop Safari"],
screenshot: 'only-on-failure',
headless: false,
headless: headlessMode,
trace: 'off'
},
},
{
name: "MobileChrome",
use: { ...devices["Pixel 5"],
screenshot: 'only-on-failure',
headless: false,
headless: headlessMode,
trace: 'off'
},
},
{
name: "MobileSafari",
use: { ...devices["iPhone 12"],
screenshot: 'only-on-failure',
headless: false,
headless: headlessMode,
trace: 'off'
},
},
Expand All @@ -64,7 +66,7 @@ module.exports = defineConfig({
use: { ...devices["Desktop Edge"],
channel: "msedge",
screenshot: 'only-on-failure',
headless: false,
headless: headlessMode,
trace: 'off'
},
},
Expand Down
10 changes: 7 additions & 3 deletions playwright_tests/E2E/global-search.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from '@playwright/test';
import { signIn } from './steps/login-steps';
import { clickOnMainMenu } from './steps/steps-functions';
import { retryAction } from './steps/retry-steps';

test('Search from menu 16-digit find control', async ({ page }) => {
await signIn(page, 'IAC_CaseOfficer_R2');
Expand All @@ -9,9 +10,12 @@ test('Search from menu 16-digit find control', async ({ page }) => {
const caseId = findCaseId(page)
await expect(page.getByText('-digit case reference:')).toBeVisible();
await page.getByLabel('-digit case reference:').click();
await page.getByLabel('-digit case reference:').fill(caseId);
await page.getByRole('button', { name: 'Find' }).click();

await page.getByLabel('-digit case reference:').fill(caseId);
await retryAction(async () => {
await page.getByRole('button', { name: 'Find' }).click();
await expect(page.getByRole('heading', { name: 'Current progress of the case' })).toBeVisible();
});

console.log('Check the case details are displayed');
await expect(page.getByRole('heading', { name: 'Current progress of the case' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Do this next' })).toBeVisible();
Expand Down
8 changes: 3 additions & 5 deletions playwright_tests/E2E/staff-search.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { test, expect } from '@playwright/test';
import { signIn, signOut } from "./steps/login-steps";
import { clickToStaffPage } from "./steps/staff-steps";
import { clickToStaffPage, fillSearchBox } from "./steps/staff-steps";

test('Simplified search results', async ({ page }) => {
await signIn(page, "STAFF_ADMIN");
await clickToStaffPage(page);

console.log("Using simple search");
await page.locator('#main-content').getByRole('textbox').click();
await page.locator('#main-content').getByRole('textbox').fill('xui');
await fillSearchBox(page);
await page.getByRole('button', { name: 'Search' }).click();
await expect(page.locator('exui-staff-user-list')).toContainText('Showing 1');

Expand All @@ -20,8 +19,7 @@ test('Simplified search', async ({ page }) => {
await clickToStaffPage(page);

console.log("Using Simple search");
await page.locator('#main-content').getByRole('textbox').click();
await page.locator('#main-content').getByRole('textbox').fill('xui');
await fillSearchBox(page);
await page.getByRole('button', { name: 'Search' }).click();
await expect(page.getByRole('columnheader', { name: 'Job title' })).toBeVisible();
await expect(page.locator('exui-staff-user-list')).toContainText('Showing 1');
Expand Down
12 changes: 12 additions & 0 deletions playwright_tests/E2E/steps/retry-steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export async function retryAction(action: () => Promise<void>, numberOfTries: number = 5) {
for (let i = 0; i < numberOfTries; i++) {
try {
await action();
break; // Exit loop if action succeeds
} catch (error) {
console.log(`Action failed, retrying (${i + 1}/${numberOfTries})...`);
if (i === numberOfTries - 1) throw error; // Rethrow error on last attempt
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1 second before retrying
}
}
}
32 changes: 17 additions & 15 deletions playwright_tests/E2E/steps/staff-steps.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
export async function clickToStaffPage(page) {
console.log("Going to Staff Page");
const numberOfTries = 5;
for (let i = 0; i < numberOfTries; i++) {
try {
await page.getByRole('link', { name: 'Staff' }).click();
await page.waitForSelector('text=User list', { state: 'visible', timeout: 1000 });
break;
} catch (error) {
console.log(`Click to staff page failed, retrying (${i + 1}/${numberOfTries})...`);
if (i !== numberOfTries) await page.waitForTimeout(1000); // Wait 1 second before the next attempt
else throw error;
}
}
}
import { retryAction } from './retry-steps';

export async function clickToStaffPage(page) {
console.log("Going to Staff Page");
await retryAction(async () => {
await page.getByRole('link', { name: 'Staff' }).click();
await page.waitForSelector('text=User list', { state: 'visible', timeout: 1000 });
});
}

export async function fillSearchBox(page) {
console.log("Fill SearchBox");
await retryAction(async () => {
await page.locator('#main-content').getByRole('textbox').click();
await page.locator('#main-content').getByRole('textbox').fill('xui');
});
}
13 changes: 6 additions & 7 deletions playwright_tests/E2E/workallocation2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,9 @@ test('View tasks, E2E journey of Caseworker-ia-officer user', async ({ page }) =
await page.getByRole('link', { name: 'All work' }).click();
await expect(page.getByRole('heading', { name: 'All work' })).toBeVisible();
await checkAllHeadersTabMenu(page);

console.log("Case list tabs");
await page.getByRole('link', { name: 'Case list' }).click();
await expect(page.getByRole('heading', { name: 'Case list' })).toBeVisible();
await checkAllHeadersTabMenu(page);

await page.getByRole('link', { name: 'Create case' }).click();

console.log("Create case tabs");
await page.getByRole('link', { name: 'Create case' }).click();
await expect(page.getByRole('heading', { name: 'Create Case' })).toBeVisible();
await checkAllHeadersTabMenu(page);

Expand All @@ -73,6 +67,11 @@ test('View tasks, E2E journey of Caseworker-ia-officer user', async ({ page }) =
await expect(page.locator('[data-test="search-result-summary__text"]')).toBeVisible();
await assertTableColumnNames(page, false, true);
await page.getByRole('button', { name: '▼ Case category ▲' }).click();

console.log("Case list tabs");
await page.getByRole('link', { name: 'Case list' }).click();
await expect(page.getByRole('heading', { name: 'Case list' })).toBeVisible();
await checkAllHeadersTabMenu(page);
});

async function checkAllHeadersTabMenu(page) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/get-help/get-help.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class GetHelpComponent implements OnInit {
this.userDetails$ = this.store.pipe(select(fromRoot.getUserDetails));
this.userDetails$.subscribe((userDetail: UserDetails) => {
if (userDetail && userDetail.userInfo) {
this.caseManager = userDetail.userInfo.roles && userDetail.userInfo.roles.includes('pui-case-manager');
this.caseManager = userDetail?.userInfo?.roles.includes('pui-case-manager');
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class HmctsGlobalHeaderComponent implements OnInit, OnChanges {
this.userDetails$ = this.appStore.pipe(select(fromAppStore.getUserDetails));
this.isUserCaseManager$ = this.userDetails$.pipe(
skipWhile((details) => !('userInfo' in details)),
map((details) => details.userInfo.roles),
map((details) => details?.userInfo?.roles),
map((roles) => {
const givenRoles = ['pui-case-manager', 'caseworker-ia-legalrep-solicitor', 'caseworker-ia-homeofficeapc', 'caseworker-ia-respondentofficer', 'caseworker-ia-homeofficelart', 'caseworker-ia-homeofficepou'];
return givenRoles.filter((x) => roles.includes(x)).length > 0;
Expand Down Expand Up @@ -119,7 +119,7 @@ export class HmctsGlobalHeaderComponent implements OnInit, OnChanges {
items = items || [];
return this.userService.getUserDetails().pipe(
skipWhile((details) => !('userInfo' in details)),
map((details) => details.userInfo.roles),
map((details) => details?.userInfo?.roles),
map((roles) => {
const i = items.filter((item) => (item.roles && item.roles.length > 0 ? item.roles.some((role) => roles.includes(role)) : true));
return i.filter((item) => (item.notRoles && item.notRoles.length > 0 ? item.notRoles.every((role) => !roles.includes(role)) : true));
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/routing/application-routing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export class ApplicationRoutingComponent implements OnInit {
if (bookingFeatureToggle && AppUtils.isBookableAndJudicialRole(userDetails)) {
return this.router.navigate([ApplicationRoutingComponent.bookingUrl]);
}
if (userDetails && userDetails.userInfo && userDetails.userInfo.roles
&& !userDetails.userInfo.roles.includes('pui-case-manager')) {
if (!(userDetails?.userInfo?.roles?.includes('pui-case-manager'))) {
const userRoles = userDetails.userInfo.roles;
let rolePresent = false;
for (let i = 0, len = landingRoles.roles.length; i < len; i++) {
Expand Down
4 changes: 4 additions & 0 deletions src/app/containers/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ td {
;
}

.hmcts-primary-navigation__container {
text-align: initial;
}

// gov uk frond-end template is not installed on this
.js-hidden {
display: none;
Expand Down
2 changes: 1 addition & 1 deletion src/app/containers/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class AppComponent implements OnInit, OnDestroy {
if (userInfo) {
const featureUser: FeatureUser = {
key: userInfo.id || userInfo.uid,
roles: userInfo.roles,
roles: userInfo?.roles,
orgId: '-1'
};
console.log(`LD Client: ${ldClientId}`);
Expand Down
2 changes: 1 addition & 1 deletion src/app/guards/case-allocator.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CaseAllocatorGuard {
const userInfoStr = this.sessionStorageService.getItem('userDetails');
if (userInfoStr) {
const userInfo: UserInfo = JSON.parse(userInfoStr);
const roleExists = userInfo.roles.includes('case-allocator');
const roleExists = userInfo?.roles.includes('case-allocator');
if (!roleExists) {
this.router.navigateByUrl('/cases');
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/guards/task-supervisor.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class TaskSupervisorGuard {
const userInfoStr = this.sessionStorageService.getItem('userDetails');
if (userInfoStr) {
const userInfo: UserInfo = JSON.parse(userInfoStr);
const roleExists = userInfo.roles.includes('task-supervisor');
const roleExists = userInfo?.roles.includes('task-supervisor');
if (!roleExists) {
this.router.navigateByUrl('/cases');
}
Expand Down
18 changes: 18 additions & 0 deletions src/app/models/error-message.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,21 @@ export interface MultipleErrorMessage {
error: string;
name?: string;
}

export interface ResponseErrorMessage {
message?: string;
name?: string;
status?: number;
statusTest?: string;
url?: string;
error?: {
errorCode?: number;
errorDescription?: string;
errorMessage?: string;
status?: string;
timeStamp?: string;
}
headers?: any;

}

Loading

0 comments on commit 88251fd

Please sign in to comment.