Skip to content

Commit

Permalink
Merge pull request #85 from orbinson/improve-it-tests
Browse files Browse the repository at this point in the history
Improve it tests
  • Loading branch information
bdhoine authored Jan 19, 2025
2 parents 0cd4b94 + b56d3df commit c1bf1bf
Show file tree
Hide file tree
Showing 46 changed files with 1,191 additions and 1,060 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ updates:
versions: [ "[6.5.17,)" ]
- dependency-name: "biz.aQute.bnd:bnd-maven-plugin"
update-types: [ "version-update:semver-major" ]
- dependency-name: "org.apache.commons:commons-csv"
versions: [ "[1.10.0,)" ]
- package-ecosystem: "npm"
directory: "/ui.tests"
reviewers:
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,33 @@ jobs:
name: Call workflow
uses: orbinson/workflows/.github/workflows/aem-maven-build.yml@main
with:
java-version: 11
java-version: 21

sonar:
name: Run SonarQube analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
cache: maven
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Execute SonarQube maven plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B -Pcoverage verify sonar:sonar

ui-tests:
name: Run UI tests
Expand All @@ -35,7 +61,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 21
cache: maven
- name: Get Playwright version from package-lock.json
run: echo "PLAYWRIGHT_VERSION=$(jq -r '.packages["node_modules/playwright-core"].version' ui.tests/package-lock.json)" >> $GITHUB_ENV
Expand All @@ -52,7 +78,7 @@ jobs:
run: mvn test -B -pl ui.tests -DskipTests=false
- name: Publish Playwright test results
run: |
npx github-actions-ctrf --pull-request --annotate ui.tests/ctrf/ctrf-report.json
npx github-actions-ctrf --pull-request --annotate --on-fail-only ui.tests/ctrf/ctrf-report.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Playwright HTML report
Expand Down
66 changes: 33 additions & 33 deletions .run/[author] install it.content.run.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="[author] install it.content" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="cmdOptions" />
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="clean" />
<option value="install" />
</list>
</option>
<option name="multimoduleDir" />
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map>
<entry key="autoInstallPackage" value="true" />
</map>
</option>
<option name="projectsCmdOptionValues">
<list />
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/it.content" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
<configuration default="false" name="[author] install it.content" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings"/>
<option name="myRunnerSettings"/>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="cmdOptions"/>
<option name="profiles">
<set/>
</option>
<option name="goals">
<list>
<option value="clean"/>
<option value="install"/>
</list>
</option>
<option name="multimoduleDir"/>
<option name="pomFileName" value="pom.xml"/>
<option name="profilesMap">
<map>
<entry key="autoInstallPackage" value="true"/>
</map>
</option>
<option name="projectsCmdOptionValues">
<list/>
</option>
<option name="resolveToWorkspace" value="false"/>
<option name="workingDirPath" value="$PROJECT_DIR$/it.content"/>
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2"/>
</configuration>
</component>
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Only single dictionary can be selected [#62](https://github.com/orbinson/aem-dictionary-translator/issues/62)
- Last modified date is removed from UI as it was not correct

## [1.2.1] - 2024-11-26

Expand Down
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ Import-Package: javax.annotation;version=0.0.0,*
<artifactId>junit-addons</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@

import org.apache.sling.api.resource.Resource;

import java.util.Calendar;
import java.util.List;

public interface Dictionary {
Resource getResource();

Calendar getCreated();

String getLanguageList();

String getLastModifiedFormatted();

String getBasename();

Calendar getLastModified();

List<String> getLanguages();

List<String> getKeys();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,20 @@
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.inject.Named;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Model(
adaptables = SlingHttpServletRequest.class,
adapters = be.orbinson.aem.dictionarytranslator.models.Dictionary.class
)
public class DictionaryImpl implements Dictionary {

@SlingObject
private SlingHttpServletRequest request;

@SlingObject
private Resource resource;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@Named("jcr:created")
private Calendar created;

@ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL)
@Named("jcr:lastModified")
private Calendar lastModified;

@OSGiService
private DictionaryService dictionaryService;

Expand All @@ -46,21 +27,6 @@ public String getLanguageList() {
return String.join(", ", this.getLanguages());
}

private String getDateString(Date date) {
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, request.getLocale());
return formatter.format(date);
}

@Override
public String getLastModifiedFormatted() {
return getDateString(getLastModified().getTime());
}

@Override
public Calendar getLastModified() {
return lastModified == null ? getCreated() : lastModified;
}

@Override
public List<String> getLanguages() {
return dictionaryService.getLanguages(resource);
Expand All @@ -76,11 +42,6 @@ public boolean isEditable() {
return resource;
}

@Override
public @Nullable Calendar getCreated() {
return created;
}

@Override
public String getBasename() {
return dictionaryService.getBasename(resource);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Version("1.0")
@Version("2.0.0")
package be.orbinson.aem.dictionarytranslator.models;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import javax.jcr.RepositoryException;
import java.util.List;
import java.util.Map;

public interface DictionaryService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import static be.orbinson.aem.dictionarytranslator.utils.DictionaryConstants.SLING_MESSAGEENTRY;

Expand Down Expand Up @@ -114,5 +120,4 @@ private boolean isMessageEntry(Resource dictionaryResource, String key) {
public @Nullable Iterator<Resource> listChildren(@NotNull ResolveContext<Object> ctx, @NotNull Resource parent) {
return Collections.emptyIterator();
}

}
Loading

0 comments on commit c1bf1bf

Please sign in to comment.