|
| 1 | +var ploneModule; |
| 2 | + |
| 3 | +angular.module('e2e-mocks', ['ngMockE2E']).run(function($httpBackend) { |
| 4 | + |
| 5 | + var site_structure = [ |
| 6 | + { |
| 7 | + id: 'front-page', |
| 8 | + title: 'Welcome to Plone', |
| 9 | + description: 'Congratulations! You have successfully installed Plone.', |
| 10 | + text: '<p>Front-page content</p>', |
| 11 | + path: 'front-page', |
| 12 | + portal_type: 'document', |
| 13 | + children: [] |
| 14 | + }, |
| 15 | + { |
| 16 | + id: 'news', |
| 17 | + title: 'News', |
| 18 | + description: 'Site News', |
| 19 | + text: '<p>Site news content</p>', |
| 20 | + path: 'news', |
| 21 | + portal_type: 'folder', |
| 22 | + children: [] |
| 23 | + }, |
| 24 | + { |
| 25 | + id: 'events', |
| 26 | + title: 'Events', |
| 27 | + description: 'Site Events', |
| 28 | + text: '<p>Site events content</p>', |
| 29 | + path: 'events', |
| 30 | + portal_type: 'folder', |
| 31 | + children: [] |
| 32 | + }, |
| 33 | + { |
| 34 | + id: 'Members', |
| 35 | + title: 'Members', |
| 36 | + description: 'Site Members', |
| 37 | + text: '<p>Site Members content</p>', |
| 38 | + path: 'Members', |
| 39 | + portal_type: 'folder', |
| 40 | + children: [] |
| 41 | + } |
| 42 | + ]; |
| 43 | + |
| 44 | + |
| 45 | + // -- TOP NAVIGATION ------------------------------------------------------- |
| 46 | + var top_navigation = [ |
| 47 | + { |
| 48 | + id: 'news', |
| 49 | + title: 'News', |
| 50 | + description: 'News', |
| 51 | + path: '/news' |
| 52 | + }, |
| 53 | + { |
| 54 | + id: 'events', |
| 55 | + title: 'Events', |
| 56 | + description: 'Events', |
| 57 | + path: '/events' |
| 58 | + } |
| 59 | + ]; |
| 60 | + var re = new RegExp('\\+\\+api\\+\\+v1/top_navigation'); |
| 61 | + $httpBackend.whenGET(re).respond(top_navigation); |
| 62 | + |
| 63 | + |
| 64 | + // --- PORTLET NAVIGATION -------------------------------------------------- |
| 65 | + var portlet_navigation_re = new RegExp('\\+\\+api\\+\\+v1/portlet_navigation'); |
| 66 | + $httpBackend.whenGET(portlet_navigation_re).respond(site_structure); |
| 67 | + |
| 68 | + |
| 69 | + // --- TRAVERSAL ----------------------------------------------------------- |
| 70 | + angular.forEach(site_structure, function(value, key) { |
| 71 | + var traversal = { |
| 72 | + 'route': value.path, |
| 73 | + 'id': value.id, |
| 74 | + 'title': value.title, |
| 75 | + 'description': value.description, |
| 76 | + 'text': '<p>Lorem Ipsum</p>' |
| 77 | + }; |
| 78 | + var traversal_re = new RegExp('\\+\\+api\\+\\+v1/traversal\\?path=' + value.path); |
| 79 | + $httpBackend.whenGET(traversal_re).respond(traversal); |
| 80 | + |
| 81 | + }); |
| 82 | + |
| 83 | + |
| 84 | + // --- PASS THROUGH TEMPLATES ---------------------------------------------- |
| 85 | + var templates_re = new RegExp('.*.tpl.html$'); |
| 86 | + $httpBackend.whenGET(templates_re).passThrough(); |
| 87 | + |
| 88 | +}); |
| 89 | + |
| 90 | +ploneModule.requires.push('e2e-mocks'); |
| 91 | + |
0 commit comments