Skip to content
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
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
124 changes: 62 additions & 62 deletions e2e/tests/auth/auth.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/// <reference types="cypress" />

const contextPath = process.env.QDB_HTTP_CONTEXT_WEB_CONSOLE || "";
const baseUrl = `http://localhost:9999${contextPath}`;
const contextPath = process.env.QDB_HTTP_CONTEXT_WEB_CONSOLE || ""
const baseUrl = `http://localhost:9999${contextPath}`

const interceptSettings = (payload) => {
cy.intercept({ method: "GET", url: `${baseUrl}/settings` }, payload).as(
"settings"
);
};
"settings",
)
}

describe("OSS", () => {
before(() => {
Expand All @@ -16,15 +16,15 @@ describe("OSS", () => {
"release.type": "OSS",
"release.version": "1.2.3",
},
});
cy.visit(baseUrl);
});
})
cy.visit(baseUrl)
})

it("should display the console", () => {
cy.wait("@settings");
cy.getEditor().should("be.visible");
});
});
cy.wait("@settings")
cy.getEditor().should("be.visible")
})
})

describe("Auth - UI", () => {
before(() => {
Expand All @@ -41,16 +41,16 @@ describe("Auth - UI", () => {
"acl.oidc.pkce.required": null,
"acl.oidc.groups.encoded.in.token": false,
},
});
cy.visit(baseUrl);
});
})
cy.visit(baseUrl)
})

it("should display UI auth", () => {
cy.wait("@settings");
cy.getByDataHook("auth-login").should("be.visible");
cy.getEditor().should("not.exist");
});
});
cy.wait("@settings")
cy.getByDataHook("auth-login").should("be.visible")
cy.getEditor().should("not.exist")
})
})

describe("Auth - OIDC", () => {
before(() => {
Expand All @@ -67,17 +67,17 @@ describe("Auth - OIDC", () => {
"acl.oidc.pkce.required": true,
"acl.oidc.groups.encoded.in.token": false,
},
});
cy.visit(baseUrl);
});
})
cy.visit(baseUrl)
})

it("should display UI auth with OIDC support", () => {
cy.wait("@settings");
cy.getByDataHook("auth-login").should("be.visible");
cy.getByDataHook("button-sso-login").should("be.visible");
cy.getEditor().should("not.exist");
});
});
cy.wait("@settings")
cy.getByDataHook("auth-login").should("be.visible")
cy.getByDataHook("button-sso-login").should("be.visible")
cy.getEditor().should("not.exist")
})
})

describe("Auth - Basic", () => {
before(() => {
Expand All @@ -94,15 +94,15 @@ describe("Auth - Basic", () => {
"acl.oidc.pkce.required": null,
"acl.oidc.groups.encoded.in.token": false,
},
});
cy.visit(baseUrl);
});
})
cy.visit(baseUrl)
})

it("should display the console", () => {
cy.wait("@settings");
cy.getEditor().should("be.visible");
});
});
cy.wait("@settings")
cy.getEditor().should("be.visible")
})
})

describe("Auth - Disabled", () => {
before(() => {
Expand All @@ -119,15 +119,15 @@ describe("Auth - Disabled", () => {
"acl.oidc.pkce.required": null,
"acl.oidc.groups.encoded.in.token": false,
},
});
cy.visit(baseUrl);
});
})
cy.visit(baseUrl)
})

it("should display the console", () => {
cy.wait("@settings");
cy.getEditor().should("be.visible");
});
});
cy.wait("@settings")
cy.getEditor().should("be.visible")
})
})

describe("Auth - Session Parameter (OAuth)", () => {
describe("OAuth Login with session=true", () => {
Expand All @@ -145,8 +145,8 @@ describe("Auth - Session Parameter (OAuth)", () => {
"acl.oidc.pkce.required": true,
"acl.oidc.groups.encoded.in.token": false,
},
});
});
})
})

it("should call exec with session=true after OAuth token exchange", () => {
cy.intercept(
Expand All @@ -155,8 +155,8 @@ describe("Auth - Session Parameter (OAuth)", () => {
url: `${baseUrl}/exec?query=select%202&session=true`,
},
(req) => {
expect(req.headers).to.have.property("authorization");
expect(req.headers.authorization).to.match(/^Bearer /);
expect(req.headers).to.have.property("authorization")
expect(req.headers.authorization).to.match(/^Bearer /)

req.reply({
statusCode: 200,
Expand All @@ -169,9 +169,9 @@ describe("Auth - Session Parameter (OAuth)", () => {
dataset: [[2]],
count: 1,
},
});
}
).as("oauthSessionStart");
})
},
).as("oauthSessionStart")

cy.intercept(
{
Expand All @@ -185,18 +185,18 @@ describe("Auth - Session Parameter (OAuth)", () => {
token_type: "Bearer",
expires_in: 3600,
},
}
).as("tokenExchange");
},
).as("tokenExchange")

cy.visit(`${baseUrl}?code=test-auth-code&state=test-state`);
cy.wait("@settings");
cy.visit(`${baseUrl}?code=test-auth-code&state=test-state`)
cy.wait("@settings")

cy.wait("@tokenExchange");
cy.wait("@tokenExchange")
cy.wait("@oauthSessionStart").then((interception) => {
expect(interception.request.url).to.include("session=true");
expect(interception.request.url).to.include("select%202");
expect(interception.response.headers).to.have.property("set-cookie");
});
});
});
});
expect(interception.request.url).to.include("session=true")
expect(interception.request.url).to.include("select%202")
expect(interception.response.headers).to.have.property("set-cookie")
})
})
})
})
94 changes: 47 additions & 47 deletions e2e/tests/console/download.spec.js
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
describe("download functionality", () => {
beforeEach(() => {
cy.loadConsoleWithAuth();
});
cy.loadConsoleWithAuth()
})

it("should show download button with results", () => {
// When
cy.typeQuery("select x from long_sequence(10)");
cy.runLine();
cy.typeQuery("select x from long_sequence(10)")
cy.runLine()

// Then
cy.getByDataHook("download-parquet-button").should("be.visible");
cy.getByDataHook("download-dropdown-button").should("be.visible");
cy.getByDataHook("download-csv-button").should("not.exist");
cy.getByDataHook("download-parquet-button").should("be.visible")
cy.getByDataHook("download-dropdown-button").should("be.visible")
cy.getByDataHook("download-csv-button").should("not.exist")

// When
cy.getByDataHook("download-dropdown-button").click();
cy.getByDataHook("download-dropdown-button").click()

// Then
cy.getByDataHook("download-csv-button").should("be.visible");
});
cy.getByDataHook("download-csv-button").should("be.visible")
})

it("should trigger CSV download", () => {
const query = "select x from long_sequence(10)";
const query = "select x from long_sequence(10)"

// Given
cy.intercept("GET", "**/exp?*", (req) => {
req.reply({
statusCode: 200,
body: null,
});
}).as("exportRequest");
})
}).as("exportRequest")

// When
cy.typeQuery(query);
cy.runLine();
cy.getByDataHook("download-dropdown-button").click();
cy.getByDataHook("download-csv-button").click();
cy.typeQuery(query)
cy.runLine()
cy.getByDataHook("download-dropdown-button").click()
cy.getByDataHook("download-csv-button").click()

// Then
cy.wait("@exportRequest").then((interception) => {
expect(interception.request.url).to.include("fmt=csv");
expect(interception.request.url).to.include("fmt=csv")
expect(interception.request.url).to.include(
encodeURIComponent(query.replace(/\s+/g, " "))
);
});
});
encodeURIComponent(query.replace(/\s+/g, " ")),
)
})
})

it("should trigger Parquet download", () => {
const query = "select x from long_sequence(10)";
const query = "select x from long_sequence(10)"

// Given
cy.intercept("GET", "**/exp?*", (req) => {
req.reply({
statusCode: 200,
body: null,
});
}).as("exportRequest");
})
}).as("exportRequest")

// When
cy.typeQuery(query);
cy.runLine();
cy.getByDataHook("download-parquet-button").click();
cy.typeQuery(query)
cy.runLine()
cy.getByDataHook("download-parquet-button").click()

// Then
cy.wait("@exportRequest").then((interception) => {
expect(interception.request.url).to.include("fmt=parquet");
expect(interception.request.url).to.include("rmode=nodelay");
expect(interception.request.url).to.include("fmt=parquet")
expect(interception.request.url).to.include("rmode=nodelay")
expect(interception.request.url).to.include(
encodeURIComponent(query.replace(/\s+/g, " "))
);
});
});
encodeURIComponent(query.replace(/\s+/g, " ")),
)
})
})

it("should show error toast on bad request", () => {
// Given
cy.intercept("GET", "**/exp?*", (req) => {
const url = new URL(req.url);
url.searchParams.set("query", "badquery");
req.url = url.toString();
}).as("badExportRequest");
const url = new URL(req.url)
url.searchParams.set("query", "badquery")
req.url = url.toString()
}).as("badExportRequest")

// When
cy.typeQuery("select x from long_sequence(5)");
cy.runLine();
cy.getByDataHook("download-dropdown-button").click();
cy.getByDataHook("download-csv-button").click();
cy.typeQuery("select x from long_sequence(5)")
cy.runLine()
cy.getByDataHook("download-dropdown-button").click()
cy.getByDataHook("download-csv-button").click()

// Then
cy.wait("@badExportRequest").then(() => {
cy.getByRole("alert").should(
"contain",
"An error occurred while downloading the file: table does not exist [table=badquery]"
);
});
});
});
"An error occurred while downloading the file: table does not exist [table=badquery]",
)
})
})
})
Loading