Skip to content

Commit

Permalink
Merge branch 'main' into jk/fix_type_tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
josephaxisa authored Oct 5, 2021
2 parents db568bc + 9e4a141 commit 219dbb5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ import { ExploreProperty, ExplorePropertyDetail, typeIcon } from '.'

describe('ExploreProperty', () => {
const type = api.types.CreateDashboardFilter

describe('ExplorePropertyDetail', () => {
describe('CreateDashboardFilter', () => {
test('Shows read-only property and description', async () => {
const property = type.properties.id
expect(property).toBeDefined()
renderWithSearchAndRouter(<ExplorePropertyDetail property={property} />)
renderWithSearchAndRouter(
<ExplorePropertyDetail api={api} property={property} />
)
expect(property.deprecated).toEqual(false)
expect(property.readOnly).toEqual(true)
// eslint-disable-next-line jest-dom/prefer-required
Expand All @@ -54,10 +57,13 @@ describe('ExploreProperty', () => {
)
})
})

test('Shows required property and description', async () => {
const property = type.properties.dashboard_id
expect(property).toBeDefined()
renderWithSearchAndRouter(<ExplorePropertyDetail property={property} />)
renderWithSearchAndRouter(
<ExplorePropertyDetail api={api} property={property} />
)
expect(property.deprecated).toEqual(false)
expect(property.readOnly).toEqual(false)
// eslint-disable-next-line jest-dom/prefer-required
Expand All @@ -78,23 +84,31 @@ describe('ExploreProperty', () => {
test('int64 property icon is correct', () => {
const property = type.properties.row
expect(property.type.jsonName).toEqual('int64')
renderWithSearchAndRouter(<ExploreProperty property={property} />)
renderWithSearchAndRouter(
<ExploreProperty api={api} property={property} />
)
expect(screen.getByTitle('int64')).toBeInTheDocument()
const legend = typeIcon(property.type)
expect(legend).toEqual({ icon: <Tag />, title: 'int64' })
})

test('array property icon is correct', () => {
const property = type.properties.listens_to_filters
expect(property.type.jsonName).toEqual('string[]')
renderWithSearchAndRouter(<ExploreProperty property={property} />)
renderWithSearchAndRouter(
<ExploreProperty api={api} property={property} />
)
expect(screen.getByTitle(property.type.jsonName)).toBeInTheDocument()
const legend = typeIcon(property.type)
expect(legend).toEqual({ icon: <Toc />, title: 'string[]' })
})

test('hash property icon is correct', () => {
const property = type.properties.field
expect(property.type.jsonName).toEqual('Hash[any]')
renderWithSearchAndRouter(<ExploreProperty property={property} />)
renderWithSearchAndRouter(
<ExploreProperty api={api} property={property} />
)
expect(screen.getByTitle(property.type.jsonName)).toBeInTheDocument()
const legend = typeIcon(property.type)
expect(legend).toEqual({ icon: <IdeFileManifest />, title: 'Hash[any]' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ import { DocRequestBody } from './DocRequestBody'
describe('DocRequestBody', () => {
test('it shows Request body for a method with a body type', () => {
const method = api.methods.create_dashboard
renderWithTheme(<DocRequestBody method={method} />)
renderWithTheme(<DocRequestBody api={api} method={method} />)
expect(
screen.getByText('Request body', { exact: false })
).toBeInTheDocument()
})

test('it skips Request body for a method without a body type', () => {
const method = api.methods.dashboard
renderWithTheme(<DocRequestBody method={method} />)
renderWithTheme(<DocRequestBody api={api} method={method} />)
expect(
screen.queryByText('Request body', { exact: false })
).not.toBeInTheDocument()
Expand Down
12 changes: 11 additions & 1 deletion packages/extension-api-explorer/bin/deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
set -e

# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT

if [ $# -eq 0 ]
then
Expand All @@ -12,8 +18,12 @@ cd ../.. && yarn
echo "Rebuilding all packages"
yarn build


cd packages/extension-api-explorer
echo "Removing existing bundle"
rm -rf dist/
echo "Creating extension-api-explorer production bundle"
cd packages/extension-api-explorer && yarn bundle
yarn bundle
path_to_bundle=$(pwd)"/dist/bundle.js"

cd ../../..
Expand Down
12 changes: 6 additions & 6 deletions packages/extension-sdk/src/connect/extension_host_api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('extension_host_api tests', () => {
}),
})
throw new Error('Unexpected success')
} catch (error) {
} catch (error: any) {
expect(error.message).toEqual(
'Extension requires Looker version >=7.9, got 6.25.0'
)
Expand Down Expand Up @@ -511,7 +511,7 @@ describe('extension_host_api tests', () => {
}),
})
throw new Error('Unexpected success')
} catch (error) {
} catch (error: any) {
expect(error.message).toEqual(
'Extension requires Looker version >=7.11, got 6.25.0'
)
Expand Down Expand Up @@ -562,7 +562,7 @@ describe('extension_host_api tests', () => {
}
await hostApi.oauth2Authenticate(authEndpoint, authParameters)
throw new Error('Unexpected success')
} catch (error) {
} catch (error: any) {
expect(error.message).toEqual(
'Extension requires Looker version >=7.9, got 6.25.0'
)
Expand Down Expand Up @@ -626,7 +626,7 @@ describe('extension_host_api tests', () => {
exchangeParameters
)
throw new Error('Unexpected success')
} catch (error) {
} catch (error: any) {
expect(error.message).toEqual(
'Extension requires Looker version >=7.11, got 7.9'
)
Expand Down Expand Up @@ -660,7 +660,7 @@ describe('extension_host_api tests', () => {
try {
hostApi.createSecretKeyTag('SECRET_KEY_NAME')
throw new Error('Unexpected success')
} catch (error) {
} catch (error: any) {
expect(error.message).toEqual(
'Extension requires Looker version >=7.11, got 7.9'
)
Expand All @@ -682,7 +682,7 @@ describe('extension_host_api tests', () => {
try {
hostApi.createSecretKeyTag('SECRET_KEY_NAME_@@')
throw new Error('Unexpected success')
} catch (error) {
} catch (error: any) {
expect(error.message).toEqual('Unsupported characters in key name')
}
})
Expand Down

0 comments on commit 219dbb5

Please sign in to comment.