|
10 | 10 | from plone.testing.zope import Browser
|
11 | 11 | from Products.CMFPlone.resources import add_bundle_on_request
|
12 | 12 | from Products.CMFPlone.resources import remove_bundle_on_request
|
| 13 | +from Products.CMFPlone.resources.browser.resource import _RESOURCE_REGISTRY_MTIME |
13 | 14 | from Products.CMFPlone.resources.browser.resource import ScriptsView
|
14 | 15 | from Products.CMFPlone.resources.browser.resource import StylesView
|
15 | 16 | from Products.CMFPlone.tests import PloneTestCase
|
@@ -396,7 +397,6 @@ def test_styles_on_portal_type(self):
|
396 | 397 | self.assertIn("http://test4.foo/test.css", results)
|
397 | 398 | self.assertIn("http://test3.foo/test.css", results)
|
398 | 399 |
|
399 |
| - |
400 | 400 | def test_scripts_authenticated(self):
|
401 | 401 | scripts = ScriptsView(self.layer["portal"], self.layer["request"], None)
|
402 | 402 | scripts.update()
|
@@ -455,6 +455,7 @@ def test_scripts_switching_roles(self):
|
455 | 455 | class TestRRControlPanel(PloneTestCase.PloneTestCase):
|
456 | 456 | def setUp(self):
|
457 | 457 | self.portal = self.layer["portal"]
|
| 458 | + self.registry = getUtility(IRegistry) |
458 | 459 | self.app = self.layer["app"]
|
459 | 460 | self.browser = Browser(self.app)
|
460 | 461 | self.browser.handleErrors = False
|
@@ -504,3 +505,43 @@ def test_update_resource(self):
|
504 | 505 | '<h2 class="accordion-header" id="heading-new-resource-name">',
|
505 | 506 | self.browser.contents,
|
506 | 507 | )
|
| 508 | + |
| 509 | + def test_update_registry_mtime(self): |
| 510 | + mtime = str(getattr(self.registry, _RESOURCE_REGISTRY_MTIME, "")) |
| 511 | + |
| 512 | + add_form = self.browser.getForm(index=5) |
| 513 | + add_form.getControl(name="name").value = "my-resource" |
| 514 | + add_form.getControl(name="jscompilation").value = "++resource++my.resource.js" |
| 515 | + add_form.getControl(name="enabled").value = "checked" |
| 516 | + add_form.getControl("add").click() |
| 517 | + |
| 518 | + # check for updates ScriptsViewlet |
| 519 | + self.assertIn( |
| 520 | + '++resource++my.resource.js"></script>', |
| 521 | + self.browser.contents, |
| 522 | + ) |
| 523 | + |
| 524 | + # new modification time has to be larger |
| 525 | + self.assertTrue( |
| 526 | + str(getattr(self.registry, _RESOURCE_REGISTRY_MTIME, "")) |
| 527 | + > mtime |
| 528 | + ) |
| 529 | + |
| 530 | + mtime = str(getattr(self.registry, _RESOURCE_REGISTRY_MTIME, "")) |
| 531 | + |
| 532 | + # new resource form has index=3 |
| 533 | + my_resource_form = self.browser.getForm(index=3) |
| 534 | + my_resource_form.getControl(name="enabled").value = "" |
| 535 | + my_resource_form.getControl("update").click() |
| 536 | + |
| 537 | + # check for updated ScriptsViewlet with disabled resource |
| 538 | + self.assertNotIn( |
| 539 | + '++resource++my.resource.js"></script>', |
| 540 | + self.browser.contents, |
| 541 | + ) |
| 542 | + |
| 543 | + # new modification time has to be larger |
| 544 | + self.assertTrue( |
| 545 | + str(getattr(self.registry, _RESOURCE_REGISTRY_MTIME, "")) |
| 546 | + > mtime |
| 547 | + ) |
0 commit comments