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;
030import org.junit.jupiter.api.condition.DisabledOnOs;
031import org.junit.jupiter.api.condition.OS;
032
033
034/**
035 * Anonymous view related tests for Apache JSPWiki
036 */
037public class AnonymousViewIT extends WithIntegrationTestSetup {
038    
039    @Test
040    @DisabledOnOs(OS.WINDOWS)
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    @DisabledOnOs(OS.WINDOWS)
053    void anonymousViewImage() throws Exception {
054        final File file = Page.download( Page.baseUrl() + "/images/jspwiki_logo_s.png" );
055        Assertions.assertTrue( file.exists() );
056    }
057    
058    @Test
059    @DisabledOnOs(OS.WINDOWS)
060    void anonymousReaderView() {
061        final ViewWikiPage main = ViewWikiPage.open( "Main" );
062        Assertions.assertEquals( "JSPWiki: Main", main.title() );
063        Assertions.assertEquals( "Main", main.wikiTitle() );
064        main.sidebar().should( exist );
065        
066        main.hoverMoreArea()
067            .clickOnShowReaderView()
068            .sidebar().should( not( exist ) );
069    }
070
071}