|
1 | 1 | /// <reference types="Cypress" />
|
2 | 2 | context('Stylesheets', () => {
|
3 | 3 |
|
| 4 | + const name = "TestStylesheet"; |
| 5 | + const fileName = name + ".css"; |
| 6 | + |
4 | 7 | beforeEach(() => {
|
5 | 8 | cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
|
| 9 | + |
| 10 | + cy.umbracoEnsureStylesheetNameNotExists(fileName); |
6 | 11 | });
|
7 | 12 |
|
8 |
| - it('Create new style sheet file', () => { |
9 |
| - const name = "TestStylesheet"; |
10 |
| - const fileName = name + ".css"; |
| 13 | + afterEach(() => { |
| 14 | + // Clean up, this ensures that even if tests break we clean up |
| 15 | + cy.umbracoEnsureStylesheetNameNotExists(fileName); |
| 16 | + }); |
11 | 17 |
|
12 |
| - cy.umbracoEnsureStylesheetNameNotExists(fileName); |
| 18 | + it('Create new style sheet file', () => { |
13 | 19 |
|
14 | 20 | cy.umbracoSection('settings');
|
15 | 21 | cy.get('li .umb-tree-root:contains("Settings")').should("be.visible");
|
16 | 22 |
|
17 | 23 | cy.umbracoTreeItem("settings", ["Stylesheets"]).rightclick();
|
18 | 24 |
|
19 | 25 | cy.umbracoContextMenuAction("action-create").click();
|
20 |
| - cy.get('.menu-label').first().click(); // TODO: Fucked we cant use something like cy.umbracoContextMenuAction("action-mediaType").click(); |
21 |
| - //We have to wait here till everything is loaded, or worker will throw error |
| 26 | + cy.get('.menu-label').first().click(); // TODO: Would be better to use something like cy.umbracoContextMenuAction("action-mediaType").click(); |
| 27 | + // We have to wait here till everything is loaded, or worker will throw error |
22 | 28 | cy.intercept('/umbraco/lib/ace-builds/src-min-noconflict/worker-css.js').as('aceWorker');
|
23 | 29 | cy.wait('@aceWorker');
|
24 |
| - //Type name |
| 30 | + |
| 31 | + // Type name |
25 | 32 | cy.umbracoEditorHeaderName(name);
|
26 | 33 |
|
27 |
| - //Save |
| 34 | + // Save |
28 | 35 | cy.get('.btn-success').click();
|
29 | 36 |
|
30 |
| - //Assert |
| 37 | + // Assert |
31 | 38 | cy.umbracoSuccessNotification().should('be.visible');
|
32 | 39 |
|
33 |
| - //Clean up |
34 |
| - cy.umbracoEnsureStylesheetNameNotExists(fileName); |
35 | 40 | });
|
36 | 41 |
|
| 42 | + it('Deletes a stylesheet', () => { |
| 43 | + |
| 44 | + var stylesheetData = { |
| 45 | + "virtualPath": "/css/", |
| 46 | + "path": null, |
| 47 | + "name": name, |
| 48 | + "content": "", |
| 49 | + "fileType": "stylesheets", |
| 50 | + "snippet": null, |
| 51 | + "id": "0", |
| 52 | + "notifications": [] |
| 53 | + } |
| 54 | + |
| 55 | + let url = '/umbraco/backoffice/umbracoapi/codefile/PostSave' |
| 56 | + cy.umbracoApiRequest(url, 'POST', stylesheetData); |
| 57 | + |
| 58 | + // Navigate to Settings section |
| 59 | + cy.umbracoSection('settings'); |
| 60 | + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); |
| 61 | + |
| 62 | + // Open stylesheet tree |
| 63 | + cy.get('[data-element="tree-item-stylesheets"] > .umb-tree-item__inner > .umb-tree-item__arrow').click(); |
| 64 | + |
| 65 | + // Delete stylesheet |
| 66 | + cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(name).rightclick(); |
| 67 | + cy.get('.umb-action-link').click(); |
| 68 | + cy.get('[ng-if="showConfirm"]').click(); |
| 69 | + |
| 70 | + // Assert |
| 71 | + cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(name).should('not.exist'); |
| 72 | + |
| 73 | + }); |
37 | 74 | });
|
0 commit comments