Skip to content

Commit

Permalink
Add Cypress integration & initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyvesel committed May 29, 2019
1 parent bdc19a4 commit e22cd4e
Show file tree
Hide file tree
Showing 9 changed files with 14,355 additions and 74 deletions.
6 changes: 6 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"baseUrl": "http://localhost:9000",
"video": false,
"pluginsFile": false,
"supportFile": false
}
24 changes: 24 additions & 0 deletions cypress/integration/cluster_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe('Cluster functionality test', () => {
it('adds cluster with valid data', () => {
cy.visit('/');
cy.get('#add-cluster-btn').then(() => {
cy.get('#add-cluster-btn')
.first()
.click()
.then(() => {
cy.get('#cluster-name-input')
.type('test cluster')
cy.get('#url-input')
.type('example.com')
cy.get('#token-input')
.type('123456')
cy.get('#check-connection-btn')
.click()
cy.get('#submit-cluster-btn')
.click()
})
});
cy.contains('Add cluster')
cy.contains('test cluster')
});
});
13,381 changes: 13,381 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"prep-remote": "./scripts/prep-remote.sh",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"test": "jest --rootDir=. --config=config/jest.config.js"
"test:unit": "jest --rootDir=. --config=config/jest.config.js",
"test:integration": "cypress run",
"test": "yarn test:unit && yarn test:integration"
},
"devDependencies": {
"@babel/core": "7.4.3",
Expand All @@ -29,12 +31,13 @@
"@babel/preset-typescript": "7.3.3",
"@emotion/babel-preset-css-prop": "10.0.9",
"@emotion/styled": "10.0.9",
"@types/jest": "24.0.13",
"@types/node": "11.13.6",
"@types/jest": "24.0.11",
"@types/node": "^11.13.6",
"babel-loader": "8.0.6",
"babel-plugin-emotion": "10.0.9",
"clean-webpack-plugin": "2.0.1",
"css-loader": "2.1.1",
"cypress": "^3.3.1",
"extract-text-webpack-plugin": "4.0.0-beta.0",
"file-loader": "2.0.0",
"fork-ts-checker-webpack-plugin": "1.3.3",
Expand Down
6 changes: 3 additions & 3 deletions src/app/cluster/components/AddClusterModal/AddClusterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class WrappedAddClusterForm extends React.Component<any, any> {
value={values.name}
name="name"
type="text"
id="name"
id="cluster-name-input"
/>
{errors.name && touched.name && (
<FormErrorDiv id="feedback-name">{errors.name}</FormErrorDiv>
Expand All @@ -96,7 +96,7 @@ class WrappedAddClusterForm extends React.Component<any, any> {
name="url"
type="text"
// isValid={!errors.url && touched.url}
id="url"
id="url-input"
/>
{errors.url && touched.url && (
<FormErrorDiv id="feedback-url">{errors.url}</FormErrorDiv>
Expand All @@ -119,7 +119,7 @@ class WrappedAddClusterForm extends React.Component<any, any> {
onInput={() => setFieldTouched('token', true, true)}
onBlur={handleBlur}
name="token"
id="token"
id="token-input"
type={this.state.tokenHidden ? 'password' : 'text'}
/>
{errors.token && touched.token && (
Expand Down
2 changes: 2 additions & 0 deletions src/app/common/components/CheckConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const CheckConnection: React.FunctionComponent<IProps> = ({
variant="secondary"
isDisabled={!errorsObj || touchedObj}
onClick={() => checkConnection()}
id="check-connection-btn"
>
Check connection
</Button>
Expand All @@ -60,6 +61,7 @@ const CheckConnection: React.FunctionComponent<IProps> = ({
type="submit"
isDisabled={connectionState !== ConnectionState.Success}
style={{ marginRight: '10px' }}
id="submit-cluster-btn"
>
Add
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const ClusterDataListItem = ({ dataList, isLoading, associatedPlans, migMeta, ..
</DataListCell>,
]}
/>
<DataListAction aria-label="add-plan" aria-labelledby="plan-item" id="add-plan">
<Button onClick={toggleOpen} variant="link">
<PlusCircleIcon /> Add Cluster
<DataListAction aria-label="add-cluster" aria-labelledby="plan-item" id="add-cluster">
<Button aria-label="add-cluster-btn" id="add-cluster-btn" onClick={toggleOpen} variant="link">
<PlusCircleIcon /> Add cluster
</Button>
<AddClusterModal isOpen={isOpen} onHandleClose={toggleOpen} />
</DataListAction>
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@
"es7",
"dom"
]
}
}
},
}
Loading

0 comments on commit e22cd4e

Please sign in to comment.