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 static com.codeborne.selenide.Condition.exist;
022import static com.codeborne.selenide.Condition.not;
023
024import java.io.File;
025
026import org.apache.wiki.pages.Page;
027import org.apache.wiki.pages.haddock.ReadWikiPage;
028import org.junit.jupiter.api.Assertions;
029import org.junit.jupiter.api.Test;
030import org.junit.jupiter.api.extension.ExtendWith;
031
032import com.codeborne.selenide.junit5.ScreenShooterExtension;
033
034
035/**
036 * Anonymous view related tests for Apache JSPWiki
037 */
038@ExtendWith( ScreenShooterExtension.class )
039public class AnonymousViewIT {
040    
041    @Test
042    void anonymousView() throws Exception {
043        ReadWikiPage main = Page.withUrl( Page.baseUrl() + "/Wiki.jsp?page=Main" ).openAs( new ReadWikiPage() );
044        Assertions.assertEquals( "JSPWiki: Main", main.title() );
045        Assertions.assertEquals( "Main", main.wikiTitle() );
046        
047        Assertions.assertTrue( main.wikiPageContent().contains( "You have successfully installed" ) );
048        ReadWikiPage about = main.navigateTo( "JSPWiki" );
049        Assertions.assertTrue( about.wikiPageContent().contains( "This Wiki is done using" ) );
050    }
051    
052    @Test
053    void anonymousViewImage() throws Exception {
054        File file = Page.download( Page.baseUrl() + "/images/jspwiki_logo_s.png" );
055        Assertions.assertTrue( file.exists() );
056    }
057    
058    @Test
059    void anonymousReaderView() {
060        ReadWikiPage main = Page.withUrl( Page.baseUrl() + "/Wiki.jsp?page=Main" ).openAs( new ReadWikiPage() );
061        Assertions.assertEquals( "JSPWiki: Main", main.title() );
062        Assertions.assertEquals( "Main", main.wikiTitle() );
063        main.sidebar().should( exist );
064        
065        main.hoverMoreArea().clickOnShowReaderView();
066        main.sidebar().should( not( exist ) );
067    }
068
069}