Skip to content

Commit

Permalink
Updated the UI tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed Jan 4, 2017
1 parent 6e76e83 commit 9857c3a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 14 deletions.
75 changes: 64 additions & 11 deletions client/app/scripts/utils/__tests__/search-utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,50 @@ describe('SearchUtils', () => {
}],
tables: [{
id: 'metric1',
type: 'property-list',
rows: [{
id: 'label1',
entries: {
id: 'row1',
label: 'Row 1',
value: 'Row Value 1'
label: 'Label 1',
value: 'Label Value 1'
}
}, {
id: 'label2',
entries: {
id: 'row2',
label: 'Row 2',
value: 'Row Value 2'
label: 'Label 2',
value: 'Label Value 2'
}
}]
}, {
id: 'metric2',
type: 'multicolumn-table',
columns: [{
id: 'a',
label: 'A'
}, {
id: 'c',
label: 'C'
}],
rows: [{
id: 'row1',
entries: {
a: 'xxxa',
b: 'yyya',
c: 'zzz1'
}
}, {
id: 'row2',
entries: {
a: 'yyyb',
b: 'xxxb',
c: 'zzz2'
}
}, {
id: 'row3',
entries: {
a: 'Value 1',
b: 'Value 2',
c: 'Value 3'
}
}]
}],
Expand Down Expand Up @@ -80,7 +113,7 @@ describe('SearchUtils', () => {
it('should filter nodes that do not match a pinned searches', () => {
let nextState = fromJS({
nodes: nodeSets.someNodes,
pinnedSearches: ['row']
pinnedSearches: ['Label Value 1']
});
nextState = fun(nextState);
expect(nextState.get('nodes').filter(node => node.get('filtered')).size).toEqual(1);
Expand Down Expand Up @@ -244,11 +277,31 @@ describe('SearchUtils', () => {
expect(matches.getIn(['n1', 'metrics', 'metric1']).metric).toBeTruthy();
});

it('should match on a tables field', () => {
it('should match on a property list value', () => {
const nodes = nodeSets.someNodes;
const matches = fun(nodes, {query: 'Row Value 1'});
expect(matches.size).toEqual(1);
expect(matches.getIn(['n2', 'tables', 'row1']).text).toBe('Row Value 1');
const matches = fun(nodes, {query: 'Value 1'});
expect(matches.size).toEqual(2);
expect(matches.getIn(['n2', 'labels']).size).toEqual(1);
expect(matches.getIn(['n2', 'labels', 'label1']).text).toBe('Label Value 1');
});

it('should match on a generic table values', () => {
const nodes = nodeSets.someNodes;
const matches1 = fun(nodes, {query: 'xx'}).getIn(['n2', 'tables']);
const matches2 = fun(nodes, {query: 'yy'}).getIn(['n2', 'tables']);
const matches3 = fun(nodes, {query: 'zz'}).getIn(['n2', 'tables']);
const matches4 = fun(nodes, {query: 'a'}).getIn(['n2', 'tables']);
expect(matches1.size).toEqual(1);
expect(matches2.size).toEqual(1);
expect(matches3.size).toEqual(2);
expect(matches4.size).toEqual(3);
expect(matches1.get('row1_a').text).toBe('xxxa');
expect(matches2.get('row2_a').text).toBe('yyyb');
expect(matches3.get('row1_c').text).toBe('zzz1');
expect(matches3.get('row2_c').text).toBe('zzz2');
expect(matches4.get('row1_a').text).toBe('xxxa');
expect(matches4.get('row3_a').text).toBe('Value 1');
expect(matches4.get('row3_c').text).toBe('Value 3');
});
});

Expand Down
6 changes: 3 additions & 3 deletions probe/overlay/weave.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ var (
Type: report.MulticolumnTableType,
Prefix: WeaveConnectionsMulticolumnTablePrefix,
Columns: []report.Column{
report.Column{
{
ID: WeaveConnectionsConnection,
Label: "Connections",
},
report.Column{
{
ID: WeaveConnectionsState,
Label: "State",
},
report.Column{
{
ID: WeaveConnectionsInfo,
Label: "Info",
},
Expand Down
2 changes: 2 additions & 0 deletions report/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ func (node Node) ExtractTable(template TableTemplate) (rows []Row, truncationCou
return rows, truncationCount
}

// Column is the type for multi-column tables in the UI.
type Column struct {
ID string `json:"id"`
Label string `json:"label"`
DataType string `json:"dataType"`
}

// Row is the type that holds the table data for the UI.
type Row struct {
ID string `json:"id"`
Entries map[string]string `json:"entries"`
Expand Down

0 comments on commit 9857c3a

Please sign in to comment.