Skip to content

Commit

Permalink
feat: #1325 Update tests for developer submit app page
Browse files Browse the repository at this point in the history
  • Loading branch information
nphivu414 committed May 26, 2020
1 parent a4778a9 commit 9162825
Show file tree
Hide file tree
Showing 23 changed files with 393 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ exports[`AppContent renderDescripion - should match snapshot 1`] = `
Description
</Component>
<Component
html="enim facilisis gravida neque convallis a cras semper auctor neque vitae tempus quam
pellentesque nec nam aliquam sem et tortor consequat id porta nibh venenatis cras
sed felis eget velit aliquet sagittis id consectetur purus ut faucibus pulvinar
elementum integer enim neque volutpat ac tincidunt vitae semper quis lectus nulla
at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet
proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum co"
html="enim facilisis"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ exports[`Aside Aside - should match snapshot 1`] = `
appDetailState={
Object {
"data": Object {
"description": "enim facilisis gravida neque convallis a cras semper auctor neque vitae tempus quam
pellentesque nec nam aliquam sem et tortor consequat id porta nibh venenatis cras
sed felis eget velit aliquet sagittis id consectetur purus ut faucibus pulvinar
elementum integer enim neque volutpat ac tincidunt vitae semper quis lectus nulla
at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet
proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum co",
"description": "enim facilisis",
"developer": "Pete's Proptech World Ltd",
"homePage": "http://myawesomeproptechproduct.io",
"id": "9b6fd5f7-2c15-483d-b925-01b650538e52",
Expand Down Expand Up @@ -101,7 +96,7 @@ exports[`Aside Aside - should match snapshot 1`] = `
"name": "Marketplace/developers.write",
},
],
"summary": "vitae elementum curabitur vitae nunc sed velit eget gravida cum sociis natoque!!",
"summary": "vitae elementum curabitur vitae",
"supportEmail": "[email protected]",
"telephone": "0113 288 2900",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
appDetailData={
Object {
"data": Object {
"description": "enim facilisis gravida neque convallis a cras semper auctor neque vitae tempus quam
pellentesque nec nam aliquam sem et tortor consequat id porta nibh venenatis cras
sed felis eget velit aliquet sagittis id consectetur purus ut faucibus pulvinar
elementum integer enim neque volutpat ac tincidunt vitae semper quis lectus nulla
at volutpat diam ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet
proin fermentum leo vel orci porta non pulvinar neque laoreet suspendisse interdum co",
"description": "enim facilisis",
"developer": "Pete's Proptech World Ltd",
"homePage": "http://myawesomeproptechproduct.io",
"id": "9b6fd5f7-2c15-483d-b925-01b650538e52",
Expand Down Expand Up @@ -54,7 +49,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"name": "Marketplace/developers.write",
},
],
"summary": "vitae elementum curabitur vitae nunc sed velit eget gravida cum sociis natoque!!",
"summary": "vitae elementum curabitur vitae",
"supportEmail": "[email protected]",
"telephone": "0113 288 2900",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MarketplaceStatusSection MarketplaceStatusSection should match a snapshot 1`] = `
<div>
<Component
key="test"
>
<Component
id="test"
labelText=""
name="scopes"
value="test"
/>
</Component>
<div
className="has-text-danger has-text-right undefined"
data-test="input-error"
>
test
</div>
</div>
`;

exports[`MarketplaceStatusSection should match a snapshot 1`] = `
<Component>
<Component>
Permissions
</Component>
<Component>
To access a client's data, you will need to specify the entities you need access to on a read or write basis. You should be familiar with these entities from the sandbox. When the user installs your application, they will have to consent to your usage based on these permissions. If you do not have the correct permissions on an entity basis, your app will receive a 403 error.
</Component>
<Component>
<Component
key="test"
>
<Component
id="test"
labelText=""
name="scopes"
value="test"
/>
</Component>
<div
className="has-text-danger has-text-right undefined"
data-test="input-error"
>
test
</div>
</Component>
</Component>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MarketplaceStatusSection should match a snapshot 1`] = `
<Component>
<Component>
<Component>
<Component>
Redirect URI(s)
</Component>
<Component>
Please enter a Redirect URI(s) to define the route Reapit Connect is permitted to redirect to after a successful authentication. The following formats are supported: https://, http:// (for localhost only) or your own custom URI schemes such as myapp://login. For multiple URI’s, separate using a comma.
</Component>
<Component
dataTest="submit-app-redirect-uri"
disabled={false}
id="redirectUris"
name="redirectUris"
placeholder="Enter your Redirect URI(s)"
type="text"
/>
</Component>
</Component>
<Component>
<Component>
<Component>
Sign Out URI(s)
</Component>
<Component>
Please enter a Sign Out URI(s) to define the route Reapit Connect is permitted to redirect to after successfully logging out. The following formats are supported: https://, http:// (for localhost only) or your own custom URI schemes such as myapp://login. For multiple URI’s, separate using a comma.
</Component>
<Component
dataTest="submit-app-signout-uris"
disabled={false}
id="signoutUris"
name="signoutUris"
placeholder="Enter your Sign Out URI(s)"
type="text"
/>
</Component>
</Component>
<Component>
<Component>
<Component>
Private Apps
</Component>
<Component>
If your App is a Private App and you would like it to only be visible to certain customers, please select ‘Yes’ below. You should then enter the ‘Customer ID’ of the customer(s) you wish to share your app with. If you select ‘No’, your App will be visible to all on the Marketplace. For multiple customers, please separate the Customer IDs using a comma, e.g. ABC, DEF.
</Component>
<Component
id="isPrivateApp"
name="isPrivateApp"
options={
Array [
Object {
"label": "YES",
"value": "yes",
},
Object {
"label": "NO",
"value": "no",
},
]
}
setFieldValue={[MockFunction]}
state="no"
/>
<Component
dataTest="submit-app-limited-to-client-ids"
disabled={true}
id="limitToClientIds"
name="limitToClientIds"
placeholder="Please enter the Customer ID. For multiple Customer ID’s, please separate using a comma"
type="text"
/>
</Component>
</Component>
</Component>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MarketplaceStatusSection should match a snapshot 1`] = `
<Component>
<Component>
Images
</Component>
<Component>
The icon field will appear as the main brand representation of your app in marketplace listings and installed apps pages. You can also select a minimum of one and up to five screenshots of your application, that will appear in a carousel in the details view of your app listing.
</Component>
<Component>
<Component>
<div
className="control"
>
<label
className="label"
>
Icon
</label>
<Component
allowClear={true}
dataTest="submit-app-icon"
id="iconImage"
labelText="Upload Image"
name="iconImageUrl"
/>
</div>
</Component>
<Component>
<div
className="control mb-4"
>
<label
className="label"
>
Screenshot 1
</label>
<Component
allowClear={true}
dataTest="submit-app-screenshot1"
id="screenshot1"
labelText="Upload Image"
name="screen1ImageUrl"
/>
</div>
</Component>
<Component>
<div
className="control mb-4"
>
<label
className="label"
>
Screenshot 2
</label>
<Component
allowClear={true}
dataTest="submit-app-screenshot2"
id="screenshot2"
labelText="Upload Image"
name="screen2ImageUrl"
/>
</div>
</Component>
<Component>
<div
className="control mb-4"
>
<label
className="label"
>
Screenshot 3
</label>
<Component
allowClear={true}
dataTest="submit-app-screenshot3"
id="screenshot3"
labelText="Upload Image"
name="screen3ImageUrl"
/>
</div>
</Component>
<Component>
<div
className="control mb-4"
>
<label
className="label"
>
Screenshot 4
</label>
<Component
allowClear={true}
dataTest="submit-app-screenshot4"
id="screenshot4"
labelText="Upload Image"
name="screen4ImageUrl"
/>
</div>
</Component>
<Component>
<div
className="control mb-4"
>
<label
className="label"
>
Screenshot 5
</label>
<Component
allowClear={true}
dataTest="submit-app-screenshot5"
id="screenshot5"
labelText="Upload Image"
name="screen5ImageUrl"
/>
</div>
</Component>
</Component>
</Component>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import DeveloperSubmitApp, {
handleSubmitModalContinue,
handleGoBackToApps,
handleOnSubmitAnotherApp,
generateInitialValues,
} from '../developer-submit-app'
import { getMockRouterProps } from '@/utils/mock-helper'
import { FIELD_ERROR_DESCRIPTION } from '@/constants/form'
Expand All @@ -27,6 +28,7 @@ import { CreateAppModel } from '@/types/marketplace-api-schema'
import { submitRevision } from '@/actions/submit-revision'
import DOCS_LINKS from '@/constants/docs-links'
import { getCookieString, setCookieString, COOKIE_FIRST_SUBMIT, COOKIE_MAX_AGE_INFINITY } from '@/utils/cookie'
import { appDetailDataStub } from '@/sagas/__stubs__/app-detail'

jest.mock('@/utils/cookie', () => ({
getCookieString: jest.fn(),
Expand Down Expand Up @@ -234,4 +236,60 @@ describe('DeveloperSubmitApp', () => {
expect(spyDispatch).toBeCalledWith(submitAppSetFormState('PENDING'))
})
})
describe('generateInitialValues', () => {
it('should run correctly in case appDetail is null', () => {
const result = generateInitialValues(null, 'testid')
expect(result).toEqual({
categoryId: '',
authFlow: '',
screen5ImageUrl: '',
screen4ImageUrl: '',
screen3ImageUrl: '',
screen2ImageUrl: '',
screen1ImageUrl: '',
name: '',
telephone: '',
supportEmail: '',
launchUri: '',
iconImageUrl: '',
homePage: '',
description: '',
summary: '',
developerId: 'testid',
scopes: [],
redirectUris: '',
signoutUris: '',
limitToClientIds: '',
desktopIntegrationTypeIds: '',
})
})
it('should run correctly in case appDetail is existed', () => {
const result = generateInitialValues(appDetailDataStub.data, 'testid')
expect(result).toEqual({
authFlow: undefined,
categoryId: '',
description: 'enim facilisis',
desktopIntegrationTypeIds: [],
developerId: undefined,
homePage: 'http://myawesomeproptechproduct.io',
iconImageUrl: '',
isDirectApi: undefined,
isListed: undefined,
isPrivateApp: 'no',
launchUri: undefined,
limitToClientIds: '',
name: "Peter's Properties",
redirectUris: '',
scopes: ['Marketplace/developers.read', 'Marketplace/developers.write'],
screen1ImageUrl:
'https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png',
screen2ImageUrl:
'https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png',
signoutUris: '',
summary: 'vitae elementum curabitur vitae',
supportEmail: '[email protected]',
telephone: '0113 288 2900',
})
})
})
})
Loading

0 comments on commit 9162825

Please sign in to comment.