Repository navigation
M3-7467 Add Cypress test for Domain cloning #10403
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | ||
| --- | ||
|
|
||
| Add Cypress test for Domain cloning ([#10403](https://github.com/linode/manager/pull/10403)) |
This file contains hidden or 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 | ||
| --- | ||
|
|
||
| Add Cypress test for Domain cloning ([#10403](https://github.com/linode/manager/pull/10403)) |
137 changes: 137 additions & 0 deletions
137
packages/manager/cypress/e2e/core/domains/smoke-clone-domain.spec.ts
This file contains hidden or 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,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 }); | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or 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
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for moving this out, Cassie! |
This file contains hidden or 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,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, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!