-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [M3-6550] - Add Domain delete, import a zone, and download zone…
… file Cypress tests (#9111) * M3-6550: Add new Domain tests * Fix comments
- Loading branch information
1 parent
0e7448c
commit 1e52cb0
Showing
6 changed files
with
336 additions
and
2 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
packages/manager/cypress/e2e/domains/smoke-delete-domain.spec.ts
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,86 @@ | ||
import { Domain } from '@linode/api-v4/types'; | ||
import { domainFactory } from '@src/factories'; | ||
import { containsClick } from 'support/helpers'; | ||
import { authenticate } from 'support/api/authentication'; | ||
import { randomDomainName } from 'support/util/random'; | ||
import { createDomain } from '@linode/api-v4/lib/domains'; | ||
import { ui } from 'support/ui'; | ||
|
||
authenticate(); | ||
describe('Delete a Domain', () => { | ||
/* | ||
* - Clicks "Delete" action menu item for domain but cancels operation. | ||
* - Clicks "Delete" action menu item for domain and confirms operation. | ||
* - Confirms that domain is still in landing page list after canceled operation. | ||
* - Confirms that domain is removed from landing page list after confirmed operation. | ||
*/ | ||
it('deletes a domain', () => { | ||
const domainRequest = domainFactory.build({ | ||
domain: randomDomainName(), | ||
group: 'test-group', | ||
}); | ||
|
||
cy.defer(createDomain(domainRequest)).then((domain: Domain) => { | ||
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('Delete').should('be.visible').click(); | ||
|
||
// Cancel deletion when prompted to confirm. | ||
ui.dialog | ||
.findByTitle(`Delete Domain ${domain.domain}?`) | ||
.should('be.visible') | ||
.within(() => { | ||
ui.buttonGroup | ||
.findButtonByTitle('Cancel') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}); | ||
|
||
// Confirm that domain is still listed and initiate deletion 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('Delete').should('be.visible').click(); | ||
|
||
// Confirm deletion. | ||
ui.dialog | ||
.findByTitle(`Delete Domain ${domain.domain}?`) | ||
.should('be.visible') | ||
.within(() => { | ||
// The button should be disabled before confirming the correct domain | ||
ui.buttonGroup | ||
.findButtonByTitle('Delete Domain') | ||
.should('be.visible') | ||
.should('be.disabled'); | ||
|
||
containsClick('Domain Name').type(domain.domain); | ||
ui.buttonGroup | ||
.findButtonByTitle('Delete Domain') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}); | ||
|
||
// Confirm that domain is deleted. | ||
cy.visitWithLogin('/domains'); | ||
cy.findByText(domain.domain).should('not.exist'); | ||
}); | ||
}); | ||
}); |
65 changes: 65 additions & 0 deletions
65
packages/manager/cypress/e2e/domains/smoke-domain-download-zone-file.spec.ts
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,65 @@ | ||
import { | ||
domainFactory, | ||
domainRecordFactory, | ||
domainZoneFileFactory, | ||
} from '@src/factories'; | ||
import { authenticate } from 'support/api/authentication'; | ||
import { fbtClick, fbtVisible } from 'support/helpers'; | ||
import { | ||
mockGetDomains, | ||
mockGetDomain, | ||
mockGetDomainRecords, | ||
mockGetDomainZoneFile, | ||
} from 'support/intercepts/domains'; | ||
import { randomDomainName } from 'support/util/random'; | ||
import { readDownload } from 'support/util/downloads'; | ||
import { ui } from 'support/ui'; | ||
|
||
authenticate(); | ||
describe('Download a Zone file', () => { | ||
/* | ||
* - Clicks "Import A Zone" button and confirms operation. | ||
* - Confirms that Domain won't be imported when the domain is empty or invalid. | ||
* - Confirms that Domain won't be imported when the name server is empty or invalid. | ||
* - Confirms that Domain exists after imported operation. | ||
*/ | ||
it('downloads a zone in the domain page', () => { | ||
const mockDomain = domainFactory.build({ | ||
id: 123, | ||
domain: randomDomainName(), | ||
group: 'test-group', | ||
}); | ||
const mockDomainRecords = domainRecordFactory.build(); | ||
const mockDomainZoneFile = domainZoneFileFactory.build(); | ||
const mockZoneFileContents = mockDomainZoneFile.zone_file.join('\n'); | ||
|
||
cy.visitWithLogin('/domains'); | ||
ui.button | ||
.findByTitle('Import a Zone') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
|
||
mockGetDomains(mockDomain).as('getDomains'); | ||
cy.visitWithLogin('/domains'); | ||
cy.wait('@getDomains'); | ||
|
||
mockGetDomain(mockDomain.id, mockDomain).as('getDomain'); | ||
mockGetDomainRecords(mockDomainRecords).as('getDomainRecords'); | ||
fbtVisible(mockDomain.domain); | ||
fbtClick(mockDomain.domain); | ||
cy.wait('@getDomain'); | ||
cy.wait('@getDomainRecords'); | ||
|
||
mockGetDomainZoneFile(mockDomain.id, mockDomainZoneFile).as( | ||
'getDomainZoneFile' | ||
); | ||
ui.button | ||
.findByTitle('Download DNS Zone File') | ||
.should('be.visible') | ||
.click(); | ||
cy.wait('@getDomainZoneFile'); | ||
|
||
readDownload(`${mockDomain.domain}.txt`).should('eq', mockZoneFileContents); | ||
}); | ||
}); |
105 changes: 105 additions & 0 deletions
105
packages/manager/cypress/e2e/domains/smoke-domain-import-a-zone.spec.ts
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,105 @@ | ||
import { ImportZonePayload } from '@linode/api-v4/types'; | ||
import { domainFactory } from '@src/factories'; | ||
import { authenticate } from 'support/api/authentication'; | ||
import { fbltClick } from 'support/helpers'; | ||
import { randomDomainName, randomIp } from 'support/util/random'; | ||
import { mockGetDomains, mockImportDomain } from 'support/intercepts/domains'; | ||
import { ui } from 'support/ui'; | ||
|
||
authenticate(); | ||
describe('Import a Zone', () => { | ||
/* | ||
* - Clicks "Import A Zone" button and confirms operation. | ||
* - Confirms that Domain won't be imported when the domain is empty or invalid. | ||
* - Confirms that Domain won't be imported when the name server is empty or invalid. | ||
* - Confirms that Domain exists after imported operation. | ||
*/ | ||
it('imports a zone in the domain page', () => { | ||
const zone: ImportZonePayload = { | ||
domain: randomDomainName(), | ||
remote_nameserver: randomIp(), | ||
}; | ||
|
||
const mockDomain = domainFactory.build({ | ||
domain: zone.domain, | ||
group: 'test-group', | ||
}); | ||
|
||
mockGetDomains(mockDomain).as('getDomains'); | ||
cy.visitWithLogin('/domains'); | ||
cy.wait('@getDomains'); | ||
|
||
ui.button | ||
.findByTitle('Import a Zone') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
|
||
ui.drawer | ||
.findByTitle('Import a Zone') | ||
.should('be.visible') | ||
.within(() => { | ||
// The button should be disabled before providing any values | ||
ui.buttonGroup | ||
.findButtonByTitle('Import') | ||
.should('be.visible') | ||
.should('be.disabled'); | ||
|
||
// Verify only filling out Domain cannot import | ||
fbltClick('Domain').clear().type(zone.domain); | ||
ui.buttonGroup | ||
.findButtonByTitle('Import') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
cy.findByText('Remote nameserver is required.'); | ||
|
||
// Verify invalid domain cannot import | ||
fbltClick('Domain').clear().type('1'); | ||
fbltClick('Remote Nameserver').clear().type(zone.remote_nameserver); | ||
ui.buttonGroup | ||
.findButtonByTitle('Import') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
cy.findByText('Domain is not valid.'); | ||
|
||
// Verify only filling out RemoteNameserver cannot import | ||
fbltClick('Domain').clear(); | ||
fbltClick('Remote Nameserver').clear().type(zone.remote_nameserver); | ||
ui.buttonGroup | ||
.findButtonByTitle('Import') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
cy.findByText('Domain is required.'); | ||
|
||
// Verify invalid remote nameserver cannot import | ||
fbltClick('Domain').clear().type(zone.domain); | ||
fbltClick('Remote Nameserver').clear().type('1'); | ||
ui.buttonGroup | ||
.findButtonByTitle('Import') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
cy.findByText(`The nameserver '1' is not valid.`); | ||
|
||
// Fill out and import the zone. | ||
mockImportDomain(mockDomain).as('importDomain'); | ||
mockGetDomains(mockDomain).as('getDomains'); | ||
fbltClick('Domain').clear().type(zone.domain); | ||
fbltClick('Remote Nameserver').clear().type(zone.remote_nameserver); | ||
ui.buttonGroup | ||
.findButtonByTitle('Import') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}); | ||
|
||
// Confirm that zone is imported. | ||
cy.wait('@importDomain'); | ||
cy.visitWithLogin('/domains'); | ||
cy.wait('@getDomains'); | ||
cy.findByText(zone.domain).should('be.visible'); | ||
}); | ||
}); |
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
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
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