Merge "Minor CSS cleanup for Vector and Monobook skins"
[mediawiki.git] / tests / selenium / suites / AddContentToNewPageTestCase.php
blob2803ff2a4203e793aaf773e869622cdcc3369861
1 <?php
2 /**
3 * Selenium server manager
5 * @file
6 * @ingroup Testing
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 class AddContentToNewPageTestCase extends SeleniumTestCase {
27 // Add bold text and verify output
28 public function testAddBoldText() {
29 $this->getExistingPage();
30 $this->clickEditLink();
31 $this->loadWikiEditor();
32 $this->clearWikiEditor();
33 $this->click( "//*[@id='mw-editbutton-bold']" );
34 $this->clickShowPreviewBtn();
35 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
37 // Verify bold text displayed on mediawiki preview
38 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/b" ) );
39 $this->assertTrue( $this->isTextPresent( "Bold text" ) );
42 // Add italic text and verify output
43 public function testAddItalicText() {
44 $this->getExistingPage();
45 $this->clickEditLink();
46 $this->loadWikiEditor();
47 $this->clearWikiEditor();
48 $this->click( "//*[@id='mw-editbutton-italic']" );
49 $this->clickShowPreviewBtn();
50 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
52 // Verify italic text displayed on mediawiki preview
53 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/i" ) );
54 $this->assertTrue( $this->isTextPresent( "Italic text" ) );
57 // Add internal link for a new page and verify output in the preview
58 public function testAddInternalLinkNewPage() {
59 $this->getExistingPage();
60 $this->clickEditLink();
61 $this->loadWikiEditor();
62 $this->clearWikiEditor();
63 $this->click( "//*[@id='mw-editbutton-link']" );
64 $this->clickShowPreviewBtn();
65 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
67 // Verify internal link displayed on mediawiki preview
68 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
69 $correct = strstr( $source, "Link title" );
70 $this->assertEquals( $correct, true );
72 $this->click( SeleniumTestConstants::LINK_START . "Link title" );
73 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
75 // Verify internal link open as a new page - editing mode
76 $source = $this->getText( "firstHeading" );
77 $correct = strstr( $source, "Editing Link title" );
78 $this->assertEquals( $correct, true );
81 // Add external link and verify output in the preview
82 public function testAddExternalLink() {
83 $this->getExistingPage();
84 $this->clickEditLink();
85 $this->loadWikiEditor();
86 $this->clearWikiEditor();
87 $this->click( "//*[@id='mw-editbutton-extlink']" );
88 $this->type( SeleniumTestConstants::TEXT_EDITOR, "[http://www.google.com Google]" );
89 $this->clickShowPreviewBtn();
90 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
92 // Verify external links displayed on mediawiki preview
93 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
94 $correct = strstr( $source, "Google" );
95 $this->assertEquals( $correct, true );
97 $this->click( SeleniumTestConstants::LINK_START . "Google" );
98 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
100 // Verify external link opens
101 $source = $this->getTitle();
102 $correct = strstr( $source, "Google" );
103 $this->assertEquals( $correct, true );
106 // Add level 2 headline and verify output in the preview
107 public function testAddLevel2HeadLine() {
108 $blnElementPresent = false;
109 $blnTextPresent = false;
110 $this->getExistingPage();
111 $this->clickEditLink();
112 $this->loadWikiEditor();
113 $this->clearWikiEditor();
114 $this->click( "mw-editbutton-headline" );
115 $this->clickShowPreviewBtn();
116 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
117 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/h2" ) );
119 // Verify level 2 headline displayed on mediawiki preview
120 $source = $this->getText( "//*[@id='Headline_text']" );
121 $correct = strstr( $source, "Headline text" );
122 $this->assertEquals( $correct, true );
125 // Add text with ignore wiki format and verify output the preview
126 public function testAddNoWikiFormat() {
127 $this->getExistingPage();
128 $this->clickEditLink();
129 $this->loadWikiEditor();
130 $this->clearWikiEditor();
131 $this->click( "//*[@id='mw-editbutton-nowiki']" );
132 $this->clickShowPreviewBtn();
133 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
135 // Verify ignore wiki format text displayed on mediawiki preview
136 $source = $this->getText( "//div[@id='wikiPreview']/p" );
137 $correct = strstr( $source, "Insert non-formatted text here" );
138 $this->assertEquals( $correct, true );
141 // Add signature and verify output in the preview
142 public function testAddUserSignature() {
143 $this->getExistingPage();
144 $this->clickEditLink();
145 $this->loadWikiEditor();
146 $this->clearWikiEditor();
147 $this->click( "mw-editbutton-signature" );
148 $this->clickShowPreviewBtn();
149 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
151 // Verify signature displayed on mediawiki preview
152 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
153 $username = $this->getText( "//*[@id='pt-userpage']/a" );
154 $correct = strstr( $source, $username );
155 $this->assertEquals( $correct, true );
158 // Add horizontal line and verify output in the preview
159 public function testHorizontalLine() {
160 $this->getExistingPage();
161 $this->clickEditLink();
162 $this->loadWikiEditor();
163 $this->clearWikiEditor();
164 $this->click( "mw-editbutton-hr" );
166 $this->clickShowPreviewBtn();
167 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
169 // Verify horizontal line displayed on mediawiki preview
170 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" ) );
171 $this->deletePage( "new" );