diff --git a/packages/manager/.changeset/pr-11912-tests-1743006972477.md b/packages/manager/.changeset/pr-11912-tests-1743006972477.md
new file mode 100644
index 00000000000..eb810b5b1d3
--- /dev/null
+++ b/packages/manager/.changeset/pr-11912-tests-1743006972477.md
@@ -0,0 +1,5 @@
+---
+"@linode/manager": Tests
+---
+
+Tests for restricted user on database page ([#11912](https://github.com/linode/manager/pull/11912))
diff --git a/packages/manager/cypress/e2e/core/databases/create-database.spec.ts b/packages/manager/cypress/e2e/core/databases/create-database.spec.ts
index db6a3dee064..d053ff241fb 100644
--- a/packages/manager/cypress/e2e/core/databases/create-database.spec.ts
+++ b/packages/manager/cypress/e2e/core/databases/create-database.spec.ts
@@ -3,7 +3,7 @@ import {
mockDatabaseEngineTypes,
mockDatabaseNodeTypes,
} from 'support/constants/databases';
-import { mockGetAccount } from 'support/intercepts/account';
+import { mockGetAccount, mockGetUser } from 'support/intercepts/account';
import {
mockCreateDatabase,
mockGetDatabaseEngines,
@@ -11,10 +11,22 @@ import {
mockGetDatabases,
} from 'support/intercepts/databases';
import { mockGetEvents } from 'support/intercepts/events';
+import {
+ mockGetProfile,
+ mockGetProfileGrants,
+} from 'support/intercepts/profile';
import { ui } from 'support/ui';
+import { randomLabel } from 'support/util/random';
import { getRegionById } from 'support/util/regions';
-import { accountFactory, databaseFactory, eventFactory } from 'src/factories';
+import {
+ accountFactory,
+ accountUserFactory,
+ databaseFactory,
+ eventFactory,
+ grantsFactory,
+ profileFactory,
+} from 'src/factories';
import type { Database } from '@linode/api-v4';
import type { databaseClusterConfiguration } from 'support/constants/databases';
@@ -158,3 +170,80 @@ describe('create a database cluster, mocked data', () => {
}
);
});
+
+describe('restricted user cannot create database', () => {
+ beforeEach(() => {
+ // Mock setup for user profile, account user, and user grants with restricted permissions,
+ const mockProfile = profileFactory.build({
+ restricted: true,
+ username: randomLabel(),
+ });
+
+ const mockUser = accountUserFactory.build({
+ restricted: true,
+ user_type: 'default',
+ username: mockProfile.username,
+ });
+
+ const mockGrants = grantsFactory.build({
+ global: {
+ add_databases: false,
+ },
+ });
+
+ mockGetProfile(mockProfile);
+ mockGetProfileGrants(mockGrants);
+ mockGetUser(mockUser);
+ mockGetDatabases([]).as('getDatabases');
+ });
+ it('cannot create database on landing page', () => {
+ // Login and wait for application to load
+ cy.visitWithLogin('/databases');
+ cy.wait('@getDatabases');
+ // Assert that Create Database button is visible and disabled
+ ui.button
+ .findByTitle('Create Database Cluster')
+ .should('be.visible')
+ .and('be.disabled')
+ .trigger('mouseover');
+
+ // Assert that tooltip is visible with message
+ ui.tooltip
+ .findByText(
+ "You don't have permissions to create Databases. Please contact your account administrator to request the necessary permissions."
+ )
+ .should('be.visible');
+
+ // table not present for restricted user
+ cy.get('table[aria-label="Database Clusters"]').should('not.exist');
+ // link to Docs should exist
+ cy.findByText('Getting Started Guides').should('be.visible');
+ cy.findByText('Video Playlist').should('be.visible');
+ });
+
+ it('cannot create database from Create menu', () => {
+ // Login and wait for application to load
+ cy.visitWithLogin('/databases/create');
+
+ // table present for restricted user but its inputs will be disabled
+ cy.get('table[aria-label="List of Linode Plans"]').should('exist');
+ // Assert that Create Database button is visible and disabled
+ ui.button
+ .findByTitle('Create Database Cluster')
+ .should('be.visible')
+ .and('be.disabled')
+ .trigger('mouseover');
+
+ // Info message is visible
+ cy.findByText(
+ "You don't have permissions to create this Database. Please contact your account administrator to request the necessary permissions."
+ );
+
+ // all form inputs are disabled
+ cy.get('[data-testid="db-create-form"]').within(() => {
+ cy.get('input').each((input) => {
+ cy.wrap(input).should('be.disabled');
+ });
+ });
+ });
+});
diff --git a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx
index 17c953b0301..6ddb8c98abd 100644
--- a/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx
+++ b/packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreate.tsx
@@ -280,7 +280,7 @@ const DatabaseCreate = () => {
return (
<>