diff --git a/tests/profileImage.spec.ts b/tests/profileImage.spec.ts index af46120..84f82c4 100644 --- a/tests/profileImage.spec.ts +++ b/tests/profileImage.spec.ts @@ -9,7 +9,6 @@ test.describe('Profile Photo Update', () => { let page: Page; let fileInput: Locator; let profileImage: Locator; - let submitButton: Locator; test.beforeEach(async ({ browser }) => { page = await browser.newPage(); @@ -19,7 +18,6 @@ test.describe('Profile Photo Update', () => { await page.goto('/account', { timeout: 30000, waitUntil: 'domcontentloaded' }); // Initialize locators - submitButton = page.getByRole('button', { name: 'Update Profile Photo' }); profileImage = page.locator('img#userimage'); fileInput = page.locator('input[type="file"]'); }); @@ -32,7 +30,8 @@ test.describe('Profile Photo Update', () => { // Upload the new image await fileInput.setInputFiles(['./static/freakybear.jpg']); - await submitButton.click(); + await page.waitForTimeout(500); + await page.getByTestId('crop').click(); // Wait for upload to complete const response = await page.waitForResponse((response) => response.request().method() === 'POST', { timeout: 30000 }); @@ -50,11 +49,11 @@ test.describe('Profile Photo Update', () => { // Upload the new image await fileInput.setInputFiles(['./README.md']); - await submitButton.click(); + await page.waitForTimeout(500); - // Wait for upload to complete - const response = await page.waitForResponse((response) => response.request().method() === 'POST', { timeout: 30000 }); - expect(response.status()).toBe(500); + // Check for error + const errorMessageLocator = page.locator(`.text-sm.text-red-500:has-text("Please upload a valid image.")`); + await expect(errorMessageLocator).toBeVisible(); // Make sure the src is the same as the original expect(await getImgSrc(profileImage)).toEqual(initalSrc);