Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

142 wiersze
4.6 KiB

  1. import type { Page } from '@playwright/test';
  2. import {
  3. adminStorageStatePath,
  4. expect,
  5. rootStorageStatePath,
  6. test,
  7. } from './fixtures/cluster';
  8. function nextBatchName(prefix: string) {
  9. return `${prefix}-${Date.now()}-${Math.floor(Math.random() * 1000)}`;
  10. }
  11. async function gotoUserPage(page: Page) {
  12. await page.goto('/console/user');
  13. await expect(page.getByTestId('user-page')).toBeVisible();
  14. }
  15. async function openMigrationTab(page: Page) {
  16. const migrationTab = page.getByTestId('user-migration-tab');
  17. await expect(migrationTab).toBeVisible();
  18. await migrationTab.click();
  19. await expect(page.getByTestId('user-migration-center')).toBeVisible();
  20. }
  21. async function createBatch(page: Page, batchName: string) {
  22. await page.getByTestId('migration-create-batch-button').click();
  23. const dialog = page.getByRole('dialog');
  24. await expect(dialog).toBeVisible();
  25. const nameField = dialog.getByRole('textbox').first();
  26. await expect(nameField).toBeVisible();
  27. await nameField.fill(batchName);
  28. await dialog
  29. .getByRole('button', { name: /confirm|确定/i })
  30. .click();
  31. await expect(page.getByTestId('migration-batch-table')).toContainText(batchName);
  32. await page.getByTestId('migration-batch-table').getByText(batchName).click();
  33. await expect(page.getByTestId('migration-execution-panel')).toBeVisible();
  34. await expect(page.getByTestId('migration-batch-detail')).toBeVisible();
  35. }
  36. test.describe('User Migration Access', () => {
  37. test.use({ storageState: adminStorageStatePath });
  38. test('non-root admin cannot see migration tab', async ({ page }) => {
  39. await gotoUserPage(page);
  40. await expect(page.getByTestId('user-migration-tab')).toHaveCount(0);
  41. });
  42. });
  43. test.describe.serial('User Migration Smoke', () => {
  44. test.use({ storageState: rootStorageStatePath });
  45. test('root can open migration center and create a batch', async ({ page }) => {
  46. const batchName = nextBatchName('ui-create');
  47. await gotoUserPage(page);
  48. await openMigrationTab(page);
  49. await createBatch(page, batchName);
  50. await expect(page.getByTestId('migration-batch-status')).toHaveText('draft');
  51. });
  52. test('root can scan, resolve conflicts, execute, and verify a batch', async ({
  53. page,
  54. }) => {
  55. const batchName = nextBatchName('ui-flow');
  56. await gotoUserPage(page);
  57. await openMigrationTab(page);
  58. await createBatch(page, batchName);
  59. await page.getByTestId('migration-scan-button').click();
  60. await expect(page.getByTestId('migration-batch-status')).toHaveText(
  61. /scanning|scanned/,
  62. );
  63. await expect(page.getByTestId('migration-batch-status')).toHaveText(
  64. 'scanned',
  65. {
  66. timeout: 25_000,
  67. },
  68. );
  69. await expect(page.getByTestId('migration-conflict-table')).toBeVisible();
  70. await page.getByTestId('migration-resolve-skip-10000003').click();
  71. await page.getByTestId('migration-resolve-skip-10000004').click();
  72. await expect(page.getByTestId('migration-batch-status')).toHaveText('ready');
  73. await page.getByTestId('migration-execute-button').click();
  74. await expect(page.getByTestId('migration-execute-confirm')).toBeVisible();
  75. await page.getByTestId('migration-execute-confirm').click();
  76. await expect(page.getByTestId('migration-batch-status')).toHaveText(
  77. /running|completed/,
  78. );
  79. await expect(page.getByTestId('migration-batch-status')).toHaveText(
  80. 'completed',
  81. {
  82. timeout: 25_000,
  83. },
  84. );
  85. await page.getByTestId('migration-verify-button').click();
  86. await expect(page.getByTestId('migration-verify-results-table')).toBeVisible();
  87. await expect(page.getByTestId('migration-verify-results-table')).toContainText(
  88. '10000001',
  89. );
  90. await expect(page.getByTestId('migration-batch-detail-table')).toContainText(
  91. 'migrated',
  92. );
  93. });
  94. test('page reload keeps batch list and detail loading available', async ({
  95. page,
  96. }) => {
  97. const batchName = nextBatchName('ui-refresh');
  98. await gotoUserPage(page);
  99. await openMigrationTab(page);
  100. await createBatch(page, batchName);
  101. await page.getByTestId('migration-scan-button').click();
  102. await expect(page.getByTestId('migration-batch-status')).toHaveText(
  103. 'scanned',
  104. {
  105. timeout: 25_000,
  106. },
  107. );
  108. await page.reload();
  109. await gotoUserPage(page);
  110. await openMigrationTab(page);
  111. await expect(page.getByTestId('migration-batch-table')).toContainText(batchName);
  112. await page.getByTestId('migration-batch-table').getByText(batchName).click();
  113. await expect(page.getByTestId('migration-batch-detail')).toBeVisible();
  114. await expect(page.getByTestId('migration-batch-status')).toHaveText('scanned');
  115. });
  116. });