1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.blog.test.ui

File BlogPostTest.java

 

Code metrics

0
33
1
1
105
56
1
0.03
33
1
1

Classes

Class Line # Actions
BlogPostTest 41 33 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.blog.test.ui;
21   
22    import java.util.Arrays;
23    import java.util.Collections;
24   
25    import org.junit.Assert;
26    import org.junit.Test;
27    import org.xwiki.test.ui.AbstractTest;
28    import org.xwiki.test.ui.browser.IgnoreBrowser;
29    import org.xwiki.test.ui.browser.IgnoreBrowsers;
30    import org.xwiki.blog.test.po.BlogHomePage;
31    import org.xwiki.blog.test.po.BlogPostInlinePage;
32    import org.xwiki.blog.test.po.BlogPostViewPage;
33    import org.xwiki.blog.test.po.CreateBlogPostPane;
34   
35    /**
36    * Functional tests for blog posts.
37    *
38    * @version $Id: d0e3a6493d37c64a4dd8c46ad2c4df20131d2bf3 $
39    * @since 3.2M3
40    */
 
41    public class BlogPostTest extends AbstractTest
42    {
43    /**
44    * Tests how a blog post is created and then edited.
45    */
 
46  1 toggle @Test
47    @IgnoreBrowsers({
48    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
49    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
50    })
51    public void testCreateAndEditBlogPost()
52    {
53  1 getUtil().deletePage(getTestClassName(), getTestMethodName());
54  1 getUtil().deletePage("XWiki", getTestClassName() + "_" + getTestMethodName());
55    // Login as superadmin to create a new user.
56  1 getUtil().loginAsSuperAdmin();
57    // Now login as a simple user to verify normal users can create blog posts. Since the Blog PO consider that
58    // WYISWYG is enable, we need to force our user to use the WYSIWYG editor (since there's no
59    // XWiki.XWikiPreferences set that would set it in our minimal instance).
60  1 getUtil().createUserAndLogin(getTestClassName() + "_" + getTestMethodName(), "password", "editor", "Wysiwyg");
61   
62    // Create the blog post.
63  1 CreateBlogPostPane createBlogPostPane = BlogHomePage.gotoPage().getCreateBlogPostPane();
64  1 createBlogPostPane.setTitle(getTestMethodName());
65  1 BlogPostInlinePage blogPostInlinePage = createBlogPostPane.clickCreateButton();
66  1 blogPostInlinePage.waitToLoad();
67   
68  1 Assert.assertEquals(getTestMethodName(), blogPostInlinePage.getTitle());
69   
70  1 blogPostInlinePage.setTitle("Test blog title");
71  1 blogPostInlinePage.setContent("Test blog content");
72  1 blogPostInlinePage.setCategories(Collections.singletonList("Personal"));
73  1 BlogPostViewPage blogPostViewPage = blogPostInlinePage.clickSaveAndView();
74   
75    // Assert the result.
76  1 Assert.assertEquals("Test blog title", blogPostViewPage.getDocumentTitle());
77  1 Assert.assertEquals("Test blog content", blogPostViewPage.getContent());
78  1 Assert.assertEquals(Collections.singletonList("Personal"), blogPostViewPage.getCategories());
79  1 Assert.assertFalse(blogPostViewPage.isPublished());
80   
81    // Edit the blog post.
82  1 blogPostInlinePage = blogPostViewPage.clickEditBlogPostIcon();
83  1 blogPostInlinePage.waitToLoad();
84   
85  1 Assert.assertEquals("Test blog title", blogPostInlinePage.getTitle());
86  1 Assert.assertEquals("Test blog content", blogPostInlinePage.getContent());
87  1 Assert.assertEquals(Collections.singletonList("Personal"), blogPostInlinePage.getCategories());
88  1 Assert.assertFalse(blogPostInlinePage.isPublished());
89   
90    // Modify the blog post.
91  1 blogPostInlinePage.setTitle("Modified title");
92  1 blogPostInlinePage.setContent("Modified content");
93  1 blogPostInlinePage.setCategories(Arrays.asList("News", "Personal"));
94  1 blogPostInlinePage.setPublished(true);
95   
96    // Assert the result.
97  1 blogPostViewPage = blogPostInlinePage.clickSaveAndView();
98   
99  1 Assert.assertEquals("Modified title", blogPostViewPage.getDocumentTitle());
100  1 Assert.assertEquals("Modified content", blogPostViewPage.getContent());
101  1 Assert.assertEquals(Arrays.asList("News", "Personal"), blogPostViewPage.getCategories());
102  1 Assert.assertTrue(blogPostViewPage.isPublished());
103  1 Assert.assertFalse(blogPostViewPage.isHidden());
104    }
105    }