Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [M3-6505] - Add StackScript Update/Delete E2E Tests #9315

Merged
merged 2 commits into from
Jul 7, 2023
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
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,102 @@
import { authenticate } from 'support/api/authentication';
import { stackScriptFactory } from 'src/factories';
import {
mockDeleteStackScript,
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,
});
mockGetStackScripts(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');
mockGetStackScripts([stackScripts[1]]).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