test: add test case for upload image (#1250)

This commit is contained in:
Himself65
2023-03-01 23:51:15 -06:00
committed by GitHub
parent e5a6fd8f6c
commit f34a64a82a
7 changed files with 60 additions and 10 deletions

BIN
tests/fixtures/smile.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

View File

@@ -0,0 +1,39 @@
import { expect } from '@playwright/test';
import { loadPage } from './libs/load-page';
import { newPage } from './libs/page-logic';
import { test } from './libs/playwright';
loadPage();
test.describe('Local first create page', () => {
test('should create a page with a local first avatar', async ({ page }) => {
await newPage(page);
await page.getByTestId('workspace-name').click();
await page.getByTestId('new-workspace').click({ delay: 50 });
await page
.getByTestId('create-workspace-input')
.type('Test Workspace 1', { delay: 50 });
await page.getByTestId('create-workspace-button').click();
await page.getByTestId('workspace-name').click();
await page.getByTestId('workspace-card').nth(1).click();
await page.getByText('Workspace Setting').click();
await page
.getByTestId('upload-avatar')
.setInputFiles('./tests/fixtures/smile.png');
await page.getByTestId('workspace-name').click();
await page.getByTestId('workspace-card').nth(0).click();
await page.waitForTimeout(1000);
const text = await page.getByTestId('workspace-avatar').textContent();
// default avatar for default workspace
expect(text).toBe('U');
await page.getByTestId('workspace-name').click();
await page.getByTestId('workspace-card').nth(1).click();
const blobUrl = await page
.getByTestId('workspace-avatar')
.locator('img')
.getAttribute('src');
// out user uploaded avatar
expect(blobUrl).toContain('blob:');
});
});