2023-07-13 12:05:01 +03:00
|
|
|
import { resolve } from 'node:path';
|
2023-03-02 08:51:15 +03:00
|
|
|
|
2023-07-13 12:05:01 +03:00
|
|
|
import { rootDir, test } from '@affine-test/kit/playwright';
|
|
|
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
2023-09-02 08:57:04 +03:00
|
|
|
import {
|
|
|
|
clickNewPageButton,
|
|
|
|
waitForEditorLoad,
|
|
|
|
} from '@affine-test/kit/utils/page-logic';
|
2023-07-13 12:05:01 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-03-02 08:51:15 +03:00
|
|
|
|
2023-09-14 17:35:05 +03:00
|
|
|
test('should create a page with a local first avatar and remove it', async ({
|
2023-07-13 15:41:46 +03:00
|
|
|
page,
|
|
|
|
workspace,
|
|
|
|
}) => {
|
2023-04-17 00:02:41 +03:00
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-09-02 08:57:04 +03:00
|
|
|
await clickNewPageButton(page);
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('workspace-name').click();
|
2023-12-08 07:01:36 +03:00
|
|
|
await page.getByTestId('new-workspace').click();
|
|
|
|
await page.getByTestId('create-workspace-input').fill('Test Workspace 1');
|
2023-05-09 10:30:01 +03:00
|
|
|
await page.getByTestId('create-workspace-create-button').click();
|
2023-12-08 07:01:36 +03:00
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
await page.getByTestId('workspace-name').click();
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('workspace-card').nth(1).click();
|
2023-07-03 13:59:23 +03:00
|
|
|
await page.getByTestId('settings-modal-trigger').click();
|
2023-07-27 08:37:31 +03:00
|
|
|
await page.getByTestId('current-workspace-label').click();
|
2023-04-17 00:02:41 +03:00
|
|
|
await page
|
|
|
|
.getByTestId('upload-avatar')
|
2023-07-13 12:05:01 +03:00
|
|
|
.setInputFiles(resolve(rootDir, 'tests', 'fixtures', 'smile.png'));
|
2023-07-03 13:59:23 +03:00
|
|
|
await page.mouse.click(0, 0);
|
2023-12-08 07:01:36 +03:00
|
|
|
await page.getByTestId('workspace-name').click();
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('workspace-card').nth(0).click();
|
|
|
|
await page.waitForTimeout(1000);
|
2023-12-08 07:01:36 +03:00
|
|
|
await page.getByTestId('workspace-name').click();
|
2023-04-17 00:02:41 +03:00
|
|
|
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:');
|
2023-09-14 17:35:05 +03:00
|
|
|
|
|
|
|
// Click remove button to remove workspace avatar
|
|
|
|
await page.getByTestId('settings-modal-trigger').click();
|
|
|
|
await page.getByTestId('current-workspace-label').click();
|
|
|
|
await page.getByTestId('workspace-setting-avatar').hover();
|
|
|
|
await page.getByTestId('workspace-setting-remove-avatar-button').click();
|
|
|
|
await page.mouse.click(0, 0);
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
await page.getByTestId('workspace-name').click();
|
|
|
|
await page.getByTestId('workspace-card').nth(1).click();
|
|
|
|
const removedAvatarImage = await page
|
|
|
|
.getByTestId('workspace-avatar')
|
|
|
|
.locator('img')
|
|
|
|
.count();
|
|
|
|
expect(removedAvatarImage).toBe(0);
|
|
|
|
|
2023-07-13 15:41:46 +03:00
|
|
|
const currentWorkspace = await workspace.current();
|
|
|
|
|
2023-12-15 10:20:50 +03:00
|
|
|
expect(currentWorkspace.meta.flavour).toContain('local');
|
2023-03-02 08:51:15 +03:00
|
|
|
});
|