Skip to content

feat(span-detail): cookies as first class fields #1230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.call-headers {
display: flex;
flex-direction: column;
height: 100%;
padding-top: 24px;

.title {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,40 @@ import { EMPTY, Observable, of } from 'rxjs';
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="call-headers">
<ht-label label="Headers" class="title"></ht-label>
<ht-label [label]="this.title" class="title"></ht-label>
<div class="container" data-sensitive-pii>
<ng-container *htLoadAsync="this.headerRecords$ as headerRecords">
<ht-list-view [records]="headerRecords"></ht-list-view>
<ng-container *htLoadAsync="this.records$ as records">
<ht-list-view [records]="records"></ht-list-view>
</ng-container>
</div>
</div>
`
})
export class SpanDetailCallHeadersComponent implements OnChanges {
@Input()
public headers?: Dictionary<unknown>;
public data?: Dictionary<unknown>;

public headerRecords$?: Observable<ListViewRecord[]>;
@Input()
public title?: string;

public records$?: Observable<ListViewRecord[]>;

public label?: string;

public ngOnChanges(): void {
this.buildHeaderRecords();
this.buildRecords();
}

private buildHeaderRecords(): void {
if (isNil(this.headers)) {
this.headerRecords$ = EMPTY;
private buildRecords(): void {
if (isNil(this.data)) {
this.records$ = EMPTY;
} else {
this.headerRecords$ = of(
Object.keys(this.headers)
this.records$ = of(
Object.keys(this.data)
.sort((key1, key2) => key1.localeCompare(key2))
.map(key => ({
key: key,
value: this.headers![key] as string | number
value: this.data![key] as string | number
}))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Span request detail component', () => {
});

test('should display headers and body title', () => {
spectator = createHost(`<ht-span-request-detail></ht-span-request-detail>`);
spectator = createHost(`<ht-span-request-detail title="Headers"></ht-span-request-detail>`);

const headerTitleElement = spectator.query<HTMLElement>('.call-headers > .title');
expect(headerTitleElement).not.toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { SpanDetailLayoutStyle } from '../span-detail-layout-style';
template: `
<div class="span-request-detail" [ngClass]="this.layout">
<div class="section">
<ht-span-detail-call-headers [headers]="this.requestHeaders"></ht-span-detail-call-headers>
<ht-span-detail-call-headers [data]="this.requestHeaders" title="Headers"></ht-span-detail-call-headers>
<ht-span-detail-call-headers [data]="this.requestCookies" title="Cookies"></ht-span-detail-call-headers>
</div>
<div class="section">
<ht-span-detail-call-body [body]="this.requestBody"></ht-span-detail-call-body>
Expand All @@ -21,6 +22,9 @@ export class SpanRequestDetailComponent {
@Input()
public requestHeaders?: Dictionary<unknown>;

@Input()
public requestCookies?: Dictionary<unknown>;

@Input()
public requestBody?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Span response detail component', () => {
});

test('should display headers and body title', () => {
spectator = createHost(`<ht-span-response-detail></ht-span-response-detail>`);
spectator = createHost(`<ht-span-response-detail title="Headers"></ht-span-response-detail>`);

const headerTitleElement = spectator.query<HTMLElement>('.call-headers > .title');
expect(headerTitleElement).not.toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { SpanDetailLayoutStyle } from '../span-detail-layout-style';
template: `
<div class="span-response-detail" [ngClass]="this.layout">
<div class="section">
<ht-span-detail-call-headers [headers]="this.responseHeaders"></ht-span-detail-call-headers>
<ht-span-detail-call-headers [data]="this.responseHeaders" title="Headers"></ht-span-detail-call-headers>
<ht-span-detail-call-headers [data]="this.responseCookies" title="Cookies"></ht-span-detail-call-headers>
</div>
<div class="section">
<ht-span-detail-call-body [body]="this.responseBody"></ht-span-detail-call-body>
Expand All @@ -21,6 +22,9 @@ export class SpanResponseDetailComponent {
@Input()
public responseHeaders?: Dictionary<unknown>;

@Input()
public responseCookies?: Dictionary<unknown>;

@Input()
public responseBody?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export interface SpanData {
apiName?: string;
protocolName?: string;
requestHeaders: Dictionary<unknown>;
requestCookies: Dictionary<unknown>;
requestBody: string;
responseHeaders: Dictionary<unknown>;
responseCookies: Dictionary<unknown>;
responseBody: string;
tags: Dictionary<unknown>;
requestUrl: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ describe('Span detail component', () => {
apiName: 'My API Name',
protocolName: 'My Protocol Name',
requestHeaders: { header1: 'value1', header2: 'value2' },
requestCookies: { cookie1: 'value1', cookie2: 'value2' },
requestBody: '[{"data": 5000}]',
responseHeaders: { header1: 'value1', header2: 'value2' },
responseCookies: { cookie1: 'value1', cookie2: 'value2' },
responseBody: '[{"data": 5000}]',
tags: { tag1: 'value1', tag2: 'value2' },
requestUrl: 'test-url',
Expand All @@ -43,8 +45,10 @@ describe('Span detail component', () => {
apiName: 'My API Name',
protocolName: 'My Protocol Name',
requestHeaders: {},
requestCookies: {},
requestBody: '',
responseHeaders: { header1: 'value1', header2: 'value2' },
responseCookies: { cookie1: 'value1', cookie2: 'value2' },
responseBody: '[{"data": 5000}]',
tags: { tag1: 'value1', tag2: 'value2' },
requestUrl: 'test-url',
Expand All @@ -69,8 +73,10 @@ describe('Span detail component', () => {
apiName: 'My API Name',
protocolName: 'My Protocol Name',
requestHeaders: {},
requestCookies: {},
requestBody: '[{"data": 5000}]',
responseHeaders: { header1: 'value1', header2: 'value2' },
responseCookies: { cookie1: 'value1', cookie2: 'value2' },
responseBody: '[{"data": 5000}]',
tags: { tag1: 'value1', tag2: 'value2' },
requestUrl: 'test-url',
Expand All @@ -94,8 +100,10 @@ describe('Span detail component', () => {
apiName: 'My API Name',
protocolName: 'My Protocol Name',
requestHeaders: { header1: 'value1', header2: 'value2' },
requestCookies: { cookie1: 'value1', cookie2: 'value2' },
requestBody: '[{"data": 5000}]',
responseHeaders: {},
responseCookies: {},
responseBody: '',
tags: { tag1: 'value1', tag2: 'value2' },
requestUrl: 'test-url',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { SpanDetailTab } from './span-detail-tab';
class="request"
[layout]="this.layout"
[requestHeaders]="this.spanData.requestHeaders"
[requestCookies]="this.spanData.requestCookies"
[requestBody]="this.spanData.requestBody"
></ht-span-request-detail>
</ht-tab>
Expand All @@ -38,6 +39,7 @@ import { SpanDetailTab } from './span-detail-tab';
class="response"
[layout]="this.layout"
[responseHeaders]="this.spanData.responseHeaders"
[responseCookies]="this.spanData.responseCookies"
[responseBody]="this.spanData.responseBody"
></ht-span-response-detail>
</ht-tab>
Expand Down Expand Up @@ -78,8 +80,14 @@ export class SpanDetailComponent implements OnChanges {

public ngOnChanges(changes: TypedSimpleChanges<this>): void {
if (changes.spanData) {
this.showRequestTab = !isEmpty(this.spanData?.requestHeaders) || !isEmpty(this.spanData?.requestBody);
this.showResponseTab = !isEmpty(this.spanData?.responseHeaders) || !isEmpty(this.spanData?.responseBody);
this.showRequestTab =
!isEmpty(this.spanData?.requestHeaders) ||
!isEmpty(this.spanData?.requestCookies) ||
!isEmpty(this.spanData?.requestBody);
this.showResponseTab =
!isEmpty(this.spanData?.responseHeaders) ||
!isEmpty(this.spanData?.responseCookies) ||
!isEmpty(this.spanData?.responseBody);
this.showExitCallsTab = !isEmpty(this.spanData?.exitCallsBreakup);
this.showLogEventsTab = !isEmpty(this.spanData?.logEvents);
this.totalLogEvents = (this.spanData?.logEvents ?? []).length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export interface WaterfallData {
apiName?: string;
spanType: SpanType;
requestHeaders?: Dictionary<unknown>;
requestCookies?: Dictionary<unknown>;
requestBody?: string;
responseHeaders?: Dictionary<unknown>;
responseCookies?: Dictionary<unknown>;
responseBody?: string;
tags: Dictionary<unknown>;
errorCount: number;
Expand Down