-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
907 additions
and
1,185 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
frontend/src/__tests__/cypress/cypress/pages/connectionTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { TableRow } from './components/table'; | ||
|
||
class CreateConnectionTypeTableRow extends TableRow { | ||
findSectionHeading() { | ||
return this.find().findByTestId(['section-heading']); | ||
} | ||
|
||
findType() { | ||
return this.find().findByTestId(['field-type']); | ||
} | ||
|
||
findDefault() { | ||
return this.find().findByTestId(['field-default']); | ||
} | ||
|
||
findEnvVar() { | ||
return this.find().findByTestId(['field-env']); | ||
} | ||
|
||
findRequired() { | ||
return this.find().findByTestId(['field-required']); | ||
} | ||
} | ||
|
||
class CreateConnectionTypePage { | ||
visitCreatePage() { | ||
cy.visitWithLogin('/connectionTypes/create'); | ||
cy.findAllByText('Create connection type').should('exist'); | ||
} | ||
|
||
visitDuplicatePage(name = 'existing') { | ||
cy.visitWithLogin(`/connectionTypes/duplicate/${name}`); | ||
cy.findAllByText('Create connection type').should('exist'); | ||
} | ||
|
||
connectionTypeName() { | ||
return cy.findByTestId('connection-type-name'); | ||
} | ||
|
||
connectionTypeDesc() { | ||
return cy.findByTestId('connection-type-description'); | ||
} | ||
|
||
connectionTypeEnable() { | ||
return cy.findByTestId('connection-type-enable'); | ||
} | ||
|
||
findFieldsTable() { | ||
return cy.findByTestId('connection-type-fields-table'); | ||
} | ||
|
||
getFieldsTableRow(name = '') { | ||
return new CreateConnectionTypeTableRow(() => | ||
this.findFieldsTable().findByText(name).parents('tr'), | ||
); | ||
} | ||
|
||
findAllFieldsTableRows() { | ||
return this.findFieldsTable().findAllByTestId(['row']); | ||
} | ||
|
||
findSubmitButton() { | ||
return cy.findByTestId('submit-button'); | ||
} | ||
} | ||
|
||
export const createConnectionTypePage = new CreateConnectionTypePage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
frontend/src/__tests__/cypress/cypress/pages/modelRegistry/registerModelPage.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...end/src/__tests__/cypress/cypress/tests/mocked/connectionTypes/createConnectionType.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { | ||
mockConnectionTypeConfigMap, | ||
mockConnectionTypeConfigMapObj, | ||
} from '~/__mocks__/mockConnectionType'; | ||
import { createConnectionTypePage } from '~/__tests__/cypress/cypress/pages/connectionTypes'; | ||
import { asClusterAdminUser } from '~/__tests__/cypress/cypress/utils/mockUsers'; | ||
import type { SectionField, ShortTextField } from '~/concepts/connectionTypes/types'; | ||
|
||
describe('create', () => { | ||
it('Display base page', () => { | ||
asClusterAdminUser(); | ||
createConnectionTypePage.visitCreatePage(); | ||
|
||
createConnectionTypePage.connectionTypeName().should('exist'); | ||
createConnectionTypePage.connectionTypeDesc().should('exist'); | ||
createConnectionTypePage.connectionTypeEnable().should('exist'); | ||
createConnectionTypePage.findFieldsTable().should('exist'); | ||
}); | ||
|
||
it('Allows create button with valid name', () => { | ||
asClusterAdminUser(); | ||
createConnectionTypePage.visitCreatePage(); | ||
|
||
createConnectionTypePage.connectionTypeName().should('have.value', ''); | ||
createConnectionTypePage.findSubmitButton().should('be.disabled'); | ||
|
||
createConnectionTypePage.connectionTypeName().type('hello'); | ||
createConnectionTypePage.findSubmitButton().should('be.enabled'); | ||
}); | ||
}); | ||
|
||
describe('duplicate', () => { | ||
const existing = mockConnectionTypeConfigMapObj({ name: 'existing' }); | ||
|
||
beforeEach(() => { | ||
asClusterAdminUser(); | ||
cy.interceptOdh( | ||
'GET /api/connection-types/:name', | ||
{ path: { name: 'existing' } }, | ||
mockConnectionTypeConfigMap({ name: 'existing' }), | ||
); | ||
}); | ||
|
||
it('Prefill details from existing connection', () => { | ||
createConnectionTypePage.visitDuplicatePage('existing'); | ||
|
||
createConnectionTypePage | ||
.connectionTypeName() | ||
.should( | ||
'have.value', | ||
`Duplicate of ${existing.metadata.annotations['openshift.io/display-name']}`, | ||
); | ||
createConnectionTypePage | ||
.connectionTypeDesc() | ||
.should('have.value', existing.metadata.annotations['openshift.io/description']); | ||
createConnectionTypePage.connectionTypeEnable().should('be.checked'); | ||
}); | ||
|
||
it('Prefill fields table from existing connection', () => { | ||
createConnectionTypePage.visitDuplicatePage('existing'); | ||
|
||
createConnectionTypePage | ||
.findAllFieldsTableRows() | ||
.should('have.length', existing.data?.fields?.length); | ||
|
||
// Row 0 - Section | ||
const dataField0 = existing.data?.fields?.[0] as SectionField; | ||
const row0 = createConnectionTypePage.getFieldsTableRow(dataField0.name); | ||
row0.findSectionHeading().should('exist'); | ||
|
||
// Row 1 - Short text field | ||
const dataField1 = existing.data?.fields?.[1] as ShortTextField; | ||
const row1 = createConnectionTypePage.getFieldsTableRow(dataField1.name); | ||
row1.findType().should('have.text', dataField1.type); | ||
row1.findDefault().should('have.text', '-'); | ||
row1.findRequired().not('be.checked'); | ||
|
||
// Row 2 - Short text field | ||
const dataField2 = existing.data?.fields?.[2] as ShortTextField; | ||
const row2 = createConnectionTypePage.getFieldsTableRow(dataField2.name); | ||
row2.findType().should('have.text', dataField2.type); | ||
row2.findDefault().should('have.text', dataField2.properties.defaultValue); | ||
row2.findRequired().should('be.checked'); | ||
}); | ||
}); |
Oops, something went wrong.