Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into RDM-2323
Browse files Browse the repository at this point in the history
* master: (46 commits)
  RDM-3230 Remove profile service and import from ui toolkit.
  change smoke test run format to old original smoke tests
  [PREVIEW] RDM-3000 update yarn.lock
  Update UI-Toolkit Version to v2.5.1
  Functional test updates (#397)
  Fix disappearing dependency
  Sync yarn.lock with package.json
  [PREVIEW] RDM-3000 MidEvent callback
  RDM-3230 Upgrade yarn to 1.9.2 for Travis CI.
  RDM-3230 Upping ui toolkit version.
  RDM-3230 Attempt to fix the build.
  RDM-3230 Yarn update to 1.12.1
  RDM-3064_to_merge Replace with MockComponent.
  RDM-3064_to_merge Remove empty char.
  RDM-3064 Trigger PREVIEW deployment.
  RDM-3230 Upgrade ui toolkit to 2.4.0
  RDM-3230 Up version of angular to fix Router bug angular/angular#26496
  RDM-3230 Fix test.
  RDM-3230 Relax versions for engines.
  RDM-3230 Add range to engines for yarn.
  ...
  • Loading branch information
mohammedanas committed Nov 16, 2018
2 parents 609df4c + c605cd8 commit e43e595
Show file tree
Hide file tree
Showing 35 changed files with 499 additions and 389 deletions.
6 changes: 3 additions & 3 deletions Jenkinsfile_nightly
Expand Up @@ -34,9 +34,9 @@ static LinkedHashMap<String, Object> secret(String secretName, String envVar) {
envVariable: envVar
]
}

withNightlyPipeline(type, product, app) {

enableSlackNotifications('#ccd-nightly-builds')

if (params.RUN_XBROWSER) {
Expand All @@ -47,7 +47,7 @@ withNightlyPipeline(type, product, app) {
env.TEST_URL = params.TEST_URL_PARAM
env.CCD_CASEWORKER_AUTOTEST_EMAIL = params.AUTOTEST_EMAIL_PARAM
env.CCD_CASEWORKER_AUTOTEST_PASSWORD = params.AUTOTEST_PASSWORD_PARAM

afterCheckout {
sh "yarn cache clean"
}
Expand Down
3 changes: 0 additions & 3 deletions Jenkinsfile_parameterized
Expand Up @@ -43,7 +43,4 @@ withParameterizedPipeline('angular', 'ccd', 'case-management-web', params.ENVIRO

}




}
39 changes: 23 additions & 16 deletions README.md
Expand Up @@ -122,33 +122,40 @@ It will start a JSON-Server instance at `http://localhost:3453`, serving the con
* single run: `yarn test`
* live mode (TDD style): `yarn test-watch`

### 2. Smoke Tests
### 2. Smoke & Functional Tests

On the pipeline the Smoke tests are run with out docker, smoke test script available in package.json
Both the smoke and functional tests are written in a cucumber protractor framework,
tests are selected using cucumber tags `@smoke` or `@functional`

``` test:smoke": "protractor test/config/smoke.conf.js", ```
Tests require 3 environment variables to be set in order to run:

environment variables listed below to be used.
| Name | Description |
|------|-------------|
| CCD_CASEWORKER_AUTOTEST_EMAIL | Username for test account |
| CCD_CASEWORKER_AUTOTEST_PASSWORD | Password for tests account |
| TEST_URL | Target URL to test against (default if not set is local docker url) |


#### Running on pipeline
On the pipeline tests are run with out docker, they are run by scripts in package.json

The smoke tests can also run within a docker container.
- Smoke: ``` "test:smoke": "./bin/runSmokeTests.sh", ```
- Functional: ``` "test:functional": "./bin/runFunctionalTests.sh", ```

``` "test:smokeDocker": "./bin/runSmokeTests.sh", ```
These bash scripts in turn execute `test:smokeTest` and `test:functionalTests` respectively in the package.json

To create an image to run execute the following command in the test directory:
#### Running local

``` docker build -t ccd-protractor . ```
If you wish to run tests locally make sure the environment variables listed above are correct and pointing to your
local/docker or desired url and run the following commands:

Before running the tests set the following environment variables

| Name | Description |
|------|-------------|
| CCD_CASEWORKER_AUTOTEST_EMAIL | Username for test account |
| CCD_CASEWORKER_AUTOTEST_PASSWORD | Password for tests account |
| TEST_FRONTEND_URL | URL for systems under tests |
- Smoke: ``` protractor test/functional-tests/config/local.conf.js --cucumberOpts.tags=@smoke ```
- Functional: ``` protractor test/fucntional-tests/config/local.conf.js --cucumberOpts.tags=@functional ```

To run the tests execute
Note: if you are trying to run tests agaist local/docker instance you may need to comment out the `proxy` section
in the `local.conf.js`:

``` docker run -it --rm -e CCD_CASEWORKER_AUTOTEST_EMAIL=$CCD_CASEWORKER_AUTOTEST_EMAIL -e CCD_CASEWORKER_AUTOTEST_PASSWORD=$CCD_CASEWORKER_AUTOTEST_PASSWORD -e TEST_FRONTEND_URL=$TEST_FRONTEND_URL --name protractor-runner -v $(PWD):/protractor/project ccd-protractor:latest test:smoke ```

## Production

Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -26,7 +26,7 @@
"test:smokeTest": "protractor test/config/smoke.conf.js",
"test:crossbrowser": "protractor test/config/crossbrowser.conf.js",
"test:functional": "./bin/runFunctionalTests.sh",
"test:functionalTests": "webdriver-manager update --versions.chrome 2.40 && protractor test/functional-tests/config/conf.js",
"test:functionalTests": "webdriver-manager update --versions.chrome 2.40 && protractor test/functional-tests/config/conf.js --cucumberOpts.tags=@functional",
"lint": "ng lint ccd-case-management-web",
"e2e": "ng e2e",
"start:fr": "ng serve --aot --i18nFile=src/locale/messages.fr.xlf --i18nFormat=xlf --locale=fr",
Expand All @@ -37,7 +37,7 @@
"build:client-and-server-bundles": "ng build --prod && ng run ccd-case-management-web:server:production",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"sonar-scan": "NODE_PATH=. sonar-scanner -X",
"stub-api": "json-server -p 3453 --delay 800 --routes stubs/unit/aggregated.routes.json --watch stubs/unit/aggregated.api.json",
"stub-api": "json-server -p 3453 --delay 800 --routes stubs/api/aggregated.routes.json --watch stubs/api/aggregated.api.json",
"stub-functional": "json-server -p 3453 --delay 800 --routes stubs/functional/aggregated.routes.json --watch stubs/functional/aggregated.api.json",
"snyk-protect": "snyk protect",
"prepare": "yarn run snyk-protect"
Expand All @@ -56,7 +56,7 @@
"@angular/platform-server": "~7.0.3",
"@angular/router": "~7.0.3",
"@angular/upgrade": "~7.0.3",
"@hmcts/ccd-case-ui-toolkit": "2.4.0",
"@hmcts/ccd-case-ui-toolkit": "2.5.1",
"@hmcts/ccpay-web-component": "~1.6.1",
"@nguniversal/express-engine": "^6.0.0",
"@nguniversal/module-map-ngfactory-loader": "^6.0.0",
Expand Down
5 changes: 3 additions & 2 deletions src/app/cases/creator/case-creator-submit.component.spec.ts
Expand Up @@ -19,6 +19,7 @@ describe('CaseCreatorSubmitComponent with Save and Resume enabled', () => {

const JID = 'PROBATE';
const CTID = 'ComplexTestType';
const PAGE_ID = 'pageId';

const CREATED_CASE: CaseDetails = {
id: '1234567890123456',
Expand Down Expand Up @@ -176,9 +177,9 @@ describe('CaseCreatorSubmitComponent with Save and Resume enabled', () => {

it('should validate case details with sanitised data when validated', () => {
casesService.validateCase.and.returnValue(CREATED_CASE_OBS);
component.validate()(SANITISED_EDIT_FORM);
component.validate()(SANITISED_EDIT_FORM, PAGE_ID);

expect(casesService.validateCase).toHaveBeenCalledWith(JID, CTID, SANITISED_EDIT_FORM);
expect(casesService.validateCase).toHaveBeenCalledWith(JID, CTID, SANITISED_EDIT_FORM, PAGE_ID);
});

it('should create a draft when saveDraft called with sanitised data', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/app/cases/creator/case-creator-submit.component.ts
Expand Up @@ -41,8 +41,9 @@ export class CaseCreatorSubmitComponent implements OnInit {
}
}

validate(): (sanitizedEditForm: CaseEventData) => Observable<object> {
return (sanitizedEditForm: CaseEventData) => this.casesService.validateCase(this.jurisdictionId, this.caseTypeId, sanitizedEditForm);
validate(): (sanitizedEditForm: CaseEventData, pageId: string) => Observable<object> {
return (sanitizedEditForm: CaseEventData, pageId: string) => this.casesService.validateCase(this.jurisdictionId, this.caseTypeId,
sanitizedEditForm, pageId);
}

saveDraft(): (caseEventData: CaseEventData) => Observable<Draft> {
Expand Down
Expand Up @@ -12,6 +12,7 @@ import { HttpError, OrderService, CaseTypeLite, Jurisdiction, CaseEvent, AlertSe
CallbackErrorsContext } from '@hmcts/ccd-case-ui-toolkit';
import { DefinitionsService } from '../../../core/definitions/definitions.service';
import { Observable } from 'rxjs';
import { CaseViewerComponent } from '../../viewer/case-viewer.component';

const EVENT_ID_1 = 'ID_1';
const EVENT_NAME_1 = 'Event one';
Expand Down Expand Up @@ -225,9 +226,10 @@ const SORTED_CASE_EVENTS: CaseEvent[] = [...CASE_EVENTS_NO_PRE_STATES];
})
class CallbackErrorsComponent {

public static readonly TRIGGER_TEXT_GO = 'Go';
public static readonly TRIGGER_TEXT_IGNORE = 'Ignore Warning and Go';

@Input()
triggerTextIgnore: string;
@Input()
triggerTextContinue: string;
@Input()
callbackErrorsSubject: Subject<any> = new Subject();
@Output()
Expand Down Expand Up @@ -828,18 +830,32 @@ describe('CreateCaseFiltersComponent', () => {

it('should change button label when callback warnings notified', () => {
let callbackErrorsContext: CallbackErrorsContext = new CallbackErrorsContext();
callbackErrorsContext.trigger_text = CallbackErrorsComponent.TRIGGER_TEXT_GO;
callbackErrorsContext.trigger_text = CreateCaseFiltersComponent.TRIGGER_TEXT_START;
component.callbackErrorsNotify(callbackErrorsContext);

fixture.detectChanges();
let button = de.query($SELECT_BUTTON);
expect(button.nativeElement.textContent).toEqual(CallbackErrorsComponent.TRIGGER_TEXT_GO);
expect(button.nativeElement.textContent).toEqual(CreateCaseFiltersComponent.TRIGGER_TEXT_START);

callbackErrorsContext.trigger_text = CreateCaseFiltersComponent.TRIGGER_TEXT_CONTINUE;
component.callbackErrorsNotify(callbackErrorsContext);

callbackErrorsContext.trigger_text = CallbackErrorsComponent.TRIGGER_TEXT_IGNORE;
fixture.detectChanges();
expect(button.nativeElement.textContent).toEqual(CreateCaseFiltersComponent.TRIGGER_TEXT_CONTINUE);
});

it('should clear errors and warnings', () => {
let callbackErrorsContext: CallbackErrorsContext = new CallbackErrorsContext();
callbackErrorsContext.trigger_text = CaseViewerComponent.TRIGGER_TEXT_START;
component.callbackErrorsNotify(callbackErrorsContext);

fixture.detectChanges();
expect(button.nativeElement.textContent).toEqual(CallbackErrorsComponent.TRIGGER_TEXT_IGNORE);
component.resetErrors();

let error = de.query($ERROR_SUMMARY);
expect(error).toBeFalsy();
expect(component.error).toBeFalsy();
expect(component.ignoreWarning).toBeFalsy();
});

it('should disable button when form valid but callback validation errors exists', () => {
Expand Down
12 changes: 9 additions & 3 deletions src/app/cases/creator/filters/create-case-filters.component.ts
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { Subject } from 'rxjs/Subject';
import { HttpError, OrderService, CaseEvent, AlertService, CallbackErrorsComponent, Jurisdiction,
import { HttpError, OrderService, CaseEvent, AlertService, Jurisdiction,
CaseTypeLite, CallbackErrorsContext} from '@hmcts/ccd-case-ui-toolkit';
import { CREATE_ACCESS } from '../../../shared/domain/case-view/access-types.model';
import { DefinitionsService } from '../../../core/definitions/definitions.service';
Expand All @@ -13,6 +13,9 @@ import { DefinitionsService } from '../../../core/definitions/definitions.servic
styleUrls: ['./create-case-filters.scss']
})
export class CreateCaseFiltersComponent implements OnInit {
static readonly TRIGGER_TEXT_START = 'Start';
static readonly TRIGGER_TEXT_CONTINUE = 'Ignore Warning and Start';

@Input()
formGroup: FormGroup = new FormGroup({});

Expand All @@ -33,7 +36,9 @@ export class CreateCaseFiltersComponent implements OnInit {
filterCaseTypeControl: FormControl;
filterEventControl: FormControl;

triggerText: string = CallbackErrorsComponent.TRIGGER_TEXT_START;
triggerTextStart = CreateCaseFiltersComponent.TRIGGER_TEXT_START;
triggerTextIgnoreWarnings = CreateCaseFiltersComponent.TRIGGER_TEXT_CONTINUE;
triggerText = CreateCaseFiltersComponent.TRIGGER_TEXT_START;
ignoreWarning = false;
error: HttpError;

Expand Down Expand Up @@ -176,8 +181,9 @@ export class CreateCaseFiltersComponent implements OnInit {
this.formGroup.controls['event'].disable();
}

private resetErrors(): void {
resetErrors(): void {
this.error = null;
this.ignoreWarning = false;
this.callbackErrorsSubject.next(null);
this.alertService.clear();
}
Expand Down
7 changes: 6 additions & 1 deletion src/app/cases/creator/filters/create-case-filters.html
Expand Up @@ -9,7 +9,12 @@ <h3 class="heading-medium error-summary-heading" id="edit-case-event_error-summa
</li>
</ul>
</div>
<ccd-callback-errors [callbackErrorsSubject]="callbackErrorsSubject" (callbackErrorsContext)="callbackErrorsNotify($event)"></ccd-callback-errors>
<ccd-callback-errors
[triggerTextContinue]="triggerTextStart"
[triggerTextIgnore]="triggerTextIgnoreWarnings"
[callbackErrorsSubject]="callbackErrorsSubject"
(callbackErrorsContext)="callbackErrorsNotify($event)">
</ccd-callback-errors>
<form (ngSubmit)="apply()">
<div class="form-group">
<label class="form-label" for="cc-jurisdiction">Jurisdiction</label>
Expand Down
Expand Up @@ -11,6 +11,7 @@ import { CaseEventData, createCaseEventTrigger, CaseReferencePipe, HttpError, Ca
CaseView, AlertService, CasesService} from '@hmcts/ccd-case-ui-toolkit';

describe('CaseEventTriggerComponent', () => {
const PAGE_ID = 'pageId';
const CASE_DETAILS: CaseView = new CaseView();
CASE_DETAILS.case_id = '42';
CASE_DETAILS.case_type = {
Expand Down Expand Up @@ -171,10 +172,10 @@ describe('CaseEventTriggerComponent', () => {
});

it('should edit case with sanitised data when form validated', () => {
component.validate()(SANITISED_EDIT_FORM);
component.validate()(SANITISED_EDIT_FORM, PAGE_ID);

expect(casesService.validateCase).toHaveBeenCalledWith(CASE_DETAILS.case_type.jurisdiction.id,
CASE_DETAILS.case_type.id, SANITISED_EDIT_FORM);
CASE_DETAILS.case_type.id, SANITISED_EDIT_FORM, PAGE_ID);
});

it('should navigate to case view upon successful event creation', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/app/cases/event-trigger/case-event-trigger.component.ts
Expand Up @@ -46,10 +46,11 @@ export class CaseEventTriggerComponent implements OnInit, OnDestroy {
return (sanitizedEditForm: CaseEventData) => this.casesService.createEvent(this.caseDetails, sanitizedEditForm);
}

validate(): (sanitizedEditForm: CaseEventData) => Observable<object> {
return (sanitizedEditForm: CaseEventData) => this.casesService.validateCase(
validate(): (sanitizedEditForm: CaseEventData, pageId: string) => Observable<object> {
return (sanitizedEditForm: CaseEventData, pageId: string) => this.casesService.validateCase(
this.caseDetails.case_type.jurisdiction.id,
this.caseDetails.case_type.id, sanitizedEditForm);
this.caseDetails.case_type.id, sanitizedEditForm,
pageId);
}

submitted(event: any): void {
Expand Down
7 changes: 6 additions & 1 deletion src/app/cases/viewer/case-viewer.component.html
Expand Up @@ -9,7 +9,12 @@ <h3 class="heading-medium error-summary-heading" id="edit-case-event_error-summa
</li>
</ul>
</div>
<ccd-callback-errors [callbackErrorsSubject]="callbackErrorsSubject" (callbackErrorsContext)="callbackErrorsNotify($event)"></ccd-callback-errors>
<ccd-callback-errors
[triggerTextContinue]="triggerTextStart"
[triggerTextIgnore]="triggerTextIgnoreWarnings"
[callbackErrorsSubject]="callbackErrorsSubject"
(callbackErrorsContext)="callbackErrorsNotify($event)">
</ccd-callback-errors>
<ccd-activity [caseId]="caseDetails.case_id" [displayMode]="BANNER"></ccd-activity>
<div class="grid-row">
<div class="column-one-half">
Expand Down
18 changes: 10 additions & 8 deletions src/app/cases/viewer/case-viewer.component.spec.ts
Expand Up @@ -57,9 +57,10 @@ describe('CaseViewerComponent', () => {
})
class CallbackErrorsComponent {

public static readonly TRIGGER_TEXT_GO = 'Go';
public static readonly TRIGGER_TEXT_IGNORE = 'Ignore Warning and Go';

@Input()
triggerTextIgnore: string;
@Input()
triggerTextContinue: string;
@Input()
callbackErrorsSubject: Subject<any> = new Subject();
@Output()
Expand Down Expand Up @@ -680,20 +681,20 @@ describe('CaseViewerComponent', () => {

it('should change button label when notified about callback errors', () => {
let callbackErrorsContext: CallbackErrorsContext = new CallbackErrorsContext();
callbackErrorsContext.trigger_text = CallbackErrorsComponent.TRIGGER_TEXT_GO;
callbackErrorsContext.trigger_text = CaseViewerComponent.TRIGGER_TEXT_START;
component.callbackErrorsNotify(callbackErrorsContext);
fixture.detectChanges();

let eventTriggerElement = de.query(By.directive(EventTriggerComponent));
let eventTrigger = eventTriggerElement.componentInstance;

expect(eventTrigger.triggerText).toEqual(CallbackErrorsComponent.TRIGGER_TEXT_GO);
expect(eventTrigger.triggerText).toEqual(CaseViewerComponent.TRIGGER_TEXT_START);

callbackErrorsContext.trigger_text = CallbackErrorsComponent.TRIGGER_TEXT_IGNORE;
callbackErrorsContext.trigger_text = CaseViewerComponent.TRIGGER_TEXT_CONTINUE;
component.callbackErrorsNotify(callbackErrorsContext);
fixture.detectChanges();

expect(eventTrigger.triggerText).toEqual(CallbackErrorsComponent.TRIGGER_TEXT_IGNORE);
expect(eventTrigger.triggerText).toEqual(CaseViewerComponent.TRIGGER_TEXT_CONTINUE);
});

it('should initially not display form errors', () => {
Expand All @@ -704,13 +705,14 @@ describe('CaseViewerComponent', () => {

it('should clear errors and warnings', () => {
let callbackErrorsContext: CallbackErrorsContext = new CallbackErrorsContext();
callbackErrorsContext.trigger_text = CallbackErrorsComponent.TRIGGER_TEXT_GO;
callbackErrorsContext.trigger_text = CaseViewerComponent.TRIGGER_TEXT_START;
component.callbackErrorsNotify(callbackErrorsContext);
fixture.detectChanges();
component.clearErrorsAndWarnings();
let error = de.query($ERROR_SUMMARY);
expect(error).toBeFalsy();
expect(component.error).toBeFalsy();
expect(component.ignoreWarning).toBeFalsy();
});

it('should display error when form error get set', () => {
Expand Down

0 comments on commit e43e595

Please sign in to comment.