mirror of
https://github.com/documenso/documenso.git
synced 2025-11-24 05:32:12 +10:00
fix: test
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
import { DocumentDataType, TeamMemberRole } from '@prisma/client';
|
import { DocumentDataType, TeamMemberRole } from '@prisma/client';
|
||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { extractDocumentAuthMethods } from '@documenso/lib/utils/document-auth';
|
import { extractDocumentAuthMethods } from '@documenso/lib/utils/document-auth';
|
||||||
@ -12,6 +11,10 @@ import { seedUser } from '@documenso/prisma/seed/users';
|
|||||||
import { apiSignin } from '../fixtures/authentication';
|
import { apiSignin } from '../fixtures/authentication';
|
||||||
|
|
||||||
const EXAMPLE_PDF_PATH = path.join(__dirname, '../../../../assets/example.pdf');
|
const EXAMPLE_PDF_PATH = path.join(__dirname, '../../../../assets/example.pdf');
|
||||||
|
const FIELD_ALIGNMENT_TEST_PDF_PATH = path.join(
|
||||||
|
__dirname,
|
||||||
|
'../../../../assets/field-font-alignment.pdf',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Create a template with all settings filled out
|
* 1. Create a template with all settings filled out
|
||||||
@ -233,10 +236,6 @@ test('[TEMPLATE]: should create a document from a template with custom document'
|
|||||||
const { user, team } = await seedUser();
|
const { user, team } = await seedUser();
|
||||||
const template = await seedBlankTemplate(user, team.id);
|
const template = await seedBlankTemplate(user, team.id);
|
||||||
|
|
||||||
// Create a temporary PDF file for upload
|
|
||||||
|
|
||||||
const pdfContent = fs.readFileSync(EXAMPLE_PDF_PATH).toString('base64');
|
|
||||||
|
|
||||||
await apiSignin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
@ -277,7 +276,7 @@ test('[TEMPLATE]: should create a document from a template with custom document'
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await fileChooser.setFiles(EXAMPLE_PDF_PATH);
|
await fileChooser.setFiles(FIELD_ALIGNMENT_TEST_PDF_PATH);
|
||||||
|
|
||||||
// Wait for upload to complete
|
// Wait for upload to complete
|
||||||
await expect(page.getByText('Remove')).toBeVisible();
|
await expect(page.getByText('Remove')).toBeVisible();
|
||||||
@ -314,8 +313,12 @@ test('[TEMPLATE]: should create a document from a template with custom document'
|
|||||||
expect(firstDocumentData.type).toEqual(expectedDocumentDataType);
|
expect(firstDocumentData.type).toEqual(expectedDocumentDataType);
|
||||||
|
|
||||||
if (expectedDocumentDataType === DocumentDataType.BYTES_64) {
|
if (expectedDocumentDataType === DocumentDataType.BYTES_64) {
|
||||||
expect(firstDocumentData.data).toEqual(pdfContent);
|
// Todo: Doesn't really work due to normalization of the PDF which won't let us directly compare the data.
|
||||||
expect(firstDocumentData.initialData).toEqual(pdfContent);
|
// Probably need to do a pixel match
|
||||||
|
expect(firstDocumentData.data).not.toEqual(template.envelopeItems[0].documentData.data);
|
||||||
|
expect(firstDocumentData.initialData).not.toEqual(
|
||||||
|
template.envelopeItems[0].documentData.initialData,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// For S3, we expect the data/initialData to be the S3 path (non-empty string)
|
// For S3, we expect the data/initialData to be the S3 path (non-empty string)
|
||||||
expect(firstDocumentData.data).toBeTruthy();
|
expect(firstDocumentData.data).toBeTruthy();
|
||||||
@ -336,8 +339,6 @@ test('[TEMPLATE]: should create a team document from a template with custom docu
|
|||||||
|
|
||||||
const template = await seedBlankTemplate(owner, team.id);
|
const template = await seedBlankTemplate(owner, team.id);
|
||||||
|
|
||||||
const pdfContent = fs.readFileSync(EXAMPLE_PDF_PATH).toString('base64');
|
|
||||||
|
|
||||||
await apiSignin({
|
await apiSignin({
|
||||||
page,
|
page,
|
||||||
email: owner.email,
|
email: owner.email,
|
||||||
@ -378,7 +379,7 @@ test('[TEMPLATE]: should create a team document from a template with custom docu
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await fileChooser.setFiles(EXAMPLE_PDF_PATH);
|
await fileChooser.setFiles(FIELD_ALIGNMENT_TEST_PDF_PATH);
|
||||||
|
|
||||||
// Wait for upload to complete
|
// Wait for upload to complete
|
||||||
await expect(page.getByText('Remove')).toBeVisible();
|
await expect(page.getByText('Remove')).toBeVisible();
|
||||||
@ -416,8 +417,12 @@ test('[TEMPLATE]: should create a team document from a template with custom docu
|
|||||||
expect(firstDocumentData.type).toEqual(expectedDocumentDataType);
|
expect(firstDocumentData.type).toEqual(expectedDocumentDataType);
|
||||||
|
|
||||||
if (expectedDocumentDataType === DocumentDataType.BYTES_64) {
|
if (expectedDocumentDataType === DocumentDataType.BYTES_64) {
|
||||||
expect(firstDocumentData.data).toEqual(pdfContent);
|
// Todo: Doesn't really work due to normalization of the PDF which won't let us directly compare the data.
|
||||||
expect(firstDocumentData.initialData).toEqual(pdfContent);
|
// Probably need to do a pixel match
|
||||||
|
expect(firstDocumentData.data).not.toEqual(template.envelopeItems[0].documentData.data);
|
||||||
|
expect(firstDocumentData.initialData).not.toEqual(
|
||||||
|
template.envelopeItems[0].documentData.initialData,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// For S3, we expect the data/initialData to be the S3 path (non-empty string)
|
// For S3, we expect the data/initialData to be the S3 path (non-empty string)
|
||||||
expect(firstDocumentData.data).toBeTruthy();
|
expect(firstDocumentData.data).toBeTruthy();
|
||||||
|
|||||||
Reference in New Issue
Block a user