Skip to content

Commit 5a32d0f

Browse files
authored
chore: fix lint errors, add lint check pre-commit hook (#494)
* init * fix all lint issues * add precommit hook for linting * submodule * use correct field name * add e2e tests to linting, fix prettier errors * error color * submodule
1 parent c9c64a8 commit 5a32d0f

File tree

172 files changed

+8322
-6412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+8322
-6412
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn lint-staged

e2e/tests/auth/auth.spec.js

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/// <reference types="cypress" />
22

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

66
const interceptSettings = (payload) => {
77
cy.intercept({ method: "GET", url: `${baseUrl}/settings` }, payload).as(
8-
"settings"
9-
);
10-
};
8+
"settings",
9+
)
10+
}
1111

1212
describe("OSS", () => {
1313
before(() => {
@@ -16,15 +16,15 @@ describe("OSS", () => {
1616
"release.type": "OSS",
1717
"release.version": "1.2.3",
1818
},
19-
});
20-
cy.visit(baseUrl);
21-
});
19+
})
20+
cy.visit(baseUrl)
21+
})
2222

2323
it("should display the console", () => {
24-
cy.wait("@settings");
25-
cy.getEditor().should("be.visible");
26-
});
27-
});
24+
cy.wait("@settings")
25+
cy.getEditor().should("be.visible")
26+
})
27+
})
2828

2929
describe("Auth - UI", () => {
3030
before(() => {
@@ -41,16 +41,16 @@ describe("Auth - UI", () => {
4141
"acl.oidc.pkce.required": null,
4242
"acl.oidc.groups.encoded.in.token": false,
4343
},
44-
});
45-
cy.visit(baseUrl);
46-
});
44+
})
45+
cy.visit(baseUrl)
46+
})
4747

4848
it("should display UI auth", () => {
49-
cy.wait("@settings");
50-
cy.getByDataHook("auth-login").should("be.visible");
51-
cy.getEditor().should("not.exist");
52-
});
53-
});
49+
cy.wait("@settings")
50+
cy.getByDataHook("auth-login").should("be.visible")
51+
cy.getEditor().should("not.exist")
52+
})
53+
})
5454

5555
describe("Auth - OIDC", () => {
5656
before(() => {
@@ -67,17 +67,17 @@ describe("Auth - OIDC", () => {
6767
"acl.oidc.pkce.required": true,
6868
"acl.oidc.groups.encoded.in.token": false,
6969
},
70-
});
71-
cy.visit(baseUrl);
72-
});
70+
})
71+
cy.visit(baseUrl)
72+
})
7373

7474
it("should display UI auth with OIDC support", () => {
75-
cy.wait("@settings");
76-
cy.getByDataHook("auth-login").should("be.visible");
77-
cy.getByDataHook("button-sso-login").should("be.visible");
78-
cy.getEditor().should("not.exist");
79-
});
80-
});
75+
cy.wait("@settings")
76+
cy.getByDataHook("auth-login").should("be.visible")
77+
cy.getByDataHook("button-sso-login").should("be.visible")
78+
cy.getEditor().should("not.exist")
79+
})
80+
})
8181

8282
describe("Auth - Basic", () => {
8383
before(() => {
@@ -94,15 +94,15 @@ describe("Auth - Basic", () => {
9494
"acl.oidc.pkce.required": null,
9595
"acl.oidc.groups.encoded.in.token": false,
9696
},
97-
});
98-
cy.visit(baseUrl);
99-
});
97+
})
98+
cy.visit(baseUrl)
99+
})
100100

101101
it("should display the console", () => {
102-
cy.wait("@settings");
103-
cy.getEditor().should("be.visible");
104-
});
105-
});
102+
cy.wait("@settings")
103+
cy.getEditor().should("be.visible")
104+
})
105+
})
106106

107107
describe("Auth - Disabled", () => {
108108
before(() => {
@@ -119,15 +119,15 @@ describe("Auth - Disabled", () => {
119119
"acl.oidc.pkce.required": null,
120120
"acl.oidc.groups.encoded.in.token": false,
121121
},
122-
});
123-
cy.visit(baseUrl);
124-
});
122+
})
123+
cy.visit(baseUrl)
124+
})
125125

126126
it("should display the console", () => {
127-
cy.wait("@settings");
128-
cy.getEditor().should("be.visible");
129-
});
130-
});
127+
cy.wait("@settings")
128+
cy.getEditor().should("be.visible")
129+
})
130+
})
131131

132132
describe("Auth - Session Parameter (OAuth)", () => {
133133
describe("OAuth Login with session=true", () => {
@@ -145,8 +145,8 @@ describe("Auth - Session Parameter (OAuth)", () => {
145145
"acl.oidc.pkce.required": true,
146146
"acl.oidc.groups.encoded.in.token": false,
147147
},
148-
});
149-
});
148+
})
149+
})
150150

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

161161
req.reply({
162162
statusCode: 200,
@@ -169,9 +169,9 @@ describe("Auth - Session Parameter (OAuth)", () => {
169169
dataset: [[2]],
170170
count: 1,
171171
},
172-
});
173-
}
174-
).as("oauthSessionStart");
172+
})
173+
},
174+
).as("oauthSessionStart")
175175

176176
cy.intercept(
177177
{
@@ -185,18 +185,18 @@ describe("Auth - Session Parameter (OAuth)", () => {
185185
token_type: "Bearer",
186186
expires_in: 3600,
187187
},
188-
}
189-
).as("tokenExchange");
188+
},
189+
).as("tokenExchange")
190190

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

194-
cy.wait("@tokenExchange");
194+
cy.wait("@tokenExchange")
195195
cy.wait("@oauthSessionStart").then((interception) => {
196-
expect(interception.request.url).to.include("session=true");
197-
expect(interception.request.url).to.include("select%202");
198-
expect(interception.response.headers).to.have.property("set-cookie");
199-
});
200-
});
201-
});
202-
});
196+
expect(interception.request.url).to.include("session=true")
197+
expect(interception.request.url).to.include("select%202")
198+
expect(interception.response.headers).to.have.property("set-cookie")
199+
})
200+
})
201+
})
202+
})

e2e/tests/console/download.spec.js

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
11
describe("download functionality", () => {
22
beforeEach(() => {
3-
cy.loadConsoleWithAuth();
4-
});
3+
cy.loadConsoleWithAuth()
4+
})
55

66
it("should show download button with results", () => {
77
// When
8-
cy.typeQuery("select x from long_sequence(10)");
9-
cy.runLine();
8+
cy.typeQuery("select x from long_sequence(10)")
9+
cy.runLine()
1010

1111
// Then
12-
cy.getByDataHook("download-parquet-button").should("be.visible");
13-
cy.getByDataHook("download-dropdown-button").should("be.visible");
14-
cy.getByDataHook("download-csv-button").should("not.exist");
12+
cy.getByDataHook("download-parquet-button").should("be.visible")
13+
cy.getByDataHook("download-dropdown-button").should("be.visible")
14+
cy.getByDataHook("download-csv-button").should("not.exist")
1515

1616
// When
17-
cy.getByDataHook("download-dropdown-button").click();
17+
cy.getByDataHook("download-dropdown-button").click()
1818

1919
// Then
20-
cy.getByDataHook("download-csv-button").should("be.visible");
21-
});
20+
cy.getByDataHook("download-csv-button").should("be.visible")
21+
})
2222

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

2626
// Given
2727
cy.intercept("GET", "**/exp?*", (req) => {
2828
req.reply({
2929
statusCode: 200,
3030
body: null,
31-
});
32-
}).as("exportRequest");
31+
})
32+
}).as("exportRequest")
3333

3434
// When
35-
cy.typeQuery(query);
36-
cy.runLine();
37-
cy.getByDataHook("download-dropdown-button").click();
38-
cy.getByDataHook("download-csv-button").click();
35+
cy.typeQuery(query)
36+
cy.runLine()
37+
cy.getByDataHook("download-dropdown-button").click()
38+
cy.getByDataHook("download-csv-button").click()
3939

4040
// Then
4141
cy.wait("@exportRequest").then((interception) => {
42-
expect(interception.request.url).to.include("fmt=csv");
42+
expect(interception.request.url).to.include("fmt=csv")
4343
expect(interception.request.url).to.include(
44-
encodeURIComponent(query.replace(/\s+/g, " "))
45-
);
46-
});
47-
});
44+
encodeURIComponent(query.replace(/\s+/g, " ")),
45+
)
46+
})
47+
})
4848

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

5252
// Given
5353
cy.intercept("GET", "**/exp?*", (req) => {
5454
req.reply({
5555
statusCode: 200,
5656
body: null,
57-
});
58-
}).as("exportRequest");
57+
})
58+
}).as("exportRequest")
5959

6060
// When
61-
cy.typeQuery(query);
62-
cy.runLine();
63-
cy.getByDataHook("download-parquet-button").click();
61+
cy.typeQuery(query)
62+
cy.runLine()
63+
cy.getByDataHook("download-parquet-button").click()
6464

6565
// Then
6666
cy.wait("@exportRequest").then((interception) => {
67-
expect(interception.request.url).to.include("fmt=parquet");
68-
expect(interception.request.url).to.include("rmode=nodelay");
67+
expect(interception.request.url).to.include("fmt=parquet")
68+
expect(interception.request.url).to.include("rmode=nodelay")
6969
expect(interception.request.url).to.include(
70-
encodeURIComponent(query.replace(/\s+/g, " "))
71-
);
72-
});
73-
});
70+
encodeURIComponent(query.replace(/\s+/g, " ")),
71+
)
72+
})
73+
})
7474

7575
it("should show error toast on bad request", () => {
7676
// Given
7777
cy.intercept("GET", "**/exp?*", (req) => {
78-
const url = new URL(req.url);
79-
url.searchParams.set("query", "badquery");
80-
req.url = url.toString();
81-
}).as("badExportRequest");
78+
const url = new URL(req.url)
79+
url.searchParams.set("query", "badquery")
80+
req.url = url.toString()
81+
}).as("badExportRequest")
8282

8383
// When
84-
cy.typeQuery("select x from long_sequence(5)");
85-
cy.runLine();
86-
cy.getByDataHook("download-dropdown-button").click();
87-
cy.getByDataHook("download-csv-button").click();
84+
cy.typeQuery("select x from long_sequence(5)")
85+
cy.runLine()
86+
cy.getByDataHook("download-dropdown-button").click()
87+
cy.getByDataHook("download-csv-button").click()
8888

8989
// Then
9090
cy.wait("@badExportRequest").then(() => {
9191
cy.getByRole("alert").should(
9292
"contain",
93-
"An error occurred while downloading the file: table does not exist [table=badquery]"
94-
);
95-
});
96-
});
97-
});
93+
"An error occurred while downloading the file: table does not exist [table=badquery]",
94+
)
95+
})
96+
})
97+
})

0 commit comments

Comments
 (0)