Skip to content
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10403-tests-1714588716317.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add Cypress test for Domain cloning ([#10403](https://github.com/linode/manager/pull/10403))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10403-tests-1714588819736.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cliu-akamai I'm seeing two changesets here. Can we delete one? Otherwise, this looks good to go!

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add Cypress test for Domain cloning ([#10403](https://github.com/linode/manager/pull/10403))
137 changes: 137 additions & 0 deletions packages/manager/cypress/e2e/core/domains/smoke-clone-domain.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import { Domain } from '@linode/api-v4';
import { domainFactory } from '@src/factories';
import { getClick, fbtClick, fbltClick } from 'support/helpers';
import { authenticate } from 'support/api/authentication';
import { randomDomainName } from 'support/util/random';
import { createDomain } from '@linode/api-v4/lib/domains';
import { createDomainRecords } from 'support/constants/domains';
import { interceptCreateDomainRecord } from 'support/intercepts/domains';
import { ui } from 'support/ui';
import { cleanUp } from 'support/util/cleanup';

authenticate();
describe('Clone a Domain', () => {
before(() => {
cleanUp('domains');
});

/*
* - Clicks "Clone" action menu item for domain but cancels operation.
* - Clicks "Clone" action menu item for domain and confirms operation.
* - Confirms that a "Domain is not valid." error is yielded when entering an invalid domain name.
* - Confirms that the user is redirected to the new Domain's details page after cloning.
* - Confirms that domain is still in landing page list after canceled operation.
* - Confirms that cloned domains contain the same records as the original Domain.
*/
it('clones a domain', () => {
const domainRequest = domainFactory.build({
domain: randomDomainName(),
group: 'test-group',
});

const invalidDomainName = 'invalid-domain-name';
const clonedDomainName = randomDomainName();

const domainRecords = createDomainRecords();

cy.defer(createDomain(domainRequest), 'creating domain').then(
(domain: Domain) => {
// Add records to the domain.
cy.visitWithLogin(`/domains/${domain.id}`);

domainRecords.forEach((rec) => {
interceptCreateDomainRecord().as('apiCreateRecord');
fbtClick(rec.name);
rec.fields.forEach((f) => {
getClick(f.name).type(f.value);
});
fbtClick('Save');
cy.wait('@apiCreateRecord');
});

cy.visitWithLogin('/domains');

// Confirm that domain is listed and initiate deletion.
cy.findByText(domain.domain)
.should('be.visible')
.closest('tr')
.within(() => {
ui.actionMenu
.findByTitle(`Action menu for Domain ${domain}`)
.should('be.visible')
.click();
});
ui.actionMenuItem.findByTitle('Clone').should('be.visible').click();

// Cancel cloning when prompted to confirm.
ui.drawer
.findByTitle(`Clone Domain`)
.should('be.visible')
.within(() => {
ui.buttonGroup
.findButtonByTitle('Cancel')
.should('be.visible')
.should('be.enabled')
.click();
});

// Confirm that no new domain is added and initiate cloning again.
cy.findByText(domain.domain)
.should('be.visible')
.closest('tr')
.within(() => {
ui.actionMenu
.findByTitle(`Action menu for Domain ${domain}`)
.should('be.visible')
.click();
});
ui.actionMenuItem.findByTitle('Clone').should('be.visible').click();

// Confirm cloning.
ui.drawer
.findByTitle(`Clone Domain`)
.should('be.visible')
.within(() => {
// The button should be disabled before confirming the correct domain
ui.buttonGroup
.findButtonByTitle('Create Domain')
.should('be.visible')
.should('be.disabled');

// Confirm that an error is displayed when entering an invalid domain name
fbltClick('New Domain').type(invalidDomainName);
ui.buttonGroup
.findButtonByTitle('Create Domain')
.should('be.visible')
.should('be.enabled')
.click();
cy.findByText('Domain is not valid.').should('be.visible');

fbltClick('New Domain').clear().type(clonedDomainName);
ui.buttonGroup
.findButtonByTitle('Create Domain')
.should('be.visible')
.should('be.enabled')
.click();
});
// After cloning a Domain, the user is redirected to the new Domain's details page
cy.url().should('endWith', 'domains');

// Confirm that domain is cloned and cloned domains contain the same records as the original Domain.
cy.visitWithLogin('/domains');
cy.findByText(domain.domain).should('be.visible');
cy.findByText(clonedDomainName).should('be.visible').click();
domainRecords.forEach((rec) => {
cy.get(`[aria-label="${rec.tableAriaLabel}"]`).within((_table) => {
rec.fields.forEach((f) => {
if (f.skipCheck) {
return;
}
cy.findByText(f.value, { exact: !f.approximate });
});
});
});
}
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,15 @@ import { createDomain } from 'support/api/domains';
import { fbtClick, getClick } from 'support/helpers';
import { interceptCreateDomainRecord } from 'support/intercepts/domains';
import { cleanUp } from 'support/util/cleanup';
import {
randomDomainName,
randomIp,
randomLabel,
randomString,
} from 'support/util/random';

const createRecords = () => [
{
name: 'Add an A/AAAA Record',
tableAriaLabel: 'List of Domains A/AAAA Record',
fields: [
{
name: '[data-qa-target="Hostname"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="IP Address"]',
value: `${randomIp()}`,
skipCheck: false,
},
],
},
{
name: 'Add a CNAME Record',
tableAriaLabel: 'List of Domains CNAME Record',
fields: [
{
name: '[data-qa-target="Hostname"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="Alias to"]',
value: `${randomLabel()}.net`,
skipCheck: false,
},
],
},
{
name: 'Add a TXT Record',
tableAriaLabel: 'List of Domains TXT Record',
fields: [
{
name: '[data-qa-target="Hostname"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="Value"]',
value: `${randomLabel()}=${randomString()}`,
skipCheck: false,
},
],
},
{
name: 'Add an SRV Record',
tableAriaLabel: 'List of Domains SRV Record',
fields: [
{
name: '[data-qa-target="Service"]',
value: randomLabel(),
skipCheck: true,
},
{
name: '[data-qa-target="Target"]',
value: randomLabel(),
approximate: true,
},
],
},
{
name: 'Add a CAA Record',
tableAriaLabel: 'List of Domains CAA Record',
fields: [
{
name: '[data-qa-target="Name"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="Value"]',
value: randomDomainName(),
skipCheck: false,
},
],
},
];
import { createDomainRecords } from 'support/constants/domains';

authenticate();
describe('Creates Domains record with Form', () => {
before(() => {
cleanUp('domains');
});

createRecords().forEach((rec) => {
createDomainRecords().forEach((rec) => {
return it(rec.name, () => {
createDomain().then((domain) => {
// intercept create api record request
Expand Down
90 changes: 90 additions & 0 deletions packages/manager/cypress/support/constants/domains.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for moving this out, Cassie!

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {
randomLabel,
randomIp,
randomString,
randomDomainName,
} from 'support/util/random';

// Array of domain records for which to test creation.
export const createDomainRecords = () => [
{
name: 'Add an A/AAAA Record',
tableAriaLabel: 'List of Domains A/AAAA Record',
fields: [
{
name: '[data-qa-target="Hostname"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="IP Address"]',
value: `${randomIp()}`,
skipCheck: false,
},
],
},
{
name: 'Add a CNAME Record',
tableAriaLabel: 'List of Domains CNAME Record',
fields: [
{
name: '[data-qa-target="Hostname"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="Alias to"]',
value: `${randomLabel()}.net`,
skipCheck: false,
},
],
},
{
name: 'Add a TXT Record',
tableAriaLabel: 'List of Domains TXT Record',
fields: [
{
name: '[data-qa-target="Hostname"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="Value"]',
value: `${randomLabel()}=${randomString()}`,
skipCheck: false,
},
],
},
{
name: 'Add an SRV Record',
tableAriaLabel: 'List of Domains SRV Record',
fields: [
{
name: '[data-qa-target="Service"]',
value: randomLabel(),
skipCheck: true,
},
{
name: '[data-qa-target="Target"]',
value: randomLabel(),
approximate: true,
},
],
},
{
name: 'Add a CAA Record',
tableAriaLabel: 'List of Domains CAA Record',
fields: [
{
name: '[data-qa-target="Name"]',
value: randomLabel(),
skipCheck: false,
},
{
name: '[data-qa-target="Value"]',
value: randomDomainName(),
skipCheck: false,
},
],
},
];