-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129805 from xinhaoz/backport24.1-128856
release-24.1: ui: use status server apis for stmt bundle ops
- Loading branch information
Showing
7 changed files
with
227 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
pkg/ui/workspaces/e2e-tests/cypress/e2e/statementBundles/statementBundles.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import { SQLPrivilege } from "../../support/types"; | ||
|
||
// TODO (xinhaoz): This test currently only works when running pnpm run cy:run | ||
// directly against a local cluster set up with sql activity in the last hour | ||
// and the expected cypress users in fixtures. We need to automate this server | ||
// setup for e2e testing. | ||
describe("statement bundles", () => { | ||
const runTestsForPrivilegedUser = (privilege: SQLPrivilege) => { | ||
describe(`${privilege} user`, () => { | ||
beforeEach(() => { | ||
cy.getUserWithExactPrivileges([privilege]).then((user) => { | ||
cy.login(user.username, user.password); | ||
}); | ||
}); | ||
|
||
it("can request statement bundles", () => { | ||
cy.visit("#/sql-activity"); | ||
cy.contains("button", "Apply").click(); | ||
// Open modal. | ||
cy.contains("button", "Activate").click(); | ||
// Wait for modal. | ||
cy.findByText(/activate statement diagnostics/i).should("be.visible"); | ||
// Click the Activate button within the modal | ||
cy.get(`[role="dialog"]`) // Adjust this selector to match your modal's structure | ||
.contains("button", "Activate") | ||
.click(); | ||
cy.findByText(/statement diagnostics were successfully activated/i); | ||
}); | ||
|
||
it("can view statement bundles", () => { | ||
cy.visit("#/reports/statements/diagnosticshistory"); | ||
cy.get("table tbody tr").should("have.length.at.least", 1); | ||
}); | ||
|
||
it("can cancel statement bundles", () => { | ||
cy.visit("#/reports/statements/diagnosticshistory"); | ||
cy.get("table tbody tr").should("have.length.at.least", 1); | ||
cy.contains("button", "Cancel").click(); | ||
cy.findByText(/statement diagnostics were successfully cancelled/i); | ||
}); | ||
}); | ||
}; | ||
|
||
const runTestsForNonPrivilegedUser = (privilege?: SQLPrivilege) => { | ||
beforeEach(() => { | ||
cy.getUserWithExactPrivileges(privilege ? [privilege] : []).then( | ||
(user) => { | ||
cy.login(user.username, user.password); | ||
}, | ||
); | ||
}); | ||
|
||
it("cannot request statement bundles", () => { | ||
cy.visit("#/sql-activity"); | ||
cy.contains("button", "Apply").click(); | ||
// Should not see an Activate button. | ||
cy.contains("button", "Activate").should("not.exist"); | ||
}); | ||
|
||
it("cannot view statement bundles", () => { | ||
cy.visit("#/reports/statements/diagnosticshistory"); | ||
cy.findByText(/no statement diagnostics to show/i); | ||
}); | ||
}; | ||
|
||
describe("view activity user", () => { | ||
runTestsForPrivilegedUser(SQLPrivilege.VIEWACTIVITY); | ||
}); | ||
|
||
describe("admin user", () => { | ||
runTestsForPrivilegedUser(SQLPrivilege.ADMIN); | ||
}); | ||
|
||
describe("non-privileged VIEWACTIVITYREDACTED user", () => { | ||
runTestsForNonPrivilegedUser(SQLPrivilege.VIEWACTIVITYREDACTED); | ||
}); | ||
|
||
describe("non-privileged user", () => { | ||
runTestsForNonPrivilegedUser(); | ||
}); | ||
}); |
Oops, something went wrong.