Skip to content

Commit

Permalink
Fix update openapi: use modificationCount (#62)
Browse files Browse the repository at this point in the history
* fix: update openapi: use modificationCount

* fix: update versions
  • Loading branch information
HenryT-CG authored Apr 17, 2024
1 parent fcffac9 commit 5b46b00
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 243 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/onecx/docker-spa-base:1.3.0
FROM ghcr.io/onecx/docker-spa-base:1.4.0

# Copy nginx configuration
COPY nginx/locations.conf $DIR_LOCATION/locations.conf
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"OneCX Development Team <[email protected]>"
],
"config": {
"openapiYaml": "src/assets/api/help-bff-api.yaml",
"openapiYaml": "src/assets/api/openapi-bff.yaml",
"openapiOutput": "src/app/shared/generated"
},
"scripts": {
Expand Down Expand Up @@ -94,7 +94,7 @@
"@swc-node/register": "^1.6.5",
"@swc/cli": "~0.1.63",
"@swc/core": "^1.3.56",
"@swc/helpers": "0.5.1",
"@swc/helpers": "0.5.8",
"@types/jasmine": "~3.10.0",
"@types/node": "18.16.3",
"@typescript-eslint/eslint-plugin": "5.48.2",
Expand All @@ -110,7 +110,7 @@
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-storybook": "^0.6.12",
"husky": "^8.0.3",
"husky": "^9.0.11",
"jasmine-core": "~4.0.0",
"jasmine-spec-reporter": "^7.0.0",
"jsonc-eslint-parser": "^2.2.0",
Expand Down
20 changes: 13 additions & 7 deletions src/app/help/help-detail/help-detail.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { of, throwError } from 'rxjs'
import { FormControl, FormGroup, Validators } from '@angular/forms'

import { AppStateService, createTranslateLoader, Column, PortalMessageService } from '@onecx/portal-integration-angular'
import { HelpsInternalAPIService, CreateHelp } from 'src/app/shared/generated'
import { Help, HelpsInternalAPIService, CreateHelp } from 'src/app/shared/generated'
import { HelpDetailComponent } from './help-detail.component'

describe('HelpDetailComponent', () => {
Expand All @@ -19,6 +19,10 @@ describe('HelpDetailComponent', () => {
createNewHelp: jasmine.createSpy('createNewHelp').and.returnValue(of({})),
updateHelp: jasmine.createSpy('updateHelp').and.returnValue(of({}))
}
const dummyHelpItem = {
appId: 'appId',
itemId: 'itemId'
}

@Component({
selector: 'app-help-form',
Expand Down Expand Up @@ -156,14 +160,16 @@ describe('HelpDetailComponent', () => {
it('should update help item', () => {
apiServiceSpy.updateHelp.and.returnValue(of({}))
component.changeMode = 'EDIT'
component.helpItem = { modificationCount: 0, ...dummyHelpItem } as Help
component.appId = dummyHelpItem.appId
component.itemId = dummyHelpItem.itemId
let mockHelpForm = new MockHelpFormComponent()
mockHelpForm.formGroup.setValue({
appId: 'help-mgmt-ui',
itemId: 'PAGE_HELP_SEARCH'
mockHelpForm.formGroup.patchValue({
appId: dummyHelpItem.appId,
itemId: dummyHelpItem.itemId
})
component.helpFormComponent = mockHelpForm
component.appId = 'help-mgmt-ui'
component.itemId = 'PAGE_HELP_SEARCH'

spyOn(component.searchEmitter, 'emit')

component.onSave()
Expand All @@ -172,7 +178,7 @@ describe('HelpDetailComponent', () => {
expect(component.searchEmitter.emit).toHaveBeenCalled()
expect(apiServiceSpy.updateHelp).toHaveBeenCalledWith({
id: component.itemId,
updateHelp: component.helpFormComponent.formGroup.value
updateHelp: { ...component.helpFormComponent.formGroup.value, modificationCount: 0 }
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/app/help/help-detail/help-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class HelpDetailComponent implements OnChanges {
this.helpApi
.updateHelp({
id: this.itemId,
updateHelp: this.helpFormComponent.formGroup.value
updateHelp: { ...this.helpFormComponent.formGroup.value, modificationCount: this.helpItem?.modificationCount }
})
.subscribe({
next: () => {
Expand Down
136 changes: 0 additions & 136 deletions src/app/shared/generated/api/helpsInternal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ export interface GetHelpByIdRequestParams {
id: string;
}

export interface GetHelpByItemIdRequestParams {
itemId: string;
}

export interface GetHelpsRequestParams {
pageNumber?: number;
pageSize?: number;
}

export interface SearchHelpsRequestParams {
helpSearchCriteria: HelpSearchCriteria;
}
Expand Down Expand Up @@ -373,133 +364,6 @@ export class HelpsInternalAPIService {
);
}

/**
* Load a single help definition
* @param requestParameters
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getHelpByItemId(requestParameters: GetHelpByItemIdRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Help>;
public getHelpByItemId(requestParameters: GetHelpByItemIdRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Help>>;
public getHelpByItemId(requestParameters: GetHelpByItemIdRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Help>>;
public getHelpByItemId(requestParameters: GetHelpByItemIdRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
const itemId = requestParameters.itemId;
if (itemId === null || itemId === undefined) {
throw new Error('Required parameter itemId was null or undefined when calling getHelpByItemId.');
}

let localVarHeaders = this.defaultHeaders;

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}

let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}


let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}

let localVarPath = `/helps/itemId/${this.configuration.encodeParam({name: "itemId", value: itemId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
return this.httpClient.request<Help>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* Return list of helps
* @param requestParameters
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getHelps(requestParameters: GetHelpsRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<Array<HelpPageResult>>;
public getHelps(requestParameters: GetHelpsRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<Array<HelpPageResult>>>;
public getHelps(requestParameters: GetHelpsRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<Array<HelpPageResult>>>;
public getHelps(requestParameters: GetHelpsRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
const pageNumber = requestParameters.pageNumber;
const pageSize = requestParameters.pageSize;

let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (pageNumber !== undefined && pageNumber !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>pageNumber, 'pageNumber');
}
if (pageSize !== undefined && pageSize !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>pageSize, 'pageSize');
}

let localVarHeaders = this.defaultHeaders;

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}

let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}


let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}

let localVarPath = `/helps`;
return this.httpClient.request<Array<HelpPageResult>>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* Search for helps
* @param requestParameters
Expand Down
6 changes: 0 additions & 6 deletions src/app/shared/generated/model/createHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@


export interface CreateHelp {
version?: number;
creationDate?: string;
creationUser?: string;
modificationDate?: string;
modificationUser?: string;
id?: string;
itemId: string;
context?: string;
baseUrl?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/generated/model/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


export interface Help {
version?: number;
modificationCount?: number;
creationDate?: string;
creationUser?: string;
modificationDate?: string;
Expand Down
8 changes: 2 additions & 6 deletions src/app/shared/generated/model/updateHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@


export interface UpdateHelp {
version?: number;
creationDate?: string;
creationUser?: string;
modificationDate?: string;
modificationUser?: string;
modificationCount: number;
id?: string;
itemId?: string;
itemId: string;
context?: string;
baseUrl?: string;
resourceUrl?: string;
Expand Down
11 changes: 11 additions & 0 deletions src/app/shared/label.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,15 @@ describe('LabelResolver', () => {
expect(result).toBe('path')
expect(translateServiceSpy.get).toHaveBeenCalledTimes(0)
})

it('should return an empty string if neither breadcrumb nor route.routeConfig.path are present', () => {
const routeConfigSpy = Object.getOwnPropertyDescriptor(activatedRouteSpy, 'routeConfig')?.get as jasmine.Spy<
() => {}
>
routeConfigSpy.and.returnValue({})
const result = labelResolver.resolve(activatedRouteSpy, routerStateSpy)

expect(result).toBe('')
expect(translateServiceSpy.get).toHaveBeenCalledTimes(0)
})
})
Loading

0 comments on commit 5b46b00

Please sign in to comment.