Skip to content

Commit

Permalink
Fix: try it interaction (#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewahome authored Nov 8, 2021
1 parent a2079f0 commit 9343088
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class App extends Component<IAppProps, IAppState> {
<div style={{ marginBottom: 8 }}>
<QueryRunner onSelectVerb={this.handleSelectVerb} />
</div>
<div style={ mobileScreen ? this.statusAreaMobileStyle : this.statusAreaLaptopStyle}>
<div style={mobileScreen ? this.statusAreaMobileStyle : this.statusAreaLaptopStyle}>
{statusMessages(queryState, sampleQuery, actions)}
{termsOfUseMessage(termsOfUse, actions, classes, geLocale)}
</div>
Expand Down
32 changes: 32 additions & 0 deletions src/app/views/query-runner/util/iframe-message-parser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-len */
import { parse } from './iframe-message-parser';

describe('Iframe Message Parser', () => {
Expand Down Expand Up @@ -38,4 +39,35 @@ Prefer: A-timezone
body: '{ "name": "Volunteer" } '
});
});

it('parses http request snippet "Use $search and OData cast to get membership in groups with display names that contain the letters "tier" including a count of returned objects" correctly', () => {
const message = `GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$search="displayName:tier"&$select=displayName,id
ConsistencyLevel: eventual`;

const parsed = parse(message);
expect(parsed).toEqual({
verb: 'GET',
url: 'https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$search="displayName:tier"&$select=displayName,id',
headers: [
{ 'ConsistencyLevel': 'eventual' }
],
body: ''
});
});

it('parses http request snippet "cast to get groups with a display name that starts with "a" correctly', () => {
const message = `GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$filter=startswith(displayName, 'a')
ConsistencyLevel: eventual`;

const parsed = parse(message);
expect(parsed).toEqual({
verb: 'GET',
// eslint-disable-next-line quotes
url: `https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$filter=startswith(displayName, 'a')`,
headers: [
{ 'ConsistencyLevel': 'eventual' }
],
body: ''
});
});
});
5 changes: 2 additions & 3 deletions src/app/views/query-runner/util/iframe-message-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,12 @@ function extractUrl(payload: string): object[] {
// of the resulting array
const sampleUrl = payload.split('\n')[1];


// The sampleUrl has the format VERB URL, after splitting it on the space character the VERB will be at index 0
// and the URL at index 1
const urlParts = sampleUrl.split(' ');
const verb = urlParts[0];
let url = urlParts[1];

let url = (urlParts.length > 2) ?
sampleUrl.replace(`${verb} `, '') : urlParts[1];

let sampleDomain = '';
domains.forEach(domain => {
Expand Down

0 comments on commit 9343088

Please sign in to comment.