Browse Source

tests: update attachments tests

pull/8990/head
DarkPhoenix2704 4 months ago
parent
commit
99207aee57
No known key found for this signature in database
GPG Key ID: 3F76B10622A07849
  1. 3
      packages/nc-gui/components/cell/attachment/index.vue
  2. 15
      tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts
  3. 1
      tests/playwright/tests/db/columns/columnAttachments.spec.ts
  4. 5
      tests/playwright/tests/db/views/viewForm.spec.ts

3
packages/nc-gui/components/cell/attachment/index.vue

@ -205,7 +205,7 @@ const handleFileDelete = (i: number) => {
<template>
<div v-if="isExpandedForm || isForm" class="form-attachment-cell">
<NcButton type="secondary" size="small" @click="open">
<NcButton data-testid="attachment-cell-file-picker-button" type="secondary" size="small" @click="open">
<div class="flex items-center !text-xs gap-1 justify-center">
<MaterialSymbolsAttachFile class="text-gray-500 text-tiny" />
<span class="text-[10px]">
@ -295,7 +295,6 @@ const handleFileDelete = (i: number) => {
v-if="!isReadonly && active && !visibleItems.length"
:class="{ 'sm:(mx-auto px-4) xs:(w-full min-w-8)': !visibleItems.length }"
class="group cursor-pointer py-1 flex gap-1 items-center rounded border-none"
data-testid="attachment-cell-file-picker-button"
tabindex="0"
@keydown.enter="keydownEnter"
@keydown.space="keydownSpace"

15
tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts

@ -21,9 +21,22 @@ export class AttachmentCellPageObject extends BasePage {
// filePath: to attach multiple files, pass an array of file paths
// e.g. ['path/to/file1', 'path/to/file2']
//
async addFile({ index, columnHeader, filePath }: { index?: number; columnHeader: string; filePath: string[] }) {
async addFile({
index,
columnHeader,
filePath,
skipElemClick,
}: {
index?: number;
columnHeader: string;
filePath: string[];
skipElemClick?: boolean;
}) {
await this.get({ index, columnHeader }).scrollIntoViewIfNeeded();
if (!skipElemClick) {
await this.get({ index, columnHeader }).click({ position: { x: 1, y: 1 } });
}
await this.get({ index, columnHeader }).locator('[data-testid="attachment-cell-file-picker-button"]').click();

1
tests/playwright/tests/db/columns/columnAttachments.spec.ts

@ -78,6 +78,7 @@ test.describe('Attachment column', () => {
await sharedForm.cell.attachment.addFile({
columnHeader: 'testAttach',
filePath: [`${process.cwd()}/fixtures/sampleFiles/1.json`],
skipElemClick: true,
});
await sharedForm.rootPage.waitForTimeout(1000);

5
tests/playwright/tests/db/views/viewForm.spec.ts

@ -226,6 +226,7 @@ test.describe('Form view', () => {
await sharedForm.cell.attachment.addFile({
columnHeader: 'Attachment',
filePath: [`${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`],
skipElemClick: true,
});
await sharedForm.cell.fillText({
columnHeader: 'Title',
@ -1355,6 +1356,7 @@ test.describe('Form view: field validation', () => {
await sharedForm.cell.attachment.addFile({
columnHeader: 'Attachment',
filePath: [`${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`],
skipElemClick: true,
});
const attError = await sharedForm.getFormFieldErrors({ title: 'Attachment' });
@ -1369,6 +1371,7 @@ test.describe('Form view: field validation', () => {
await sharedForm.cell.attachment.addFile({
columnHeader: 'Attachment',
filePath: [`${process.cwd()}/fixtures/sampleFiles/Image/2.png`],
skipElemClick: true,
});
await attError.verify({ hasError: false });
@ -1401,6 +1404,7 @@ test.describe('Form view: field validation', () => {
await surveyForm.cell.attachment.addFile({
columnHeader: 'Attachment',
filePath: [`${process.cwd()}/fixtures/sampleFiles/sampleImage.jpeg`],
skipElemClick: true,
});
const surveryAttError = await surveyForm.getFormFieldErrors();
@ -1415,6 +1419,7 @@ test.describe('Form view: field validation', () => {
await surveyForm.cell.attachment.addFile({
columnHeader: 'Attachment',
filePath: [`${process.cwd()}/fixtures/sampleFiles/Image/2.png`],
skipElemClick: true,
});
await surveryAttError.verify({ hasError: false });

Loading…
Cancel
Save