|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var helpers = require('djangocms-casper-helpers'); |
| 4 | +var globals = helpers.settings; |
| 5 | +var casperjs = require('casper'); |
| 6 | +var xPath = casperjs.selectXPath; |
| 7 | +var cms = helpers(casperjs); |
| 8 | + |
| 9 | +casper.test.setUp(function(done) { |
| 10 | + casper |
| 11 | + .start() |
| 12 | + .then(cms.login()) |
| 13 | + .then(cms.addPage({ title: 'Home page' })) |
| 14 | + .then( |
| 15 | + cms.addPlugin({ |
| 16 | + type: 'TextPlugin', |
| 17 | + content: { |
| 18 | + id_body: 'Random text' |
| 19 | + } |
| 20 | + }) |
| 21 | + ) |
| 22 | + .then(cms.publishPage({ page: 'Home page', language: 'en' })) |
| 23 | + .run(done); |
| 24 | +}); |
| 25 | + |
| 26 | +casper.test.tearDown(function(done) { |
| 27 | + casper.start().then(cms.login()).then(cms.removePage()).then(cms.logout()).run(done); |
| 28 | +}); |
| 29 | + |
| 30 | +casper.test.begin('Non admin user cannot open structureboard', function(test) { |
| 31 | + casper |
| 32 | + .start() |
| 33 | + .then(cms.logout()) |
| 34 | + .then( |
| 35 | + cms.login({ |
| 36 | + username: 'normal', |
| 37 | + password: 'normal' |
| 38 | + }) |
| 39 | + ) |
| 40 | + .thenOpen(globals.editUrl) |
| 41 | + .waitForSelector('.cms-ready', function() { |
| 42 | + this.mouse.doubleclick( |
| 43 | + // pick a div with class cms-plugin that has a p that has text "Random text" |
| 44 | + xPath('//*[contains(@class, "cms-plugin")][contains(text(), "Random text")]') |
| 45 | + ); |
| 46 | + }) |
| 47 | + .waitUntilVisible('.cms-modal-open') |
| 48 | + .withFrame(0, function() { |
| 49 | + casper.waitUntilVisible('body', function() { |
| 50 | + test.assertSelectorHasText('body', 'You do not have permission to edit this plugin'); |
| 51 | + }); |
| 52 | + }) |
| 53 | + .then(function() { |
| 54 | + this.click('.cms-modal-open .cms-modal-item-buttons:last-child > a'); |
| 55 | + }) |
| 56 | + .waitWhileVisible('.cms-modal-iframe') |
| 57 | + .then(function() { |
| 58 | + // normally nothing happens on click, but we are making sure there are no regressions |
| 59 | + this.mouse.click( |
| 60 | + // pick a div with class cms-plugin that has a p that has text "Random text" |
| 61 | + xPath('//*[contains(@class, "cms-plugin")][contains(text(), "Random text")]') |
| 62 | + ); |
| 63 | + }) |
| 64 | + .then(function() { |
| 65 | + test.assertSelectorDoesntHaveText('.cms-structure', 'Placeholder_Content_1'); |
| 66 | + }) |
| 67 | + .then(function() { |
| 68 | + this.evaluate(function() { |
| 69 | + CMS.$(document).data('expandmode', true); |
| 70 | + }); |
| 71 | + // normally nothing happens on click, but we are making sure there are no regressions |
| 72 | + this.mouse.click( |
| 73 | + // pick a div with class cms-plugin that has a p that has text "Random text" |
| 74 | + xPath('//*[contains(@class, "cms-plugin")][contains(text(), "Random text")]') |
| 75 | + ); |
| 76 | + }) |
| 77 | + .then(function() { |
| 78 | + test.assertSelectorDoesntHaveText('.cms-structure', 'Placeholder_Content_1'); |
| 79 | + }) |
| 80 | + .wait(3000, function() { |
| 81 | + test.assertSelectorDoesntHaveText('.cms-structure', 'Placeholder_Content_1'); |
| 82 | + }) |
| 83 | + .then(cms.logout()) |
| 84 | + .run(function() { |
| 85 | + test.done(); |
| 86 | + }); |
| 87 | +}); |
0 commit comments