From a590f26526dc555da030bdb77465886bf286e9cd Mon Sep 17 00:00:00 2001 From: Sabrina Date: Thu, 14 Dec 2023 11:59:59 +0000 Subject: [PATCH 1/3] Add funtion in add-edit-training to route to delete record --- .../add-edit-training.component.spec.ts | 18 ++++++++++++++++++ .../add-edit-training.component.html | 4 ++-- .../add-edit-training.directive.ts | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts b/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts index 0bc1eb626b..e20e603f61 100644 --- a/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts +++ b/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts @@ -210,6 +210,24 @@ describe('AddEditTrainingComponent', () => { }); }); + describe('Delete button', () => { + it('should navigate to delete confirmation page', async () => { + const { component, routerSpy, getByTestId } = await setup(); + const deleteTrainingRecord = getByTestId('delete-this-training-record'); + + fireEvent.click(deleteTrainingRecord); + expect(routerSpy).toHaveBeenCalledWith([ + '/workplace', + component.workplace.uid, + 'training-and-qualifications-record', + component.worker.uid, + 'training', + component.trainingRecordId, + 'delete', + ]); + }); + }); + describe('Cancel button', () => { it('should call navigate when pressing cancel', async () => { const { component, fixture, getByText, routerSpy } = await setup(); diff --git a/src/app/shared/directives/add-edit-training/add-edit-training.component.html b/src/app/shared/directives/add-edit-training/add-edit-training.component.html index 04372142f6..d49cc22524 100644 --- a/src/app/shared/directives/add-edit-training/add-edit-training.component.html +++ b/src/app/shared/directives/add-edit-training/add-edit-training.component.html @@ -175,9 +175,9 @@

class="govuk-button govuk-button--link govuk__flex govuk__align-items-center" *ngIf="trainingRecordId" draggable="false" - href="#" - [routerLink]="['../delete']" + (click)="navigateToDeleteTrainingRecord()" data-testid="deleteButton" + data-testid="delete-this-training-record" > Delete this training record Date: Thu, 14 Dec 2023 16:22:18 +0000 Subject: [PATCH 2/3] Remove code with was overwriting variable on add-edit-training --- .../add-edit-training.component.spec.ts | 24 ++++++++++++-- .../training-details.component.spec.ts | 1 - .../add-edit-training.component.html | 1 - .../add-edit-training.directive.ts | 33 ++++++++++++------- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts b/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts index e20e603f61..a6999f6b3e 100644 --- a/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts +++ b/src/app/features/training-and-qualifications/add-edit-training/add-edit-training.component.spec.ts @@ -211,10 +211,28 @@ describe('AddEditTrainingComponent', () => { }); describe('Delete button', () => { - it('should navigate to delete confirmation page', async () => { - const { component, routerSpy, getByTestId } = await setup(); - const deleteTrainingRecord = getByTestId('delete-this-training-record'); + it('should navigate to delete confirmation page with training category', async () => { + const { component, routerSpy, getByTestId, fixture } = await setup(); + const deleteTrainingRecord = getByTestId('deleteButton'); + component.trainingCategory = { id: 2, category: 'First aid' }; + fixture.detectChanges(); + fireEvent.click(deleteTrainingRecord); + expect(routerSpy).toHaveBeenCalledWith([ + '/workplace', + component.workplace.uid, + 'training-and-qualifications-record', + component.worker.uid, + 'training', + component.trainingRecordId, + { trainingCategory: JSON.stringify(component.trainingCategory) }, + 'delete', + ]); + }); + + it('should navigate to delete confirmation page without training category', async () => { + const { component, routerSpy, getByTestId } = await setup(); + const deleteTrainingRecord = getByTestId('deleteButton'); fireEvent.click(deleteTrainingRecord); expect(routerSpy).toHaveBeenCalledWith([ '/workplace', diff --git a/src/app/features/training-and-qualifications/add-multiple-training/training-details/training-details.component.spec.ts b/src/app/features/training-and-qualifications/add-multiple-training/training-details/training-details.component.spec.ts index 6fdc42bb53..2a15b938fe 100644 --- a/src/app/features/training-and-qualifications/add-multiple-training/training-details/training-details.component.spec.ts +++ b/src/app/features/training-and-qualifications/add-multiple-training/training-details/training-details.component.spec.ts @@ -126,7 +126,6 @@ describe('MultipleTrainingDetailsComponent', () => { await setup(); const categoryOption = component.categories[0].id.toString(); - userEvent.selectOptions(getByLabelText('Training category'), categoryOption); userEvent.type(getByLabelText('Training name'), 'Training'); userEvent.click(getByLabelText('Yes')); diff --git a/src/app/shared/directives/add-edit-training/add-edit-training.component.html b/src/app/shared/directives/add-edit-training/add-edit-training.component.html index d49cc22524..d9caabdaf5 100644 --- a/src/app/shared/directives/add-edit-training/add-edit-training.component.html +++ b/src/app/shared/directives/add-edit-training/add-edit-training.component.html @@ -177,7 +177,6 @@

draggable="false" (click)="navigateToDeleteTrainingRecord()" data-testid="deleteButton" - data-testid="delete-this-training-record" > Delete this training record Date: Thu, 14 Dec 2023 16:23:13 +0000 Subject: [PATCH 3/3] Update karma.conf to run ChromeHeadlessNoSandbox --- karma.conf.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index f1c12fe058..b57bc451ec 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -63,11 +63,15 @@ module.exports = function (config) { logLevel: config.LOG_INFO, autoWatch: !isCI, singleRun: isCI, - // browsers: ['ChromeHeadlessNoSandbox', 'ChromeNoSandbox'], - browsers: ['ChromeNoSandbox'], + //browsers: ['ChromeHeadlessNoSandbox', 'ChromeNoSandbox'], + browsers: ['ChromeHeadlessNoSandbox'], customLaunchers: { - // ChromeHeadlessNoSandbox: { - // base: 'ChromeHeadless', + ChromeHeadlessNoSandbox: { + base: 'ChromeHeadless', + flags: ['--no-sandbox'], + }, + // ChromeNoSandbox: { + // base: 'Chrome', // flags: [ // '--no-sandbox', // '--user-data-dir=/tmp/chrome-test-profile', @@ -77,17 +81,6 @@ module.exports = function (config) { // ], // debug: true, // }, - ChromeNoSandbox: { - base: 'Chrome', - flags: [ - '--no-sandbox', - '--user-data-dir=/tmp/chrome-test-profile', - '--disable-web-security', - '--remote-debugging-address=0.0.0.0', - '--remote-debugging-port=9222', - ], - debug: true, - }, }, browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3,