<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.atlassian.servicedesk</groupId>
        <artifactId>integration-tests-parent</artifactId>
        <version>15.14.1-QR-0023</version>
    </parent>

    <artifactId>jsm-pa11y-tests</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>atlassian-jira-pageobjects</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/test/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>

    </build>

    <properties>
        <pa11y.target.baseline.version>${project.version}</pa11y.target.baseline.version>
        <pa11y.username>admin</pa11y.username>
        <pa11y.password>admin</pa11y.password>
        <!-- conditionally setting this value or jvmArgs will not work -->
        <jacoco.agent.it.argLine></jacoco.agent.it.argLine>
    </properties>

    <profiles>
        <profile>
            <id>ci-pa11y</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.version}</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin><!-- ======== FOR DOCUMENTATION ======== see http://confluence.atlassian.com/display/DEVNET/AMPS+Plugin+for+Maven -->
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>jira-maven-plugin</artifactId>
                        <configuration>
                            <jvmArgs>${jira.jvm.args}</jvmArgs>
                            <!-- wait to false, mean AMPS will return from start-jira call and leave instance running -->
                            <wait>false</wait>
                            <!-- instead of product id -->
                            <instanceId>jira</instanceId>
                            <!-- skip the AMPS integration test step -->
                            <skipITs>true</skipITs>
                            <skipTests>true</skipTests>
                            <skipAmpsPomCheck>true</skipAmpsPomCheck>
                            <skipManifestValidation>true</skipManifestValidation>
                            <skipAllPrompts>true</skipAllPrompts>
                            <products>
                                <product>
                                    <id>jira</id>
                                    <version>${jira.version}</version>
                                    <dataVersion>${jira.version}</dataVersion>
                                </product>
                            </products>
                            <systemPropertyVariables>
                                <!-- Don't schedule any async upgrade tasks while running integration tests, as if run while testing one of them, it breaks the test -->
                                <atlassian.darkfeature.sd.no.schedule.async.upgrade.tasks.enabled>true
                                </atlassian.darkfeature.sd.no.schedule.async.upgrade.tasks.enabled>
                                <!-- Ensure that Automation runs integration tests using the PSMQ Async Engine when available -->
                                <atlassian.darkfeature.sd.automation.psmq.async.executor.enabled>true
                                </atlassian.darkfeature.sd.automation.psmq.async.executor.enabled>
                                <atlassian.dev.mode>false</atlassian.dev.mode>
                                <atlassian.mail.senddisabled>false</atlassian.mail.senddisabled>
                                <atlassian.mail.fetchdisabled>false</atlassian.mail.fetchdisabled>
                                <!-- By default, we don't like to deal with websudo, it's just an annoyance -->
                                <jira.websudo.is.disabled>true</jira.websudo.is.disabled>
                                <!-- we run on XVFB, since that's the way the build engineers would
                                                like to go, as opposed to VNC server (according to Min'an) -->
                                <xvfb.enable>${xvfb.enable}</xvfb.enable>
                                <pkqdsl.react.to.clear.cache>true</pkqdsl.react.to.clear.cache>
                                <org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER>true
                                </org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER>
                                <mail.mime.decodeparameters>true</mail.mime.decodeparameters>
                                <atlassian.cache.serialization.check>true</atlassian.cache.serialization.check>
                                <atlassian.sd.upgrade.task.version.limit>${atlassian.sd.upgrade.task.version.limit}
                                </atlassian.sd.upgrade.task.version.limit>
                                <atlassian.darkfeature.never.display.assets.rebrand.onboarding.enabled>true
                                </atlassian.darkfeature.never.display.assets.rebrand.onboarding.enabled>
                            </systemPropertyVariables>
                            <log4j2Config>src/test/resources/log4j2-test.xml</log4j2Config>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira</groupId>
                                    <artifactId>jira-func-test-plugin</artifactId>
                                    <version>${jira.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira.tests</groupId>
                                    <artifactId>jira-testkit-plugin</artifactId>
                                    <version>${testkit.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.plugins</groupId>
                                    <artifactId>atlassian-chaperone</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk</groupId>
                                    <artifactId>jira-servicedesk</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.plugins</groupId>
                                    <artifactId>atlassian-client-resource</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-testutils-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk.plugins.automation</groupId>
                                    <artifactId>servicedesk-automation-testutils-plugin</artifactId>
                                    <version>${automation.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-project-ui-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-reports-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-approvals-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>incident-management-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-core-ui-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-internal-base-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>jira-servicedesk-public-rest-api-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.pocketknife</groupId>
                                    <artifactId>atlassian-pocketknife-api-commons-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk</groupId>
                                    <artifactId>jira-workinghours-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.plugin.timedpromise</groupId>
                                    <artifactId>atlassian-timed-promise-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk.plugins.automation</groupId>
                                    <artifactId>servicedesk-automation-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk.plugins.automation</groupId>
                                    <artifactId>servicedesk-automation-modules-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk.plugins.automation</groupId>
                                    <artifactId>servicedesk-automation-then-webhook-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.psmq</groupId>
                                    <artifactId>psmq-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk</groupId>
                                    <artifactId>psmq-backdoor-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk.plugins</groupId>
                                    <artifactId>servicedesk-search-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira</groupId>
                                    <artifactId>jira-email-processor-plugin</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira</groupId>
                                    <artifactId>jira-email-processor-test-utils-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk</groupId>
                                    <artifactId>jira-servicedesk-application</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk.plugins.automation</groupId>
                                    <artifactId>servicedesk-automation-testutils-plugin</artifactId>
                                    <version>${automation.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.analytics</groupId>
                                    <artifactId>analytics-client</artifactId>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-knowledge-base-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-lingo-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-lingo-integration-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-canned-responses-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-variable-substitution-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk</groupId>
                                    <artifactId>servicedesk-frontend-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>servicedesk-notifications-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>applinks-util-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.frontend</groupId>
                                    <artifactId>atlassian-frontend-runtime-plugin</artifactId>
                                    <version>${frontend.runtime.plugin.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira.plugins</groupId>
                                    <artifactId>jira-assets-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.plugin.timedpromise</groupId>
                                    <artifactId>atlassian-timed-promise-func-tests</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>org.apache.servicemix.bundles</groupId>
                                    <artifactId>org.apache.servicemix.bundles.junit</artifactId>
                                    <version>4.12_1</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.plugins</groupId>
                                    <artifactId>atlassian-plugins-osgi-testrunner-bundle</artifactId>
                                    <version>${plugin.testrunner.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.servicedesk</groupId>
                                    <artifactId>servicedesk-conditions-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <groupId>com.atlassian.jira.plugins</groupId>
                                    <artifactId>insight</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                            <libArtifacts>
                                <libArtifact>
                                    <groupId>com.h2database</groupId>
                                    <artifactId>h2</artifactId>
                                </libArtifact>
                            </libArtifacts>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-jira</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <jvmArgs>${jira.jvm.args}</jvmArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-jira</id>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <phase>post-integration-test</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>pa11y-test</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <argLine>${jira.java17.jvmargs}</argLine>
                        </configuration>
                        <executions>
                            <execution>
                                <!-- make sure this execution is defined before ci test executions so that we run this first ALWAYS and ensure DB setup -->
                                <id>db_setup_database_tests</id>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <failIfNoTests>true</failIfNoTests>
                                    <includes>
                                        <include>pa11y/dbsetup/**</include>
                                    </includes>
                                    <systemProperties>
                                        <baseurl.jira>http://localhost:2990/jira</baseurl.jira>
                                        <http.jira.port>2990</http.jira.port>
                                        <context.jira.path>/jira</context.jira.path>
                                        <xvfb.enable>${xvfb.enable}</xvfb.enable>
                                        <webdriver.browser>firefox</webdriver.browser>
                                        <webdriver.browser.headless>true</webdriver.browser.headless>
                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                            <yarnVersion>${yarn.version}</yarnVersion>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install-node-and-yarn-audit</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>install-node-and-yarn</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>yarn-install</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>codecept-scrap-html</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>atlassian-a11y-runner crawl ./jsm-page-list.json -c ./a11y.config.json -u ${pa11y.username} -p ${pa11y.password}</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>audit-accessibility</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>atlassian-a11y-runner audit -c ./a11y.config.json --csv</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>find-accessibility-regression</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>atlassian-a11y-runner baseline compare -c ./a11y.config.json -v ${pa11y.target.baseline.version} -r ${project.basedir}/audit_baselines</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
