Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: test ci for flaky tests #5004

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 0 additions & 78 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,6 @@ jobs:
run: |
npm ci

- name: Run checks
run: |
npm run check
./sbt headerCheck

# oeq-ts-rest-api has its own ESLint checks seeing the ultimate plan
# is that it's moved to its own stand-alone repo. But so here we need
# to explicitly run them.
- name: Run checks (oeq-ts-rest-api)
working-directory: oeq-ts-rest-api
run: |
npm run lint

- name: Run unit tests (java/scala)
run: |
./sbt test

- name: Run unit tests (javascript)
working-directory: react-front-end
run: |
npm cit

- name: Run unit tests (javascript - legacy)
working-directory: Source/Plugins/Core/com.equella.core/test/javascript
run: |
npm cit

- name: Build primary artefacts
run: |
./sbt installerZip writeLanguagePack writeScriptingJavadoc
Expand All @@ -128,57 +101,6 @@ jobs:
name: Artefacts
path: artefacts.tar

build_storybook:
runs-on: ubuntu-latest
steps:
# Using v1 (rather than v2) through-out this workflow due to issue:
# https://github.com/actions/checkout/issues/237
- uses: actions/checkout@v4

- name: NPM Cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm.storybook-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm.storybook-

- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Install node dependencies (oeq-rest-api)
working-directory: oeq-ts-rest-api
run: |
npm ci

- name: Build oEQ REST module (oeq-rest-api)
working-directory: oeq-ts-rest-api
run: |
npm run build

- name: Install node dependencies (core)
working-directory: react-front-end
run: |
npm ci

- name: Generate Static Storybook instance
working-directory: react-front-end
run: |
npm run build-storybook

- name: Package Static Storybook instance
working-directory: react-front-end
run: |
tar cvf storybook.tar storybook-static

- name: Save Static Storybook instance
uses: actions/upload-artifact@v3.1.3
with:
name: Storybook
path: react-front-end/storybook.tar

functional_testing:
needs: build_and_check

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
import com.tle.webtests.pageobject.wizard.ContributePage;
import com.tle.webtests.pageobject.wizard.WizardPageTab;
import com.tle.webtests.test.AbstractCleanupTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -285,7 +291,11 @@ public void testFreemarkerPortal() {
}

@Test
public void testRecentPortal() {
public void testRecentPortal() throws InterruptedException {
ExpectedCondition<WebElement> successMessage =
ExpectedConditions.visibilityOfElementLocated(
By.xpath("//*[contains(text(), 'Successfully saved')]"));

HomePage home = dash();
String recentName = context.getFullName("Recent Contributions Portal");

Expand All @@ -309,25 +319,24 @@ public void testRecentPortal() {
wizard1.save().publish();

String draftItemName = context.getFullName("draft item");

WizardPageTab wizard2 =
new ContributePage(context).load().openWizard("Simple Controls Collection");
wizard2.editbox(1, draftItemName);
wizard2.save().draft();
WebDriverWait waiter = wizard2.save().draft().getWaiter();

// Check that the live item is displayed
home = new MenuSection(context).home();
RecentContributionsSection recent = new RecentContributionsSection(context, recentName).get();
assertTrue(recent.recentContributionExists(liveItemName));
assertTrue(waiter.until(waitForItem(recentName, liveItemName)));

// Edit the portal
new MenuSection(context).home();
RecentContributionsSection recent = new RecentContributionsSection(context, recentName).get();
RecentContributionsEditPage edit = recent.edit(portal);
edit.setStatus("draft");
edit.checkSelectedCollection();
edit.save(new HomePage(context));

// Check that the draft item is displayed
home = new MenuSection(context).home();
recent = new RecentContributionsSection(context, recentName).get();
assertTrue(recent.recentContributionExists(draftItemName));

String itemToQuery = context.getFullName("query item");
Expand All @@ -338,7 +347,7 @@ public void testRecentPortal() {
wizard3.editbox(1, itemToQuery);
wizard3.editbox(2, description);

wizard3.save().publish();
wizard3.save().publish().getWaiter().until(successMessage);

// Edit portlet for query option
home = new MenuSection(context).home();
Expand All @@ -347,10 +356,11 @@ public void testRecentPortal() {
edit.setStatus("live");
edit.checkSelectedCollection();
edit.save(new HomePage(context));

// Check that the queried item is displayed
home = new MenuSection(context).home();
recent = new RecentContributionsSection(context, recentName).get();
assertTrue(recent.recentContributionExists(itemToQuery));
new MenuSection(context).home();
recent = new RecentContributionsSection(context, recentName).get();
assertTrue(recent.descriptionExists(description, true));

// Edit portlet for description option
Expand All @@ -362,7 +372,7 @@ public void testRecentPortal() {
edit.save(new HomePage(context));

// Check that the description not displayed
home = new MenuSection(context).home();
new MenuSection(context).home();
recent = new RecentContributionsSection(context, recentName).get();
assertFalse(recent.descriptionExists(description, false));
}
Expand Down Expand Up @@ -442,4 +452,16 @@ protected void cleanupAfterClass() throws Exception {
new DashboardAdminPage(context).load().deleteAll(prefix);
super.cleanupAfterClass();
}

private ExpectedCondition<Boolean> waitForItem(String sectionTitle, String itemName) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
new MenuSection(context).home();
RecentContributionsSection recent =
new RecentContributionsSection(context, sectionTitle).get();
return recent.recentContributionExists(itemName);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public void selectUser(String username) {

// Open the dialog and search for the target user.
userSelector.findElement(By.tagName("button")).click();

WebElement dialog = driver.findElement(By.xpath("//div[@role='dialog']"));
WebElement input = dialog.findElement(By.tagName("input"));
input.sendKeys(username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public boolean recentContributionExists(String itemName) {
".//div[normalize-space(@class)='recent-items']//a[normalize-space(text())="
+ quoteXPath(itemName)
+ "]");
waiter.until(ExpectedConditions.visibilityOfElementLocated(recentContributionXpath));
return isPresent(recentContributionXpath);
}

Expand Down
Loading