Skip to content

Commit

Permalink
fix: Fix Main Customization Page Renaming and disable Terms and Condi…
Browse files Browse the repository at this point in the history
…tions - MEED-8270 (#307)

This change will disabled Terms and Conditions when enabled on Server to
allow access all pages for all users without having to accept the Terms
and conditions. In addition, this will fix the `Main Customization` page
renaming to `Appearance`.
  • Loading branch information
boubaker authored and exo-swf committed Feb 3, 2025
1 parent 240d962 commit 9d4df65
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/meeds/qa/ui/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void goToAddUser() {
}

public void goToMainSettings() {
goToAdministrationPage("General/Main Customization", true);
goToAdministrationPage("General/Appearance", true);
}

public void goToNotificationAdminPage() {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/io/meeds/qa/ui/pages/UserProfilePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ public void checkWorkExperiencesSection(String jobTitle, String organization, St
}

public void clickOnSendKudosBtn() {
ElementFacade uiIconKudosElement = uiIconKudosElement();
uiIconKudosElement.assertVisible();
uiIconKudosElement.click();
waitForDrawerToOpen();
waitCKEditorLoading();
retryOnCondition(() -> {
ElementFacade uiIconKudosElement = uiIconKudosElement();
uiIconKudosElement.checkVisible();
uiIconKudosElement.click();
waitForDrawerToOpen(true);
waitCKEditorLoading();
});
}

public int getMyWeeklyPoint() {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/meeds/qa/ui/hook/TestInitHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private void loginAsAdmin() {
if (!loginSteps.authenticate(ADMIN_USERNAME, ADMIN_PASSWORD, false)) {
throw new IllegalStateException("Couldn't login with admin");
}
genericSteps.disableTermsAndConditions();
}

private void loginAsRandomAdmin() {
Expand Down
32 changes: 30 additions & 2 deletions src/test/java/io/meeds/qa/ui/steps/GenericSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import net.serenitybdd.core.Serenity;

public class GenericSteps {
private static final String DISABLE_PWA_SCRIPT =
private static final String DISABLE_PWA_SCRIPT =
"""
const callback = arguments[arguments.length - 1];
fetch("/pwa/rest/manifest", {
Expand All @@ -43,13 +43,32 @@ public class GenericSteps {
})
.then(resp => {
if (!resp || !resp.ok) {
throw new Error("Error changing space creation permissions");
throw new Error("Error when switching Off PWA");
}
})
.then(() => callback(true))
.catch(() => callback(false));
""";

private static final String DISABLE_TERMS_SCRIPT =
"""
const callback = arguments[arguments.length - 1];
fetch("/notes/rest/terms/settings?published=false&lang=en", {
"headers": {
"content-type": "application/json",
},
"method": "PUT",
"credentials": "include"
})
.then(resp => {
if (!resp || !resp.ok) {
throw new Error("Error when switching Off Terms and Conditions");
}
})
.then(() => callback(true))
.catch(() => callback(false));
""";

private GenericPage genericPage;

public void checkConfirmMessageIsDisplayed(String message) {
Expand Down Expand Up @@ -245,6 +264,15 @@ public void disablePwa() {
.equals("true"));
}

public void disableTermsAndConditions() {
WebDriverWait wait = new WebDriverWait(Serenity.getDriver(),
Duration.ofSeconds(10),
Duration.ofMillis(SHORT_WAIT_DURATION_MILLIS));
wait.until(driver -> ((JavascriptExecutor) driver).executeAsyncScript(DISABLE_TERMS_SCRIPT)
.toString()
.equals("true"));
}

public void goToPage(String link) {
genericPage.goToPage(link);
}
Expand Down

0 comments on commit 9d4df65

Please sign in to comment.