Files
AFFiNE-Mirror/tests/affine-cloud/e2e/storage.spec.ts
pengx17 3ac92d0d27 chore(core): update onboarding snapshot (#12138)
fix AF-2590

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Tests**
  - Improved the flexibility of the "Unused blobs" count test by dynamically verifying the count before and after deletion, instead of relying on hardcoded values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-06 09:45:41 +00:00

69 lines
2.1 KiB
TypeScript

import { test } from '@affine-test/kit/playwright';
import {
createRandomUser,
deleteUser,
enableCloudWorkspace,
loginUser,
} from '@affine-test/kit/utils/cloud';
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test';
let user: {
id: string;
name: string;
email: string;
password: string;
};
test.beforeEach(async ({ page }) => {
user = await createRandomUser();
await loginUser(page, user);
});
test.afterEach(async () => {
// if you want to keep the user in the database for debugging,
// comment this line
await deleteUser(user.email);
});
test('should show blob management dialog', async ({ page }) => {
await enableCloudWorkspace(page);
await clickSideBarAllPageButton(page);
// delete the welcome page ('Getting Started')
await page
.getByTestId('page-list-item')
.filter({
has: page.getByText('Getting Started'),
})
.getByTestId('page-list-operation-button')
.click();
const deleteBtn = page.getByTestId('move-to-trash');
await deleteBtn.click();
await expect(page.getByText('Delete doc?')).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByTestId('slider-bar-workspace-setting-button').click();
await expect(page.getByTestId('setting-modal')).toBeVisible();
await page.getByTestId('workspace-setting:storage').click();
await expect(page.getByTestId('blob-preview-card')).toHaveCount(9);
// get the unused blobs count
const count = await page.getByText(/Unused blobs \(\d+\)/).textContent();
const unusedBlobsCount = parseInt(count?.match(/\d+/)?.[0] ?? '0');
// count should > 9
expect(unusedBlobsCount).toBeGreaterThan(9);
await page.getByTestId('blob-preview-card').nth(0).click();
await expect(page.getByText('1 Selected')).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await expect(page.getByText('Delete blob files')).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await expect(
page.getByText(`Unused blobs (${unusedBlobsCount - 1})`)
).toBeVisible();
});