Skip to content

Commit

Permalink
Merge pull request #1739 from openequella/hotfix/2019.2.3
Browse files Browse the repository at this point in the history
Hotfix/2019.2.3
  • Loading branch information
SammyIsConfused authored May 28, 2020
2 parents dd48f40 + 88ce722 commit 5174f99
Show file tree
Hide file tree
Showing 431 changed files with 15,330 additions and 12,130 deletions.
44 changes: 44 additions & 0 deletions Source/Plugins/Core/com.equella.core/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Source/Plugins/Core/com.equella.core/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"react-beautiful-dnd": "7.1.3",
"react-color": "2.17.0",
"react-dom": "16.8.4",
"react-html-parser": "2.0.2",
"react-redux": "5.1.1",
"react-router": "5.0.0",
"react-router-dom": "5.0.0",
Expand All @@ -71,20 +72,21 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "22.2.3",
"@types/luxon": "1.15.1",
"@types/lodash": "4.14.144",
"@types/tinymce": "4.5.23",
"@types/luxon": "1.15.1",
"@types/node": "9.6.52",
"@types/react": "16.9.11",
"@types/react-autosuggest": "9.3.11",
"@types/react-color": "2.17.0",
"@types/react-dom": "16.9.2",
"@types/react-html-parser": "2.0.1",
"@types/react-redux": "5.0.21",
"@types/react-router": "5.1.1",
"@types/react-router-dom": "4.3.5",
"@types/react-swipeable-views": "0.12.2",
"@types/redux-logger": "3.0.7",
"@types/sprintf-js": "1.1.2",
"@types/tinymce": "4.5.23",
"@types/uuid": "3.4.4",
"argparse": "1.0.10",
"combined-stream2": "1.1.2",
Expand Down
24 changes: 16 additions & 8 deletions Source/Plugins/Core/com.equella.core/js/tsrc/mainui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
LegacyContentProps,
PageContent
} from "../legacycontent/LegacyContent";
import HtmlParser from "react-html-parser";
import { getCurrentUser } from "../api/currentuser";
import { ErrorResponse } from "../api/errors";
import ErrorPage from "./ErrorPage";
Expand Down Expand Up @@ -108,9 +109,7 @@ function IndexPage() {
}, []);
const oeqRoutes: { [key: string]: OEQRoute } = routes;

function mkRouteProps(
p: RouteComponentProps<any>
): OEQRouteComponentProps<any> {
function mkRouteProps(p: RouteComponentProps<any>): OEQRouteComponentProps {
return {
...p,
updateTemplate,
Expand Down Expand Up @@ -218,11 +217,20 @@ function IndexPage() {
{routeSwitch(content)}
</Template>
);
return !content || content.noForm ? (
template
) : (
<LegacyForm state={content.state}>{template}</LegacyForm>
);
const render = () => {
if (!content || content.noForm) {
return template;
} else {
const { form } = content.html;
return (
<>
<LegacyForm state={content.state}>{template}</LegacyForm>
{form && HtmlParser(form)}
</>
);
}
};
return render();
}}
/>
</BrowserRouter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,19 @@ class LegacyContentApi {
val body = SectionUtils.renderToString(
context,
wrapBody(context, tr.getNamedResult(context, "body")))
val form = context.getForm
val formString: Option[String] = Option(form.getAction) match {
case Some(action) => Some(SectionUtils.renderToString(context, form))
case None => None
}
val upperbody =
SectionUtils.renderToString(context, tr.getNamedResult(context, "upperbody"))
val scrops = renderScreenOptions(context)
val crumbs = renderCrumbs(context, decs).map(SectionUtils.renderToString(context, _))
Iterable(
Some("body" -> body),
Option(upperbody).filter(_.nonEmpty).map("upperbody" -> _),
formString.map("form" -> _),
scrops.map("so" -> _),
crumbs.map("crumbs" -> _)
).flatten.toMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import com.tle.web.sections.SectionInfo;
import com.tle.web.sections.equella.annotation.PlugKey;
import com.tle.web.sections.equella.annotation.PluginResourceHandler;
import com.tle.web.wizard.WebWizardPage;
import com.tle.web.wizard.WizardService;
import com.tle.web.wizard.impl.WizardCommand;
import com.tle.web.wizard.section.PagesSection;
import com.tle.web.wizard.section.WizardSectionInfo;
import com.tle.web.workflow.tasks.ModerationService;
import javax.inject.Inject;
Expand Down Expand Up @@ -57,10 +55,7 @@ public void execute(SectionInfo info, WizardSectionInfo winfo, String data) thro
wizardService.reload(winfo.getWizardState(), true);
moderationService.setEditing(info, true);
// validate mandatory fields when moderating items
PagesSection ps = info.lookupSection(PagesSection.class);
for (WebWizardPage page : winfo.getWizardState().getPages()) {
wizardService.ensureInitialisedPage(info, page, ps.getReloadFunction(), true);
}
validateMandatoryFields(info, winfo.getWizardState());
info.forceRedirect();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ public void execute(SectionInfo info, WizardSectionInfo winfo, String data) thro
}
wizardService.reloadSaveAndContinue(state);
// validate mandatory fields after reloading
for (WebWizardPage page : pageList) {
wizardService.ensureInitialisedPage(info, page, ps.getReloadFunction(), true);
}
validateMandatoryFields(info, state);
moderationService.setEditing(info, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
import com.tle.web.sections.SectionInfo;
import com.tle.web.sections.events.js.JSHandler;
import com.tle.web.sections.js.JSCallable;
import com.tle.web.wizard.WebWizardPage;
import com.tle.web.wizard.WizardService;
import com.tle.web.wizard.WizardState;
import com.tle.web.wizard.section.PagesSection;
import com.tle.web.wizard.section.WizardSectionInfo;
import javax.inject.Inject;

public abstract class WizardCommand {
private final String name;
private final String value;
@Inject private WizardService wizardService;

public WizardCommand(String name, String value) {
this.name = name;
Expand Down Expand Up @@ -69,4 +75,11 @@ public String getStyleClass() {
}

public abstract boolean isEnabled(SectionInfo info, WizardSectionInfo winfo);

public void validateMandatoryFields(SectionInfo info, WizardState state) {
PagesSection ps = info.lookupSection(PagesSection.class);
wizardService.getWizardPages(state).stream()
.filter(WebWizardPage::isViewable)
.forEach(p -> wizardService.ensureInitialisedPage(info, p, ps.getReloadFunction(), true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.tle.web.template.Decorations;
import com.tle.web.template.Decorations.MenuMode;
import com.tle.web.viewurl.ItemSectionInfo;
import com.tle.web.wizard.WebWizardPage;
import com.tle.web.wizard.WizardExceptionHandler;
import com.tle.web.wizard.WizardService;
import com.tle.web.wizard.WizardState;
Expand Down Expand Up @@ -303,8 +304,8 @@ protected WizardSectionInfo getWizardInfo(SectionInfo info) {

void validateMandatoryFields(SectionInfo info, WizardState state) {
PagesSection ps = info.lookupSection(PagesSection.class);
wizardService
.getWizardPages(state)
wizardService.getWizardPages(state).stream()
.filter(WebWizardPage::isViewable)
.forEach(p -> wizardService.ensureInitialisedPage(info, p, ps.getReloadFunction(), true));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.tle.webtests.test.contribute.bugs;

import static com.tle.webtests.framework.Assert.assertTrue;

import com.tle.webtests.framework.TestInstitution;
import com.tle.webtests.pageobject.searching.SearchPage;
import com.tle.webtests.pageobject.viewitem.ItemXmlPage;
import com.tle.webtests.pageobject.viewitem.SummaryPage;
import com.tle.webtests.pageobject.wizard.ContributePage;
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.test.AbstractCleanupTest;
import org.testng.annotations.Test;
import retry.RetryTest;

/**
* This is a test to ensure that GH issue #1678 has not regressed.
*
* @see <a href="https://github.com/openequella/openEQUELLA/issues/1678">GitHub Issue 1678</a>
*/
@TestInstitution("vanilla")
public class VisibilityScriptingBugTest extends AbstractCleanupTest {
private static final String METADATA_INPUT_USER = "cpddm";
private static final String TOGGLE_USER = "csme";
private static final String PASS = "tle010";

private static final String COLLECTION = "Test Wizard Issue";
private static final String ITEM_NAME = "VisibilityScriptingBugTest - Lost Metadata Test Item 1";

private static final String RADIO = "Yes";

private static final String XML_PATH = "item/";

@RetryTest
@Test
public void testLostMetadataBug() {
// Login as cpddm and begin contribution to 'Test Wizard Issue' collection.
logon(METADATA_INPUT_USER, PASS);
WizardPageTab wizard = new ContributePage(context).load().openWizard(COLLECTION);

// Insert a value into each control and publish the item.
wizard.getControl(1).sendKeys(ITEM_NAME);
wizard.save().publish();

// Login as csme and find the same item.
logon(TOGGLE_USER, PASS);
SearchPage searchPage = new SearchPage(context).load();
searchPage.search(ITEM_NAME);
SummaryPage summaryPage = searchPage.resultsPageObject().viewFromTitle(ITEM_NAME);

// If the item is in a locked state, unlock it
// (this is mainly so that rerunning the test before it cleans up doesn't wrongly fail the test)
if (summaryPage.isItemLocked()) {
summaryPage.unlockAfterLogout();
}

// Edit the item as csme.
// This will open a different wizard page to the one cpddm sees, because of visibility
// scripting.
WizardPageTab newWizard = summaryPage.edit(1);

// Make a change (this is where the metadata would become lost because of the bug) and save.
newWizard.setCheckReload(1, RADIO, true).saveNoConfirm().checkLoaded();
// Open the item's xml page to view the metadata.
ItemXmlPage xml = summaryPage.itemXml();

// Assert that all of the metadata has been retained.
assertTrue(xml.nodeHasValue(XML_PATH + "name", ITEM_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public void testViewCount() {

@Test
public void testAttachmentViewCount() {
final String linkAttachment =
"https://web.archive.org/web/19990125084553/http://alpha.google.com/";
final String linkAttachment = "https://www.google.com/";

final String imgAlt = "input[value=\"Google Search\"]";
logon(AUTOTEST_LOGON, AUTOTEST_PASSWD);

final WizardPageTab wizard = new ContributePage(context).load().openWizard(COLLECTION3);
Expand All @@ -145,9 +145,7 @@ public void testAttachmentViewCount() {
checkViews(summary, 1, linkAttachment, 0);

// view the attachment and go back
summary
.attachments()
.viewLinkAttachment(linkAttachment, By.cssSelector("img[alt=\"Google!\"]"));
summary.attachments().viewLinkAttachment(linkAttachment, By.cssSelector(imgAlt));
final WebDriver.Navigation navigate = context.getDriver().navigate();
navigate.back();
// navigate.refresh();
Expand All @@ -157,9 +155,7 @@ public void testAttachmentViewCount() {
checkViews(summary, 2, linkAttachment, 1);

// view the attachment again and go back
summary
.attachments()
.viewLinkAttachment(linkAttachment, By.cssSelector("img[alt=\"Google!\"]"));
summary.attachments().viewLinkAttachment(linkAttachment, By.cssSelector(imgAlt));
navigate.back();
// navigate.refresh();

Expand Down
36 changes: 36 additions & 0 deletions autotest/OldTests/src/test/java/retry/FailureRetryAnalyzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package retry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

public class FailureRetryAnalyzer implements IRetryAnalyzer {
int currentRetry = 0;
Logger LOGGER = LoggerFactory.getLogger(FailureRetryAnalyzer.class.getName());

@Override
public boolean retry(ITestResult result) {
RetryTest failureRetryCount =
result.getMethod().getConstructorOrMethod().getMethod().getAnnotation(RetryTest.class);
int maxRetryCount = (failureRetryCount == null) ? 0 : failureRetryCount.value();
if (++currentRetry > maxRetryCount) {
return false;
} else {
logRetryInfo(result, maxRetryCount);
return true;
}
}

private void logRetryInfo(ITestResult result, int maxRetryCount) {
// print failure stack trace
LOGGER.debug("Stack trace of failure to be retried:", result.getThrowable());
LOGGER.warn(
String.format(
"Running retry %d/%d for test '%s' in class %s",
currentRetry,
maxRetryCount,
result.getName(),
result.getTestClass().getRealClass().getSimpleName()));
}
}
Loading

0 comments on commit 5174f99

Please sign in to comment.