Skip to content

Commit

Permalink
v9: Create new 'delete stylesheet' cypress test (umbraco#11528)
Browse files Browse the repository at this point in the history
* Create new cypress test- delete stylesheet

* Cleanup

Co-authored-by: Elitsa Marinovska <[email protected]>
Co-authored-by: Nikolaj Geisle <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2021
1 parent d4682a9 commit 1359eb8
Showing 1 changed file with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,74 @@
/// <reference types="Cypress" />
context('Stylesheets', () => {

const name = "TestStylesheet";
const fileName = name + ".css";

beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));

cy.umbracoEnsureStylesheetNameNotExists(fileName);
});

it('Create new style sheet file', () => {
const name = "TestStylesheet";
const fileName = name + ".css";
afterEach(() => {
// Clean up, this ensures that even if tests break we clean up
cy.umbracoEnsureStylesheetNameNotExists(fileName);
});

cy.umbracoEnsureStylesheetNameNotExists(fileName);
it('Create new style sheet file', () => {

cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");

cy.umbracoTreeItem("settings", ["Stylesheets"]).rightclick();

cy.umbracoContextMenuAction("action-create").click();
cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click();
//We have to wait here till everything is loaded, or worker will throw error
cy.get('.menu-label').first().click(); // TODO: Would be better to use something like cy.umbracoContextMenuAction("action-mediaType").click();
// We have to wait here till everything is loaded, or worker will throw error
cy.intercept('/umbraco/lib/ace-builds/src-min-noconflict/worker-css.js').as('aceWorker');
cy.wait('@aceWorker');
//Type name

// Type name
cy.umbracoEditorHeaderName(name);

//Save
// Save
cy.get('.btn-success').click();

//Assert
// Assert
cy.umbracoSuccessNotification().should('be.visible');

//Clean up
cy.umbracoEnsureStylesheetNameNotExists(fileName);
});

it('Deletes a stylesheet', () => {

var stylesheetData = {
"virtualPath": "/css/",
"path": null,
"name": name,
"content": "",
"fileType": "stylesheets",
"snippet": null,
"id": "0",
"notifications": []
}

let url = '/umbraco/backoffice/umbracoapi/codefile/PostSave'
cy.umbracoApiRequest(url, 'POST', stylesheetData);

// Navigate to Settings section
cy.umbracoSection('settings');
cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");

// Open stylesheet tree
cy.get('[data-element="tree-item-stylesheets"] > .umb-tree-item__inner > .umb-tree-item__arrow').click();

// Delete stylesheet
cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(name).rightclick();
cy.get('.umb-action-link').click();
cy.get('[ng-if="showConfirm"]').click();

// Assert
cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(name).should('not.exist');

});
});

0 comments on commit 1359eb8

Please sign in to comment.