Skip to content
Snippets Groups Projects
Unverified Commit 781c9484 authored by Kamil Mielnik's avatar Kamil Mielnik Committed by GitHub
Browse files

Repro #28106 - Scrolling up on schema list jumps to the top when creating a new question (#44965)

* Add a test table with many schemas

* Add a repro for #28106

* Format code

* Add issue tag
parent 2c8bf0f8
No related branches found
No related tags found
No related merge requests found
...@@ -202,3 +202,36 @@ export const multi_schema = async dbClient => { ...@@ -202,3 +202,36 @@ export const multi_schema = async dbClient => {
return schemas; return schemas;
}; };
export const many_schemas = async dbClient => {
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
const schemas = Object.fromEntries(
alphabet.map(letter => {
const key = `Schema ${letter}`;
const value = [
"Animals",
[
{ name: "Duck", score: 10 },
{ name: "Horse", score: 20 },
{ name: "Cow", score: 30 },
],
];
return [key, value];
}),
);
Object.entries(schemas).forEach(async ([schemaName, details]) => {
const [table, rows] = details;
await dbClient.schema.createSchemaIfNotExists(schemaName);
await dbClient.schema.withSchema(schemaName).dropTableIfExists(table);
await dbClient.schema.withSchema(schemaName).createTable(table, t => {
t.string("name");
t.integer("score");
});
await dbClient(`${schemaName}.${table}`).insert(rows);
});
return schemas;
};
...@@ -393,6 +393,57 @@ describe("scenarios > notebook > data source", { tags: "@OSS" }, () => { ...@@ -393,6 +393,57 @@ describe("scenarios > notebook > data source", { tags: "@OSS" }, () => {
}); });
}); });
describe("issue 28106", () => {
beforeEach(() => {
const dialect = "postgres";
resetTestTable({ type: dialect, table: "many_schemas" });
restore(`${dialect}-writable`);
cy.signInAsAdmin();
resyncDatabase({ dbId: WRITABLE_DB_ID });
});
it(
"should not jump to the top of schema list when scrolling (metabase#28106)",
{ tags: "@external" },
() => {
startNewQuestion();
entityPickerModal().within(() => {
entityPickerModalTab("Tables").click();
cy.findByText("Writable Postgres12").click();
entityPickerModalLevel(1)
.findByTestId("scroll-container")
.as("schemasList");
// the list is virtualized and the scrollbar height changes during scrolling (metabase#44966)
// that's why we need to scroll twice and wait
cy.get("@schemasList").scrollTo("bottom");
cy.wait(100);
cy.get("@schemasList").scrollTo("bottom");
// assert scrolling worked and the last item is visible
entityPickerModalItem(1, "Public").should("be.visible");
// simulate scrolling up using mouse wheel 3 times
cy.get("@schemasList").realMouseWheel({ deltaY: -100 });
cy.wait(100);
cy.get("@schemasList").realMouseWheel({ deltaY: -100 });
cy.wait(100);
cy.get("@schemasList").realMouseWheel({ deltaY: -100 });
cy.wait(100);
// assert first item does not exist - this means the list has not been scrolled to the top
cy.findByText("Domestic").should("not.exist");
cy.get("@schemasList").should(([$element]) => {
expect($element.scrollTop).to.be.greaterThan(0);
});
});
},
);
});
function moveToCollection(collection: string) { function moveToCollection(collection: string) {
cy.intercept("GET", "/api/collection/tree**").as("updateCollectionTree"); cy.intercept("GET", "/api/collection/tree**").as("updateCollectionTree");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment