Skip to content

Commit

Permalink
chore: added dashboard test in tilt
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth committed Nov 9, 2023
1 parent 8a5c42f commit e7715ee
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/dashboard/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_AUTH_SESSION_TOKEN=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..fnJyx2BxWbwpS29F.TqoLx8IPoVJZW9pBECH5uc_LlAjGyYtOkyRXyL9wuCvJ9LcDNkXm3I_QYSoOnSZ_V2kKgGO90A-SDNGyz749UBZcvq7Nu_eLc5_cUDUKDxoa1_rmdSAtjShpoS3VUqBBMyBzOhCl8V2gxqwZWI7hnJQo545eQRulQhZDiSWYvTQK1_e8_sTPi1gax9QgrGRM2gJqvEtrKl2dugGHF18WmlY20Q7QkaGUs32bzOPw9hhL2GT8d8IRiXsq5KnYBvhFGKJV1teUOTKL6OFkuDruMwuTJi66ToX1YQLIkhrqBSAhrXlN1YxAKX0lnmBEhJlaEGlB56_hKQWDWQPGMbYhCOYouQM5qGivIBegN9D8MDs2I6lQJJVZkuILHsE4fNnzQ6j2BtMigWvCJsrAvmwntxySgvrbGPMIUnz1Cdb8u_Rm5mzvYIAJTQ5b0N-_Pf3zqX9T4sElRGF-i6DSoMYhbkoCgxigJ_qsr-VCP6l3lzD-WSc.d5HZomcq9nPlUYX7ojfbWQ
1 change: 1 addition & 0 deletions apps/dashboard/BUCK
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load(
"@toolchains//workspace-pnpm:macros.bzl",
"dev_pnpm_task_binary",
"dev_pnpm_task_test",
"build_node_modules",
"next_build",
"next_build_bin",
Expand Down
6 changes: 5 additions & 1 deletion apps/dashboard/components/api-keys/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const ApiKeyCreate = () => {
>
<Typography>Name</Typography>
<Input
data-testid="create-api-name-input"
name="apiKeyName"
id="apiKeyName"
sx={{
Expand All @@ -205,6 +206,7 @@ const ApiKeyCreate = () => {
sx={{ display: "none", padding: "0.6em" }}
/>
<Select
data-testid="create-api-expire-select"
sx={{
padding: "0.6em",
}}
Expand All @@ -217,7 +219,9 @@ const ApiKeyCreate = () => {
if (v && v !== "custom") setExpiresInDays(parseInt(String(v)))
}}
>
<Option value="30">30 days</Option>
<Option data-testid="create-api-expire-30-days-select" value="30">
30 days
</Option>
<Option value="90">90 days</Option>
<Option value="custom">Custom</Option>
</Select>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "cypress"
import dotenv from "dotenv"

dotenv.config({ path: "../../dev/.dashboard-test.env" })
dotenv.config({ path: ".env.test" })

export default defineConfig({
e2e: {
Expand Down
21 changes: 21 additions & 0 deletions apps/dashboard/cypress/e2e/api-keys/api-keys.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { testData } from "../../support/test-data"

describe("Callback Test", () => {
beforeEach(() => {
cy.setCookie("next-auth.session-token", testData.NEXT_AUTH_SESSION_TOKEN, {
secure: true,
})
cy.visit("/")

cy.get("[data-testid=sidebar-api-keys-link]").click()
})

it("Api Key creation Test", () => {
cy.get('[data-testid="create-api-add-btn"]').click()
cy.get('[data-testid="create-api-name-input"]').type("New API Key")
cy.get('[data-testid="create-api-expire-select"]').click()
cy.get('[data-testid="create-api-expire-30-days-select"]').click()
cy.get('[data-testid="create-api-create-btn"]').click()
cy.get('[data-testid="create-api-close-btn"]').click()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ describe("Consent integration Test", () => {
cy.wait(5000)
cy.getCookie("next-auth.session-token").then((cookie) => {
if (cookie && cookie.value) {
cy.writeFile(
"../../../../dev/.dashboard-test.env",
`NEXT_AUTH_SESSION_TOKEN=${cookie.value}\n`,
{
flag: "w",
},
)
cy.writeFile(".env.test", `NEXT_AUTH_SESSION_TOKEN=${cookie.value}\n`, {
flag: "w",
})
cy.log("Session token saved to .env.test")
} else {
cy.log("Session token not found")
Expand Down
5 changes: 3 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "next start -p 3001",
"lint:fix": "eslint --fix --ext .ts,.tsx .",
"codegen": "graphql-codegen --config codegen.yml",
"cypress:run": "cypress run --spec './cypress/e2e/consent-intigration.cy.ts' && cypress run"
"cypress:run": "cypress run --spec './cypress/e2e/consent-integration.cy.ts' && cypress run",
"cypress:open": "cypress run --spec './cypress/e2e/consent-integration.cy.ts' && cypress open"
},
"dependencies": {
"@apollo/client": "^3.8.4",
Expand Down Expand Up @@ -61,4 +62,4 @@
"tailwindcss": "3.3.5",
"typescript": "5.2.2"
}
}
}
16 changes: 14 additions & 2 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ local_resource(
],
)

dashboard_test_target = "//apps/dashboard:test-integration"
local_resource(
"dashboard-test",
labels = ["test"],
auto_init = is_ci and "dashboard" in cfg.get("test", []),
cmd = "buck2 test {}".format(dashboard_test_target),
resource_deps = [
"dashboard",
"init-test-user",
"hydra-dashboard"
],
)

local_resource(
name='init-test-user',
labels = ['test'],
Expand Down Expand Up @@ -214,8 +227,7 @@ docker_groups = {
"apollo-router",
"mongodb",
"redis",
"svix-pg",
"svix",
"svix"
],
"bitcoin": [
"lnd1",
Expand Down

0 comments on commit e7715ee

Please sign in to comment.