fix: broken e2e tests (#1956)

This commit is contained in:
David Nguyen
2025-08-11 16:16:21 +10:00
committed by GitHub
parent b844e166a9
commit 9026aabe3b
4 changed files with 21 additions and 8 deletions

View File

@ -484,6 +484,7 @@ export function TemplateUseDialog({
<input <input
type="file" type="file"
data-testid="template-use-dialog-file-input"
className="absolute h-full w-full opacity-0" className="absolute h-full w-full opacity-0"
accept=".pdf,application/pdf" accept=".pdf,application/pdf"
onChange={(e) => { onChange={(e) => {

View File

@ -1178,13 +1178,12 @@ test.describe('Unauthorized Access - Document API V2', () => {
const { user: firstRecipientUser } = await seedUser(); const { user: firstRecipientUser } = await seedUser();
const { user: secondRecipientUser } = await seedUser(); const { user: secondRecipientUser } = await seedUser();
await prisma.template.update({ const updatedTemplate = await prisma.template.update({
where: { id: template.id }, where: { id: template.id },
data: { data: {
recipients: { recipients: {
create: [ create: [
{ {
id: firstRecipientUser.id,
name: firstRecipientUser.name || '', name: firstRecipientUser.name || '',
email: firstRecipientUser.email, email: firstRecipientUser.email,
token: nanoid(12), token: nanoid(12),
@ -1193,7 +1192,6 @@ test.describe('Unauthorized Access - Document API V2', () => {
signingStatus: SigningStatus.NOT_SIGNED, signingStatus: SigningStatus.NOT_SIGNED,
}, },
{ {
id: secondRecipientUser.id,
name: secondRecipientUser.name || '', name: secondRecipientUser.name || '',
email: secondRecipientUser.email, email: secondRecipientUser.email,
token: nanoid(12), token: nanoid(12),
@ -1204,21 +1202,35 @@ test.describe('Unauthorized Access - Document API V2', () => {
], ],
}, },
}, },
include: {
recipients: true,
},
}); });
const recipientAId = updatedTemplate.recipients.find(
(recipient) => recipient.email === firstRecipientUser.email,
)?.id;
const recipientBId = updatedTemplate.recipients.find(
(recipient) => recipient.email === secondRecipientUser.email,
)?.id;
if (!recipientAId || !recipientBId) {
throw new Error('Recipient IDs not found');
}
const res = await request.post(`${WEBAPP_BASE_URL}/api/v2-beta/template/use`, { const res = await request.post(`${WEBAPP_BASE_URL}/api/v2-beta/template/use`, {
headers: { Authorization: `Bearer ${tokenB}` }, headers: { Authorization: `Bearer ${tokenB}` },
data: { data: {
templateId: template.id, templateId: template.id,
recipients: [ recipients: [
{ {
id: firstRecipientUser.id, id: recipientAId,
name: firstRecipientUser.name, name: firstRecipientUser.name,
email: firstRecipientUser.email, email: firstRecipientUser.email,
role: RecipientRole.SIGNER, role: RecipientRole.SIGNER,
}, },
{ {
id: secondRecipientUser.id, id: recipientBId,
name: secondRecipientUser.name, name: secondRecipientUser.name,
email: secondRecipientUser.email, email: secondRecipientUser.email,
role: RecipientRole.SIGNER, role: RecipientRole.SIGNER,

View File

@ -268,7 +268,7 @@ test('[TEMPLATE]: should create a document from a template with custom document'
// Upload document. // Upload document.
const [fileChooser] = await Promise.all([ const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'), page.waitForEvent('filechooser'),
page.locator('input[type=file]').evaluate((e) => { page.getByTestId('template-use-dialog-file-input').evaluate((e) => {
if (e instanceof HTMLInputElement) { if (e instanceof HTMLInputElement) {
e.click(); e.click();
} }
@ -361,7 +361,7 @@ test('[TEMPLATE]: should create a team document from a template with custom docu
// Upload document. // Upload document.
const [fileChooser] = await Promise.all([ const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'), page.waitForEvent('filechooser'),
page.locator('input[type=file]').evaluate((e) => { page.getByTestId('template-use-dialog-file-input').evaluate((e) => {
if (e instanceof HTMLInputElement) { if (e instanceof HTMLInputElement) {
e.click(); e.click();
} }

View File

@ -96,7 +96,7 @@ export const DocumentDropzone = ({
return ( return (
<Button loading={loading} aria-disabled={disabled} {...getRootProps()} {...props}> <Button loading={loading} aria-disabled={disabled} {...getRootProps()} {...props}>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<input {...getInputProps()} /> <input data-testid="document-upload-input" {...getInputProps()} />
{!loading && <Upload className="h-4 w-4" />} {!loading && <Upload className="h-4 w-4" />}
{disabled ? _(disabledMessage) : _(heading[type])} {disabled ? _(disabledMessage) : _(heading[type])}
</div> </div>