Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(entities): form state data-testids [khcp-13000] #1576

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ describe('<CACertificateForm />', () => {
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
cy.get('.kong-ui-entities-ca-certificates-form form').should('be.visible')
// button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-create-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-create-form-submit').should('be.visible')
cy.getTestId('ca_certificate-create-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.disabled')
// form fields
cy.getTestId('ca-certificate-form-cert').should('be.visible')
cy.getTestId('ca-certificate-form-cert-digest').should('be.visible')
Expand All @@ -90,16 +90,16 @@ describe('<CACertificateForm />', () => {

cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
// default button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-create-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-create-form-submit').should('be.visible')
cy.getTestId('ca_certificate-create-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.disabled')
// enables save when required fields have values
cy.getTestId('ca-certificate-form-cert').type(caCertificate1.cert)
cy.getTestId('ca_certificate-form-submit').should('be.enabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.enabled')
// disables save when required field is cleared
cy.getTestId('ca-certificate-form-cert').clear()
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.disabled')
})

it('should show edit form', () => {
Expand All @@ -115,10 +115,10 @@ describe('<CACertificateForm />', () => {
cy.wait('@getCertificate')
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
// button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-edit-form-submit').should('be.visible')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.disabled')
// form fields
cy.getTestId('ca-certificate-form-cert').should('have.value', caCertificate1.cert)
})
Expand All @@ -136,16 +136,16 @@ describe('<CACertificateForm />', () => {
cy.wait('@getCertificate')
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
// default button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-edit-form-submit').should('be.visible')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.disabled')
// enables save when form has changes
cy.getTestId('ca-certificate-form-cert-digest').type('edited')
cy.getTestId('ca_certificate-form-submit').should('be.enabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.enabled')
// disables save when form changes are undone
cy.getTestId('ca-certificate-form-cert-digest').clear()
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.disabled')
})

it('should handle error state - failed to load CA Certificate', () => {
Expand All @@ -172,8 +172,8 @@ describe('<CACertificateForm />', () => {
// error state is displayed
cy.getTestId('form-fetch-error').should('be.visible')
// buttons and form hidden
cy.getTestId('ca_certificate-form-cancel').should('not.exist')
cy.getTestId('ca_certificate-form-submit').should('not.exist')
cy.getTestId('ca_certificate-edit-form-cancel').should('not.exist')
cy.getTestId('ca_certificate-edit-form-submit').should('not.exist')
cy.get('.kong-ui-entities-ca-certificates-form form').should('not.exist')
})

Expand Down Expand Up @@ -255,10 +255,10 @@ describe('<CACertificateForm />', () => {
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
cy.get('.kong-ui-entities-ca-certificates-form form').should('be.visible')
// button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-create-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-create-form-submit').should('be.visible')
cy.getTestId('ca_certificate-create-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.disabled')
// form fields
cy.getTestId('ca-certificate-form-cert').should('be.visible')
cy.getTestId('ca-certificate-form-cert-digest').should('be.visible')
Expand All @@ -273,16 +273,16 @@ describe('<CACertificateForm />', () => {
})
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
// default button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-create-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-create-form-submit').should('be.visible')
cy.getTestId('ca_certificate-create-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.disabled')
// enables save when required fields have values
cy.getTestId('ca-certificate-form-cert').type(caCertificate1.cert)
cy.getTestId('ca_certificate-form-submit').should('be.enabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.enabled')
// disables save when required field is cleared
cy.getTestId('ca-certificate-form-cert').clear()
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-create-form-submit').should('be.disabled')
})

it('should show edit form', () => {
Expand All @@ -298,10 +298,10 @@ describe('<CACertificateForm />', () => {
cy.wait('@getCertificate')
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
// button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-edit-form-submit').should('be.visible')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.disabled')
// form fields
cy.getTestId('ca-certificate-form-cert').should('have.value', caCertificate1.cert)
})
Expand All @@ -319,16 +319,16 @@ describe('<CACertificateForm />', () => {
cy.wait('@getCertificate')
cy.get('.kong-ui-entities-ca-certificates-form').should('be.visible')
// default button state
cy.getTestId('ca_certificate-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-form-submit').should('be.visible')
cy.getTestId('ca_certificate-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.visible')
cy.getTestId('ca_certificate-edit-form-submit').should('be.visible')
cy.getTestId('ca_certificate-edit-form-cancel').should('be.enabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.disabled')
// enables save when form has changes
cy.getTestId('ca-certificate-form-cert-digest').type('edited')
cy.getTestId('ca_certificate-form-submit').should('be.enabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.enabled')
// disables save when form changes are undone
cy.getTestId('ca-certificate-form-cert-digest').clear()
cy.getTestId('ca_certificate-form-submit').should('be.disabled')
cy.getTestId('ca_certificate-edit-form-submit').should('be.disabled')
})

it('should handle error state - failed to load CA Certificate', () => {
Expand All @@ -355,8 +355,8 @@ describe('<CACertificateForm />', () => {
// error state is displayed
cy.getTestId('form-fetch-error').should('be.visible')
// buttons and form hidden
cy.getTestId('ca_certificate-form-cancel').should('not.exist')
cy.getTestId('ca_certificate-form-submit').should('not.exist')
cy.getTestId('ca_certificate-create-form-cancel').should('not.exist')
cy.getTestId('ca_certificate-create-form-submit').should('not.exist')
cy.get('.kong-ui-entities-ca-certificates-form form').should('not.exist')
})

Expand Down
Loading
Loading