Files
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign).
Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files)
and align docker/Dockerfile turbo --scope/--filter to the actual remix
package name @hanzo/esign (was a pre-existing mismatch with -remix that
broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
2026-06-21 19:56:09 -07:00

91 lines
2.7 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { createDocumentAuthOptions } from '@hanzo/esign-lib/utils/document-auth';
import { prisma } from '@hanzo/esign-prisma';
import { seedPendingDocument } from '@hanzo/esign-prisma/seed/documents';
import { seedUser } from '@hanzo/esign-prisma/seed/users';
import { apiSignin } from '../fixtures/authentication';
test('[DOCUMENT_AUTH]: should grant access when not required', async ({ page }) => {
const { user, team } = await seedUser();
const { user: recipientWithAccount } = await seedUser();
const document = await seedPendingDocument(user, team.id, [
recipientWithAccount,
'[email protected]',
]);
const recipients = await prisma.recipient.findMany({
where: {
envelopeId: document.id,
},
});
const tokens = recipients.map((recipient) => recipient.token);
for (const token of tokens) {
await page.goto(`/sign/${token}`);
await expect(page.getByRole('heading', { name: 'Sign Document' })).toBeVisible();
}
});
test('[DOCUMENT_AUTH]: should allow or deny access when required', async ({ page }) => {
const { user, team } = await seedUser();
const { user: recipientWithAccount } = await seedUser();
const document = await seedPendingDocument(
user,
team.id,
[recipientWithAccount, '[email protected]'],
{
createDocumentOptions: {
authOptions: createDocumentAuthOptions({
globalAccessAuth: ['ACCOUNT'],
globalActionAuth: [],
}),
},
},
);
const recipients = await prisma.recipient.findMany({
where: {
envelopeId: document.id,
},
});
// Check that both are denied access.
for (const recipient of recipients) {
const { email, token } = recipient;
await page.goto(`/sign/${token}`);
await expect(page.getByRole('heading', { name: 'Authentication required' })).toBeVisible();
await expect(page.getByRole('paragraph')).toContainText(email);
}
await apiSignin({
page,
email: recipientWithAccount.email,
});
// Check that the one logged in is granted access.
for (const recipient of recipients) {
const { email, token } = recipient;
await page.goto(`/sign/${token}`);
// Recipient should be granted access.
if (recipient.email === recipientWithAccount.email) {
await expect(page.getByRole('heading', { name: 'Sign Document' })).toBeVisible();
}
// Recipient should still be denied.
if (recipient.email !== recipientWithAccount.email) {
await expect(page.getByRole('heading', { name: 'Authentication required' })).toBeVisible();
await expect(page.getByRole('paragraph')).toContainText(email);
}
}
});