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