Adds tests for buttons hooks

Tests folowing:
 * `register_page_listing_buttons`
 * `register_page_listing_more_buttons`
 * Custom hook produced by non-default `ButtonWithDropdownFromHook` instance

organised indicator color state variables into main variables.scss file
pull/2345/head
Mikalai Radchuk 2016-03-08 15:50:39 +03:00 zatwierdzone przez Matt Westcott
rodzic 29f92d25d2
commit e2327675e1
3 zmienionych plików z 92 dodań i 4 usunięć

Wyświetl plik

@ -65,6 +65,12 @@ $color-link-hover: $color-teal-dark;
$color-text-base: $color-grey-2;
$color-text-input: $color-grey-1;
// Color states
$color-state-live: #59b524;
$color-state-draft: #808080;
$color-state-absent: #ff8f11;
$color-state-live-draft: #43b1b0;
// Fonts
$font-sans: Open Sans, Arial, sans-serif;
$font-serif: Roboto Slab, Georgia, serif;
@ -72,3 +78,6 @@ $font-serif: Roboto Slab, Georgia, serif;
// misc sizing
$thumbnail-width: 130px;
$menu-width: 180px;

Wyświetl plik

@ -24,10 +24,6 @@ $c-indicator-margin: .25rem;
// States
// =============================================================================
$color-state-live: #59b524;
$color-state-draft: #808080;
$color-state-absent: #ff8f11;
$color-state-live-draft: #43b1b0;
.is-absent .c-indicator {
background: $color-state-absent;

Wyświetl plik

@ -0,0 +1,83 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailadmin import widgets as wagtailadmin_widgets
from wagtail.wagtailcore import hooks
from wagtail.wagtailcore.models import Page
class TestButtonsHooks(TestCase, WagtailTestUtils):
def setUp(self):
self.root_page = Page.objects.get(id=2)
self.login()
def test_register_page_listing_buttons(self):
@hooks.register('register_page_listing_buttons')
def page_listing_buttons(page, page_perms, is_parent=False):
yield wagtailadmin_widgets.PageListingButton(
'Another useless page listing button',
'/custom-url',
priority=10
)
response = self.client.get(
reverse('wagtailadmin_explore', args=(self.root_page.id, ))
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailadmin/pages/listing/_button_with_dropdown.html')
self.assertTemplateUsed(response, 'wagtailadmin/pages/listing/_buttons.html')
self.assertContains(response, 'Another useless page listing button')
def test_register_page_listing_more_buttons(self):
@hooks.register('register_page_listing_more_buttons')
def page_listing_more_buttons(page, page_perms, is_parent=False):
yield wagtailadmin_widgets.Button(
'Another useless button in default "More" dropdown',
'/custom-url',
priority=10
)
response = self.client.get(
reverse('wagtailadmin_explore', args=(self.root_page.id, ))
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailadmin/pages/listing/_button_with_dropdown.html')
self.assertTemplateUsed(response, 'wagtailadmin/pages/listing/_buttons.html')
self.assertContains(response, 'Another useless button in default "More" dropdown')
def test_custom_button_with_dropdown(self):
@hooks.register('register_page_listing_buttons')
def page_custom_listing_buttons(page, page_perms, is_parent=False):
yield wagtailadmin_widgets.ButtonWithDropdownFromHook(
'One more more button',
hook_name='register_page_listing_one_more_more_buttons',
page=page,
page_perms=page_perms,
is_parent=is_parent,
attrs={'target': '_blank'},
priority=50
)
@hooks.register('register_page_listing_one_more_more_buttons')
def page_custom_listing_more_buttons(page, page_perms, is_parent=False):
yield wagtailadmin_widgets.Button(
'Another useless dropdown button in "One more more button" dropdown',
'/custom-url',
priority=10
)
response = self.client.get(
reverse('wagtailadmin_explore', args=(self.root_page.id, ))
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailadmin/pages/listing/_button_with_dropdown.html')
self.assertTemplateUsed(response, 'wagtailadmin/pages/listing/_buttons.html')
self.assertContains(response, 'One more more button')
self.assertContains(response, 'Another useless dropdown button in "One more more button" dropdown')