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

Issue 48715: Limit Data Region "Show all" to a maximum number of rows #1762

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion modules/simpletest/resources/views/QWPDemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<div class="tab"><a href="#testFilterOnSortColumn">Filter on "Sort" column</a></div>
<div class="tab"><a href="#testButtonBarConfig">Use onRender via ButtonBarOptions</a></div>
<div class="tab"><a href="#testRespectExcludingPrefixes">Exclude "skipPrefixes"</a></div>
<div class="tab"><a href="#testAllRowsLimit">Show All Rows Limit (Regression #48715)</a></div>
<div class="tab"><a href="#testGetSelected">Get Selected (Regression #41705)</a></div>
</td>
<td valign="top">
Expand All @@ -67,7 +68,11 @@
LABKEY.Domain.get(function() {
LABKEY.Domain.get(function() {
LABKEY.Domain.get(function() {
showPopulateSuccess(true);
LABKEY.Domain.get(function() {
showPopulateSuccess(true);
}, function() {
showPopulateButton(true);
}, 'Samples', 'sampleDataTest5k');
}, function() {
showPopulateButton(true);
}, 'Samples', 'sampleDataTest3');
Expand Down
78 changes: 67 additions & 11 deletions modules/simpletest/resources/web/simpletest/QWPDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
testFilterOnSortColumn: testFilterOnSortColumn,
testButtonBarConfig: testButtonBarConfig,
testRespectExcludingPrefixes: testRespectExcludingPrefixes,
testGetSelected: testGetSelected
testAllRowsLimit: testAllRowsLimit,
testGetSelected: testGetSelected,
};

var PAGE_OFFSET = 4;
Expand Down Expand Up @@ -136,11 +137,11 @@
renderTo: RENDERTO,
success: function() {
var results = $("a:contains('sampleDataTest')");
if (!results || results.length < 3) {
if (!results || results.length < 4) {
alert('Failed to list out all queries in Samples schema');
}
else {
LABKEY.Utils.signalWebDriverTest("testSchemaOnly");
LABKEY.Utils.signalWebDriverTest('testSchemaOnly');
}
},
failure: function() {
Expand Down Expand Up @@ -764,6 +765,7 @@
}

function testShowAllTotalRows() {
var loadCount = 0;
new LABKEY.QueryWebPart({
title: 'Show All Rows',
schemaName: 'Samples',
Expand All @@ -774,17 +776,19 @@
},
listeners: {
render: function(dr) {
if (dr.maxRows != -1) {
loadCount++;

if (loadCount === 1) {
dr.showAllRows();
}
else {
if (!dr.totalRows)
{
} else if (loadCount === 2) {
if (!dr.totalRows) {
alert('Failed test: Show All Rows. totalRows is not set correctly with Show All.');
return;
}
else {
LABKEY.Utils.signalWebDriverTest("testShowAllTotalRows");
}

LABKEY.Utils.signalWebDriverTest('testShowAllTotalRows');
} else {
alert('Failed test: Unexpected number of requests made.');
}
}
}
Expand Down Expand Up @@ -982,6 +986,58 @@
});
}

// Issue 48715: Limit Data Region "Show all" to a maximum number of rows
function testAllRowsLimit() {
var loadCount = 0;
new LABKEY.QueryWebPart({
title: 'Show All Rows Limit (Regression #48715)',
schemaName: 'Samples',
queryName: 'sampleDataTest5k',
removeableFilters: [
// Initialize with a user filter
LABKEY.Filter.create('Name', 'Sample 5k-5000')
],
renderTo: RENDERTO,
failure: function() {
alert('Failed test: testAllRowsLimit failed to load');
},
listeners: {
render: function(qwp) {
loadCount++;

if (loadCount === 1) {
// Set the QWP to show all rows
qwp.showAllRows();
} else if (loadCount === 2) {
// Clear the user filter
qwp.clearFilter('Name');
} else if (loadCount === 3) {
if (qwp.totalRows !== 5_001) {
alert('Failed test: Expected 5,001 results in query.');
return;
}

if (qwp.maxRows !== 5_000) {
alert('Failed test: Expected maxRows to be set to 5,000');
return;
}

// Expect to be bound by the "Show all" configuration displaying a maximum amount of rows
const message = qwp.getMessage('info');
if (!message || message.indexOf('Displaying the first 5,000 rows. Use paging to see more results.') === -1) {
alert('Failed test: Expected message regarding "Show all" boundary did not appear.');
return;
}

LABKEY.Utils.signalWebDriverTest('testAllRowsLimit');
} else {
alert('Failed test: Unexpected number of requests made.');
}
}
}
});
}

function testGetSelected() {
var loadCount = 0;
new LABKEY.QueryWebPart({
Expand Down
11 changes: 9 additions & 2 deletions modules/simpletest/resources/web/simpletest/QWPDemoData.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,17 @@ function setUpDomains() {
{"Alias": 'alias 6', "Id": 6, "Sort": 50, "Tag": 'blue'}];
var rows2 =[ {"Alias": 'alias 2-1', "Id": 201, "Sort": 1000, "Tag": 'square'}];
var rows3 =[ {"Alias": 'alias 3-1', "Id": 301, "Sort": 500, "Tag": 'Hispanic'}];
const manyRows = [];
const numRows = 5_001;
for (let i = 0; i < numRows; i++) {
manyRows.push({ Alias: `alias 5k-${i}`, Id: numRows + i, Name: `Sample 5k-${i}`, Sort: numRows + i, Tag: 'many rows' });
}
sampleSetDomainTypeTest('sampleDataTest1', rows1, 'A sample type with color tags', function() {
sampleSetDomainTypeTest('sampleDataTest2', rows2, 'A sample type with shape tags', function(){
sampleSetDomainTypeTest('sampleDataTest3', rows3, 'A sample type with race tags', function(){
location.reload();
sampleSetDomainTypeTest('sampleDataTest5k', manyRows, `A sample type with ${manyRows.length.toLocaleString()} rows`, function(){
location.reload();
});
});
});
}, ([
Expand All @@ -113,7 +120,7 @@ function setUpDomains() {

function dropDomains() {
var completeCt = 0;
var queries = ["sampleDataTest1", "sampleDataTest2", "sampleDataTest3"];
var queries = ['sampleDataTest1', 'sampleDataTest2', 'sampleDataTest3', 'sampleDataTest5k'];
var dropSuccess = function() {
dropComplete('dropped');
};
Expand Down
4 changes: 3 additions & 1 deletion src/org/labkey/test/tests/AbstractQWPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.util.List;

import static org.junit.Assert.assertEquals;
Expand All @@ -44,7 +46,7 @@ protected void testQWPDemoPage()
waitForElement(Locator.button("Populate test data"));
clickButton("Populate test data");
WebElement populateMessage = Locator.id("populatemessage").waitForElement(shortWait());
longWait().until(ExpectedConditions.visibilityOf(populateMessage)).getText();
new WebDriverWait(getDriver(), Duration.ofSeconds(60)).until(ExpectedConditions.visibilityOf(populateMessage)).getText();
assertEquals("Test data is populated!", populateMessage.getText());

log("Testing " + QWP_SCHEMA_LISTING.getLeft());
Expand Down
1 change: 1 addition & 0 deletions src/org/labkey/test/tests/DataRegionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class DataRegionTest extends AbstractQWPTest
Pair.of("Filter on \"Sort\" column", "testFilterOnSortColumn"),
Pair.of("Use onRender via ButtonBarOptions", "testButtonBarConfig"),
Pair.of("Exclude \"skipPrefixes\"", "testRespectExcludingPrefixes"),
Pair.of("Show All Rows Limit (Regression #48715)", "testAllRowsLimit"),
Pair.of("Get Selected (Regression #41705)", "testGetSelected")
);

Expand Down