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

test: [M3-8661] - Cypress test to validate CAA record are editable #11440

5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11440-added-1734593684793.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changeset should be for Tests category

---

Cypress test to validate CAA records are editable ([#11440](https://github.com/linode/manager/pull/11440))
Original file line number Diff line number Diff line change
Expand Up @@ -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();

jdamore-linode marked this conversation as resolved.
Show resolved Hide resolved
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) => {
Expand All @@ -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',
hasyed-akamai marked this conversation as resolved.
Show resolved Hide resolved
'iodef',
'mailto:security@example.com',
'5 minutes'
);

// Verify the initial record is in the table
verifyRecordInTable(
'securitytest',
'iodef',
'mailto:security@example.com',
'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:secdef@example.com');
cy.get('table').should('contain', 'mailto:secdef@example.com');
});

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');
});
});
Loading