[1219] | 1 | Quills browser tests |
---|
| 2 | ==================== |
---|
| 3 | |
---|
| 4 | N.B. Much of the generic browser testing has been factored out into |
---|
| 5 | quills/app/tests/browser.rst. *Only* browser tests that are *specific* to the |
---|
| 6 | Products.QuillsEnabled implementation (as opposed to Products.Quills) should be |
---|
| 7 | in this file. |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | Here we click ourselves through a Quills instance and check that everything is |
---|
| 11 | in order. First some boilerplate to get our browser up and running: |
---|
| 12 | |
---|
| 13 | >>> self.setRoles(("Contributor",)) |
---|
| 14 | >>> browser = self.getBrowser(logged_in=True) |
---|
| 15 | >>> browser.handleErrors = False |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | adding content |
---|
| 19 | ************** |
---|
| 20 | |
---|
| 21 | >>> browser.open('http://nohost/plone/weblog/') |
---|
| 22 | >>> browser.getLink(url='http://nohost/plone/weblog/createObject?type_name=Document').click() |
---|
| 23 | >>> browser.getControl('Title').value = "New entry" |
---|
| 24 | >>> browser.getControl('Description').value = "A new entry" |
---|
| 25 | >>> browser.getControl('Text').value = "This is a new entry." |
---|
| 26 | >>> browser.getControl(name='allowDiscussion:boolean').value = True |
---|
| 27 | |
---|
| 28 | We'd like to set the subjects, but they are on a different 'tab' for |
---|
| 29 | standard 'Document'/'Page' types in plone, so we skip it for now. |
---|
| 30 | |
---|
| 31 | #>>> browser.getControl(name='subject_existing_keywords:list').value = ["fishslapping",] |
---|
| 32 | >>> browser.getControl('Save').click() |
---|
| 33 | |
---|
| 34 | Having filled out the form and saved it we should now be viewing our newly baked |
---|
| 35 | entry: |
---|
| 36 | |
---|
| 37 | >>> browser.url |
---|
| 38 | 'http://nohost/plone/weblog/new-entry' |
---|
| 39 | |
---|
| 40 | However, since we only have the Contributor role, we are not allowed to publish |
---|
| 41 | the item: |
---|
| 42 | |
---|
| 43 | >>> browser.getLink('Publish') |
---|
| 44 | Traceback (most recent call last): |
---|
| 45 | ... |
---|
| 46 | LinkNotFoundError |
---|
| 47 | |
---|
| 48 | But we can submit the entry for publication: |
---|
| 49 | |
---|
| 50 | >>> browser.getLink('Submit').click() |
---|
| 51 | |
---|
| 52 | If we additionally grant the `Reviewer` role we can publish the new entry: |
---|
| 53 | |
---|
| 54 | >>> self.setRoles(("Contributor", "Reviewer")) |
---|
| 55 | >>> browser.reload() |
---|
| 56 | >>> browser.getLink('Publish').click() |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | comments |
---|
| 60 | ******** |
---|
| 61 | |
---|
| 62 | By default we even need the `Manager` role to add comments: |
---|
| 63 | |
---|
| 64 | >>> self.setRoles(("Contributor", "Reviewer", "Manager")) |
---|
| 65 | |
---|
| 66 | We also need to enable comments for the 'Document' portal type: |
---|
| 67 | |
---|
| 68 | >>> dtype = self.portal.portal_types['Document'] |
---|
| 69 | >>> dtype.manage_changeProperties(allow_discussion=1) |
---|
| 70 | >>> entry_content = self.weblog.context['new-entry'] |
---|
| 71 | >>> entry_content.allowDiscussion = 1 |
---|
| 72 | >>> entry_content.reindexObject() |
---|
| 73 | |
---|
| 74 | Now we open the page in a browser: |
---|
| 75 | |
---|
| 76 | >>> browser.open('http://nohost/plone/weblog/new-entry') |
---|
| 77 | |
---|
| 78 | The non-archive view has a button to add a comment: |
---|
| 79 | |
---|
| 80 | #XXX: quintagroup.quills.extras fix (because of using quintagorup.plonecomments) |
---|
| 81 | >>> browser.getControl('Subject') |
---|
| 82 | <Control name='subject' type='text'> |
---|
| 83 | |
---|
| 84 | When viewing an entry via its archive url, we still should be able to add a |
---|
| 85 | comment, as well: |
---|
| 86 | |
---|
| 87 | >>> entry = self.weblog.getEntry('new-entry') |
---|
| 88 | >>> date = entry.getPublicationDate() |
---|
| 89 | >>> year = str(date.year()) |
---|
| 90 | >>> month = str(date.month()).zfill(2) |
---|
| 91 | >>> day = str(date.day()).zfill(2) |
---|
| 92 | |
---|
| 93 | >>> browser.open('http://nohost/plone/weblog/%s/%s/%s/new-entry' % (year, month, day)) |
---|
| 94 | |
---|
| 95 | #XXX: quintagroup.quills.extras fix (because of using quintagorup.plonecomments) |
---|
| 96 | >>> browser.getControl('Subject') |
---|
| 97 | <Control name='subject' type='text'> |
---|
| 98 | |
---|
| 99 | >>> browser.getControl('Subject').value = "Parrot" |
---|
| 100 | >>> browser.getControl('Comment').value = "Is dead. Is deceased." |
---|
| 101 | |
---|
| 102 | However, currently this still raises an error (eventhough the comment is |
---|
| 103 | actually created). The problem seems to be that zope.testbrowser cannot handle |
---|
| 104 | urls that have anchors (e.g. 'foo/bar#anchor') at the end. The comment machinery |
---|
| 105 | tries to redirect to such a url after the 'click', so this next call fails. See |
---|
| 106 | issue http://plone.org/products/quills/issues/105 for more details of why this |
---|
| 107 | test exists. |
---|
| 108 | |
---|
| 109 | >> browser.getControl('Save').click() |
---|