-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
M3-6505: Add StackScript Update/Delete E2E Tests
- Loading branch information
1 parent
e8b0246
commit 2b47c51
Showing
5 changed files
with
459 additions
and
6 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
104 changes: 104 additions & 0 deletions
104
packages/manager/cypress/e2e/core/stackscripts/delete-stackscripts.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,104 @@ | ||
import { authenticate } from 'support/api/authentication'; | ||
import { stackScriptFactory } from 'src/factories'; | ||
import { | ||
mockDeleteStackScript, | ||
interceptGetStackScripts, | ||
mockGetStackScripts, | ||
} from 'support/intercepts/stackscripts'; | ||
import { ui } from 'support/ui'; | ||
|
||
authenticate(); | ||
describe('Delete stackscripts', () => { | ||
/* | ||
* - Deletes the stackscripts. | ||
* - Confirms that the stackscript item still exist when cancelling the delete operation. | ||
* - Confirms that the stackscript item can be deleted successfully. | ||
* - Confirms that "Automate Deployment with StackScripts!" welcome page appears when user has no StackScript. | ||
*/ | ||
it('deletes the stackscripts', () => { | ||
const stackScripts = stackScriptFactory.buildList(2, { | ||
is_public: false, | ||
}); | ||
interceptGetStackScripts(stackScripts).as('getStackScripts'); | ||
cy.visitWithLogin('/stackscripts/account'); | ||
cy.wait('@getStackScripts'); | ||
|
||
// Do nothing when cancelling | ||
cy.get(`[aria-label="${stackScripts[0].label}"]`) | ||
.closest('tr') | ||
.within(() => { | ||
ui.actionMenu | ||
.findByTitle(`Action menu for StackScript ${stackScripts[0].label}`) | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
ui.actionMenuItem.findByTitle('Delete').should('be.visible').click(); | ||
ui.dialog | ||
.findByTitle(`Delete StackScript ${stackScripts[0].label}?`) | ||
.should('be.visible') | ||
.within(() => { | ||
ui.button.findByTitle('Cancel').should('be.visible').click(); | ||
}); | ||
|
||
cy.findByText(stackScripts[0].label) | ||
.should('be.visible') | ||
.closest('tr') | ||
.within(() => { | ||
cy.findByText(stackScripts[0].description).should('be.visible'); | ||
}); | ||
|
||
// The StackScript is deleted successfully. | ||
cy.get(`[aria-label="${stackScripts[0].label}"]`) | ||
.closest('tr') | ||
.within(() => { | ||
ui.actionMenu | ||
.findByTitle(`Action menu for StackScript ${stackScripts[0].label}`) | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
mockDeleteStackScript(stackScripts[0].id).as('deleteStackScript'); | ||
const updateStackScript = JSON.parse(JSON.stringify(stackScripts[1])); | ||
mockGetStackScripts([updateStackScript]).as('getUpdatedStackScripts'); | ||
ui.actionMenuItem.findByTitle('Delete').should('be.visible').click(); | ||
ui.dialog | ||
.findByTitle(`Delete StackScript ${stackScripts[0].label}?`) | ||
.should('be.visible') | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Delete StackScript') | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
cy.wait('@deleteStackScript'); | ||
cy.wait('@getUpdatedStackScripts'); | ||
|
||
cy.findByText(stackScripts[0].label).should('not.exist'); | ||
|
||
// The "Automate Deployment with StackScripts!" welcome page appears when no StackScript exists. | ||
cy.get(`[aria-label="${stackScripts[1].label}"]`) | ||
.closest('tr') | ||
.within(() => { | ||
ui.actionMenu | ||
.findByTitle(`Action menu for StackScript ${stackScripts[1].label}`) | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
mockDeleteStackScript(stackScripts[1].id).as('deleteStackScript'); | ||
mockGetStackScripts([]).as('getUpdatedStackScripts'); | ||
ui.actionMenuItem.findByTitle('Delete').should('be.visible').click(); | ||
ui.dialog | ||
.findByTitle(`Delete StackScript ${stackScripts[1].label}?`) | ||
.should('be.visible') | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Delete StackScript') | ||
.should('be.visible') | ||
.click(); | ||
}); | ||
cy.wait('@deleteStackScript'); | ||
cy.wait('@getUpdatedStackScripts'); | ||
|
||
cy.findByText(stackScripts[1].label).should('not.exist'); | ||
cy.findByText('Automate deployment scripts').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
Oops, something went wrong.