Skip to content
Snippets Groups Projects
Unverified Commit de58c843 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Replace hard coded ids in E2E custom commands and helpers (#20729)

* Replace hard coded ids in `question.js`

* Replace hard coded ids in ad hoc question helpers

* Replace hard coded ids in `sandboxTable` custom command

* Replace hard coded ids in `updatePermissions` custom command

* Avoid circular dependencies
parent 232be18a
No related branches found
No related tags found
No related merge requests found
import { SAMPLE_DB_ID } from "__support__/e2e/cypress_data";
Cypress.Commands.add("createQuestion", (questionDetails, customOptions) => {
const { name, query } = questionDetails;
......@@ -50,7 +52,7 @@ function question(
dataset = false,
native,
query,
database = 1,
database = SAMPLE_DB_ID,
display = "table",
visualization_settings = {},
collection_id,
......
import { USER_GROUPS } from "__support__/e2e/cypress_data";
const { COLLECTION_GROUP } = USER_GROUPS;
Cypress.Commands.add(
"sandboxTable",
({
attribute_remappings = {},
card_id = null,
group_id = 3,
group_id = COLLECTION_GROUP,
table_id = 2,
} = {}) => {
// Extract the name of the table, as well as `schema` and `db_id` that we'll need later on for `cy.updatePermissionsSchemas()`
......
import { SAMPLE_DB_ID, USER_GROUPS } from "__support__/e2e/cypress_data";
const { COLLECTION_GROUP } = USER_GROUPS;
/**
* PERMISSIONS
*
......@@ -34,7 +38,11 @@ Cypress.Commands.add(
Cypress.Commands.add(
"updatePermissionsSchemas",
({ schemas = {}, user_group = 3, database_id = 1 } = {}) => {
({
schemas = {},
user_group = COLLECTION_GROUP,
database_id = SAMPLE_DB_ID,
} = {}) => {
if (typeof schemas !== "object") {
throw new Error("`schemas` must be an object!");
}
......
import { SAMPLE_DB_ID } from "__support__/e2e/cypress_data";
export function adhocQuestionHash(question) {
if (question.display) {
// without "locking" the display, the QB will run its picking logic and override the setting
......@@ -32,7 +34,7 @@ export function visitQuestionAdhoc(question, { callback, mode } = {}) {
* @param {{database:number, table: number, mode: (undefined|"notebook"), limit: number, callback: function}} config
*/
export function openTable({
database = 1,
database = SAMPLE_DB_ID,
table,
mode = null,
limit,
......@@ -74,7 +76,7 @@ function getInterceptDetails(question, mode) {
// Therefore, there is no `dataset` to wait for.
// But we need to make sure the schema for our database is loaded before we can proceed.
if (mode === "notebook") {
return ["/api/database/1/schema/PUBLIC", "publicSchema"];
return [`/api/database/${SAMPLE_DB_ID}/schema/PUBLIC`, "publicSchema"];
}
const {
......
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