Skip to content

Commit

Permalink
M3-6505: Add StackScript Update/Delete E2E Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cliu-akamai committed Jun 26, 2023
1 parent e8b0246 commit 2b47c51
Show file tree
Hide file tree
Showing 5 changed files with 459 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const createLinodeAndImage = async () => {
};

authenticate();
describe('stackscripts', () => {
describe('Create stackscripts', () => {
/*
* - Creates a StackScript with user-defined fields.
* - Confirms that an error message appears upon submitting script without a shebang.
Expand Down
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');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { mockGetStackScripts } from 'support/intercepts/stackscripts';
import { ui } from 'support/ui';

authenticate();
describe('stackscripts', () => {
describe('Display stackscripts', () => {
/*
* - Displays welcom message in the landing page.
* - Displays welcome message in the landing page.
* - Confirms that "Automate Deployment with StackScripts!" welcome page appears when user has no StackScripts.
*/
it('display the correct welcom message in landing page', () => {
it('displays the correct welcome message in landing page', () => {
mockGetStackScripts([]).as('getStackScripts');
cy.visitWithLogin('/stackscripts/account');
cy.wait('@getStackScripts');
Expand All @@ -29,7 +29,7 @@ describe('stackscripts', () => {
* - Displays Account StackScripts in the landing page.
* - Confirms that all the StackScripts are shown as expected.
*/
it('display Account StackScripts in landing page', () => {
it('displays Account StackScripts in landing page', () => {
const stackScripts = stackScriptFactory.buildList(2);
mockGetStackScripts(stackScripts).as('getStackScripts');
cy.visitWithLogin('/stackscripts/account');
Expand All @@ -54,7 +54,7 @@ describe('stackscripts', () => {
* - Displays Community StackScripts in the landing page.
* - Confirms that Community page is not empty.
*/
it('display Community StackScripts in landing page', () => {
it('displays Community StackScripts in landing page', () => {
cy.visitWithLogin('/stackscripts/community');

cy.get('[data-qa-stackscript-empty-msg="true"]').should('not.exist');
Expand Down
Loading

0 comments on commit 2b47c51

Please sign in to comment.