-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [M3-8661] - Cypress test to validate CAA record are editable (#…
…11440) * test: [M3-8661] - Cypress test to validate CAA record are editable * Added changeset: Cypress test to validate CAA records are editable * Splitting the test cases for valid and invalid records * Move`createCaaRecord` and `verifyRecordInTable` function calls in `beforeEach` block * Add cleanup, use @example.com for emails, and replace `cy.get()` for stability. * Update Changeset type
- Loading branch information
1 parent
7432afd
commit 3febaa0
Showing
2 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"@linode/manager": Tests | ||
--- | ||
|
||
Cypress test to validate CAA records are editable ([#11440](https://github.com/linode/manager/pull/11440)) |
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 |
---|---|---|
|
@@ -2,22 +2,83 @@ import { authenticate } from 'support/api/authentication'; | |
import { createDomain } from 'support/api/domains'; | ||
import { interceptCreateDomainRecord } from 'support/intercepts/domains'; | ||
import { createDomainRecords } from 'support/constants/domains'; | ||
import { ui } from 'support/ui'; | ||
import { cleanUp } from 'support/util/cleanup'; | ||
|
||
const createCaaRecord = ( | ||
name: string, | ||
tag: string, | ||
value: string, | ||
ttl: string | ||
) => { | ||
cy.findByText('Add a CAA Record').click(); | ||
|
||
// Fill in the form fields | ||
cy.findByLabelText('Name').type(name); | ||
|
||
ui.autocomplete.findByLabel('Tag').click(); | ||
ui.autocompletePopper.findByTitle(tag).click(); | ||
|
||
cy.findByLabelText('Value').type(value); | ||
|
||
ui.autocomplete.findByLabel('TTL').click(); | ||
ui.autocompletePopper.findByTitle(ttl).click(); | ||
|
||
// Save the record | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}; | ||
|
||
// Reusable function to edit a CAA record | ||
const editCaaRecord = (name: string, newValue: string) => { | ||
ui.actionMenu | ||
.findByTitle(`Action menu for Record ${name}`) | ||
.should('be.visible') | ||
.click(); | ||
|
||
ui.actionMenuItem.findByTitle('Edit').should('be.visible').click(); | ||
|
||
// Edit the value field | ||
cy.findByLabelText('Value').clear().type(newValue); | ||
ui.button.findByTitle('Save').click(); | ||
}; | ||
|
||
// Reusable function to verify record details in the table | ||
const verifyRecordInTable = ( | ||
name: string, | ||
tag: string, | ||
value: string, | ||
ttl: string | ||
) => { | ||
cy.get('[aria-label="List of Domains CAA Record"]') // Target table by aria-label | ||
.should('contain', name) | ||
.and('contain', tag) | ||
.and('contain', value) | ||
.and('contain', ttl); | ||
}; | ||
|
||
authenticate(); | ||
|
||
before(() => { | ||
cleanUp('domains'); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.tag('method:e2e'); | ||
createDomain().then((domain) => { | ||
// intercept create API record request | ||
interceptCreateDomainRecord().as('apiCreateRecord'); | ||
const url = `/domains/${domain.id}`; | ||
cy.visitWithLogin(url); | ||
cy.url().should('contain', url); | ||
}); | ||
}); | ||
|
||
describe('Creates Domains records with Form', () => { | ||
it('Adds domain records to a newly created Domain', () => { | ||
createDomain().then((domain) => { | ||
// intercept create api record request | ||
interceptCreateDomainRecord().as('apiCreateRecord'); | ||
const url = `/domains/${domain.id}`; | ||
cy.visitWithLogin(url); | ||
cy.url().should('contain', url); | ||
}); | ||
|
||
createDomainRecords().forEach((rec) => { | ||
cy.findByText(rec.name).click(); | ||
rec.fields.forEach((field) => { | ||
|
@@ -36,3 +97,37 @@ describe('Creates Domains records with Form', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('Tests for Editable Domain CAA Records', () => { | ||
beforeEach(() => { | ||
// Create the initial record with a valid email | ||
createCaaRecord( | ||
'securitytest', | ||
'iodef', | ||
'mailto:[email protected]', | ||
'5 minutes' | ||
); | ||
|
||
// Verify the initial record is in the table | ||
verifyRecordInTable( | ||
'securitytest', | ||
'iodef', | ||
'mailto:[email protected]', | ||
'5 minutes' | ||
); | ||
}); | ||
|
||
it('Validates that "iodef" domain records can be edited with valid record', () => { | ||
// Edit the record with a valid email and verify the updated record | ||
editCaaRecord('securitytest', 'mailto:[email protected]'); | ||
cy.get('table').should('contain', 'mailto:[email protected]'); | ||
}); | ||
|
||
it('Validates that "iodef" domain records returns error with invalid record', () => { | ||
// Edit the record with invalid email and validate form validation | ||
editCaaRecord('securitytest', 'invalid-email-format'); | ||
cy.get('p[role="alert"][data-qa-textfield-error-text="Value"]') | ||
.should('exist') | ||
.and('have.text', 'You have entered an invalid target'); | ||
}); | ||
}); |