001/*
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.    
018 */
019package org.apache.wiki.its;
020
021import com.codeborne.selenide.junit5.ScreenShooterExtension;
022import org.apache.wiki.pages.Page;
023import org.apache.wiki.pages.haddock.ViewWikiPage;
024import org.junit.jupiter.api.Assertions;
025import org.junit.jupiter.api.Test;
026import org.junit.jupiter.api.extension.ExtendWith;
027
028import java.io.File;
029
030import static com.codeborne.selenide.Condition.exist;
031import static com.codeborne.selenide.Condition.not;
032
033
034/**
035 * Anonymous view related tests for Apache JSPWiki
036 */
037@ExtendWith( ScreenShooterExtension.class )
038public class AnonymousViewIT {
039    
040    @Test
041    void anonymousView() {
042        final ViewWikiPage main = ViewWikiPage.open( "Main" );
043        Assertions.assertEquals( "JSPWiki: Main", main.title() );
044        Assertions.assertEquals( "Main", main.wikiTitle() );
045        
046        Assertions.assertTrue( main.wikiPageContent().contains( "You have successfully installed" ) );
047        final ViewWikiPage about = main.navigateTo( "JSPWiki" );
048        Assertions.assertTrue( about.wikiPageContent().contains( "This Wiki is done using" ) );
049    }
050    
051    @Test
052    void anonymousViewImage() throws Exception {
053        final File file = Page.download( Page.baseUrl() + "/images/jspwiki_logo_s.png" );
054        Assertions.assertTrue( file.exists() );
055    }
056    
057    @Test
058    void anonymousReaderView() {
059        final ViewWikiPage main = ViewWikiPage.open( "Main" );
060        Assertions.assertEquals( "JSPWiki: Main", main.title() );
061        Assertions.assertEquals( "Main", main.wikiTitle() );
062        main.sidebar().should( exist );
063        
064        main.hoverMoreArea()
065            .clickOnShowReaderView()
066            .sidebar().should( not( exist ) );
067    }
068
069}