mirror of https://github.com/docusealco/docuseal
parent
a44531c6a7
commit
1b6aa56757
@ -1,20 +1,10 @@
|
||||
<div class="form-control">
|
||||
<%= f.label :role, class: 'label' %>
|
||||
<%= f.select :role, nil, {}, class: 'base-select' do %>
|
||||
<option value="admin"><%= t('admin') %></option>
|
||||
<option value="editor" disabled><%= t('editor') %></option>
|
||||
<option value="viewer" disabled><%= t('viewer') %></option>
|
||||
<% end %>
|
||||
<% if Docuseal.multitenant? %>
|
||||
<%= f.select :role,
|
||||
User::ROLES.map { |r| [t(r, default: r.titleize), r] },
|
||||
{},
|
||||
class: 'base-select' %>
|
||||
<label class="label">
|
||||
<span class="label-text-alt">
|
||||
<%= t('click_here_to_learn_more_about_user_roles_and_permissions_html') %>
|
||||
</span>
|
||||
<span class="label-text-alt"><%= t('user_role_help') %></span>
|
||||
</label>
|
||||
<% end %>
|
||||
<a class="text-sm mt-3 px-4 py-2 bg-base-300 rounded-full block" target="_blank" href="<%= Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}/plans") : "#{Docuseal::CLOUD_URL}/sign_up?#{{ redir: "#{Docuseal::CONSOLE_URL}/on_premises" }.to_query}" %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4 inline align-text-bottom') %>
|
||||
<%= t('unlock_more_user_roles_with_docuseal_pro') %>
|
||||
<span class="link font-medium"><%= t('learn_more') %></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { loginAs, loginAsAdmin, adminEmail, adminPassword } from './helpers/auth';
|
||||
|
||||
// Phase 1.1 — User roles (admin / editor / viewer)
|
||||
// Pre-seeded users required in target env:
|
||||
// - editor@example.com / password (role: editor)
|
||||
// - viewer@example.com / password (role: viewer)
|
||||
|
||||
const editorEmail = process.env.DOCUSEAL_EDITOR_EMAIL || 'editor@example.com';
|
||||
const viewerEmail = process.env.DOCUSEAL_VIEWER_EMAIL || 'viewer@example.com';
|
||||
const defaultPassword = process.env.DOCUSEAL_DEFAULT_PASSWORD || 'password';
|
||||
|
||||
test.describe('User roles', () => {
|
||||
test('admin sees New Template button', async ({ page }) => {
|
||||
await loginAs(page, adminEmail, adminPassword);
|
||||
await page.goto('/');
|
||||
await expect(page.getByRole('link', { name: /new template|create/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('editor can access templates but not account settings', async ({ page }) => {
|
||||
await loginAs(page, editorEmail, defaultPassword);
|
||||
await page.goto('/templates');
|
||||
await expect(page).toHaveURL(/templates|^\//);
|
||||
|
||||
await page.goto('/settings/account');
|
||||
// Editor is denied write access; expect redirect or forbidden copy.
|
||||
await expect(page).not.toHaveURL(/\/settings\/account(?:$|\?)/);
|
||||
});
|
||||
|
||||
test('viewer cannot see New Template / create controls', async ({ page }) => {
|
||||
await loginAs(page, viewerEmail, defaultPassword);
|
||||
await page.goto('/templates');
|
||||
await expect(page.getByRole('link', { name: /new template/i })).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in new issue