fix: file upload test (#9502)

* fix: file upload test

* Updated test
This commit is contained in:
Lucas Oliveira 2025-08-22 17:10:40 -03:00 • committed by GitHub
commit 2f9f80f7b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 26 deletions

View file

@ -596,17 +596,17 @@ test(
); );
test( test(
"should show PNG file as disabled in file component", "should show PSD file as disabled in file component",
{ {
tag: ["@release", "@workspace"], tag: ["@release", "@workspace"],
}, },
async ({ page }) => { async ({ page }) => {
// Generate unique filenames for this test run // Generate unique filenames for this test run
const pngFileName = generateRandomFilename(); const psdFileName = generateRandomFilename();
const txtFileName = generateRandomFilename(); const txtFileName = generateRandomFilename();
// Create PNG content (a simple 1x1 transparent PNG) // Create PSD content (just a mock)
const pngFileContent = Buffer.from( const psdFileContent = Buffer.from(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"base64", "base64",
); );
@ -626,24 +626,24 @@ test(
const title = await page.getByTestId("mainpage_title"); const title = await page.getByTestId("mainpage_title");
expect(await title.textContent()).toContain("Files"); expect(await title.textContent()).toContain("Files");
// Upload the PNG file // Upload the PSD file
const fileChooserPromisePng = page.waitForEvent("filechooser"); const fileChooserPromisePsd = page.waitForEvent("filechooser");
await page.getByTestId("upload-file-btn").click(); await page.getByTestId("upload-file-btn").click();
const fileChooserPng = await fileChooserPromisePng; const fileChooserPsd = await fileChooserPromisePsd;
await fileChooserPng.setFiles([ await fileChooserPsd.setFiles([
{ {
name: `${pngFileName}.png`, name: `${psdFileName}.psd`,
mimeType: "image/png", mimeType: "image/vnd.adobe.photoshop",
buffer: pngFileContent, buffer: psdFileContent,
}, },
]); ]);
// Wait for upload success message // Wait for upload success message
await expect(page.getByText("File uploaded successfully")).toBeVisible(); await expect(page.getByText("File uploaded successfully")).toBeVisible();
// Verify PNG file appears in the list // Verify PSD file appears in the list
await expect(page.getByText(`${pngFileName}.png`)).toBeVisible(); await expect(page.getByText(`${psdFileName}.psd`)).toBeVisible();
// Upload the TXT file // Upload the TXT file
const fileChooserPromiseTxt = page.waitForEvent("filechooser"); const fileChooserPromiseTxt = page.waitForEvent("filechooser");
@ -664,7 +664,7 @@ test(
// Verify TXT file appears in the list // Verify TXT file appears in the list
await expect(page.getByText(`${txtFileName}.txt`)).toBeVisible(); await expect(page.getByText(`${txtFileName}.txt`)).toBeVisible();
// Step 2: Create a flow with File component and check if PNG file is disabled // Step 2: Create a flow with File component and check if PSD file is disabled
// Navigate to workspace page // Navigate to workspace page
await page.getByText("Starter Project").first().click(); await page.getByText("Starter Project").first().click();
@ -696,10 +696,10 @@ test(
// Open the file management modal // Open the file management modal
await page.getByTestId("button_open_file_management").click(); await page.getByTestId("button_open_file_management").click();
console.warn(pngFileName); console.warn(psdFileName);
// Check if the PNG file has the disabled class (greyed out) // Check if the PSD file has the disabled class (greyed out)
await expect(page.getByTestId(`file-item-${pngFileName}`)).toHaveClass( await expect(page.getByTestId(`file-item-${psdFileName}`)).toHaveClass(
/pointer-events-none cursor-not-allowed opacity-50/, /pointer-events-none cursor-not-allowed opacity-50/,
); );
@ -708,9 +708,9 @@ test(
/pointer-events-none cursor-not-allowed opacity-50/, /pointer-events-none cursor-not-allowed opacity-50/,
); );
// Verify the tooltip for PNG file states it's not supported // Verify the tooltip for PSD file states it's not supported
await page await page
.locator(`[data-testid="file-item-${pngFileName}"]`) .locator(`[data-testid="file-item-${psdFileName}"]`)
.locator("..") .locator("..")
.hover(); .hover();
@ -718,11 +718,11 @@ test(
page.getByText("Type not supported by component"), page.getByText("Type not supported by component"),
).toBeVisible(); ).toBeVisible();
// Try to select the PNG file (should not change its state) // Try to select the PSD file (should not change its state)
await expect(page.getByTestId(`checkbox-${pngFileName}`)).toBeDisabled(); await expect(page.getByTestId(`checkbox-${psdFileName}`)).toBeDisabled();
// Verify the PNG file checkbox remains unchecked // Verify the PSD file checkbox remains unchecked
await expect(page.getByTestId(`checkbox-${pngFileName}`)).toHaveAttribute( await expect(page.getByTestId(`checkbox-${psdFileName}`)).toHaveAttribute(
"data-state", "data-state",
"unchecked", "unchecked",
); );
@ -741,6 +741,6 @@ test(
// Verify that only the TXT file was selected in the component // Verify that only the TXT file was selected in the component
await expect(page.getByText(`${txtFileName}.txt`)).toBeVisible(); await expect(page.getByText(`${txtFileName}.txt`)).toBeVisible();
await expect(page.getByText(`${pngFileName}.png`)).not.toBeVisible(); await expect(page.getByText(`${psdFileName}.psd`)).not.toBeVisible();
}, },
); );

View file

@ -71,7 +71,7 @@ test(
const elementTestIds = [ const elementTestIds = [
"input_outputChat Output", "input_outputChat Output",
"dataAPI Request", "dataAPI Request",
"vectorstoresAstra DB", "vectorstoresAstra DB Graph",
"langchain_utilitiesTool Calling Agent", "langchain_utilitiesTool Calling Agent",
"langchain_utilitiesConversationChain", "langchain_utilitiesConversationChain",
"mem0Mem0 Chat Memory", "mem0Mem0 Chat Memory",
@ -90,10 +90,11 @@ test(
); );
await Promise.all( await Promise.all(
elementTestIds.map((id) => { elementTestIds.map(async (id) => {
if (!expect(page.getByTestId(id).first()).toBeVisible()) { if (!expect(page.getByTestId(id).first()).toBeVisible()) {
console.error(`${id} is not visible`); console.error(`${id} is not visible`);
} }
return expect(page.getByTestId(id).first()).toBeVisible();
}), }),
); );