Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2024-11-08 10:38:41 +00:00
commit 7d0aadcf52

View File

@ -8,6 +8,7 @@
*/ */
import { expect, test } from '@nocobase/test/e2e'; import { expect, test } from '@nocobase/test/e2e';
import { dayjs } from '@nocobase/utils';
import { subTableDefaultValue } from './templatesOfBug'; import { subTableDefaultValue } from './templatesOfBug';
test.describe('subTable', () => { test.describe('subTable', () => {
@ -18,25 +19,29 @@ test.describe('subTable', () => {
// timeEnd: {{ $iteration.timeStart }} // timeEnd: {{ $iteration.timeStart }}
await mockPage(subTableDefaultValue).goto(); await mockPage(subTableDefaultValue).goto();
// 1. Click "Add new" to add a row, default values should display correctly // This is to handle timezone differences between CI environment and local environment
const expectedDateBeforeModify = dayjs('2024-11-06T16:00:00.000Z').format('YYYY-MM-DD');
const expectedDateAfterModify = '2024-11-08';
// 1. Click "Add new" to add a row, default values should display correctly`
await page.getByRole('button', { name: 'Add new' }).click(); await page.getByRole('button', { name: 'Add new' }).click();
await expect(page.getByTestId('select-object-single').getByText('Super Admin')).toBeVisible(); await expect(page.getByTestId('select-object-single').getByText('Super Admin')).toBeVisible();
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').getByPlaceholder('Select date'),
).toHaveValue('2024-11-07'); ).toHaveValue(expectedDateBeforeModify);
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').getByPlaceholder('Select date'),
).toHaveValue('2024-11-07'); ).toHaveValue(expectedDateBeforeModify);
// 2. Click "Add new" again to add another row, default values should display correctly // 2. Click "Add new" again to add another row, default values should display correctly
await page.getByRole('button', { name: 'Add new' }).click(); await page.getByRole('button', { name: 'Add new' }).click();
await expect(page.getByTestId('select-object-single').getByText('Super Admin').nth(1)).toBeVisible(); await expect(page.getByTestId('select-object-single').getByText('Super Admin').nth(1)).toBeVisible();
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').nth(1).getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').nth(1).getByPlaceholder('Select date'),
).toHaveValue('2024-11-07'); ).toHaveValue(expectedDateBeforeModify);
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').nth(1).getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').nth(1).getByPlaceholder('Select date'),
).toHaveValue('2024-11-07'); ).toHaveValue(expectedDateBeforeModify);
// 3. After modifying timeStart in both first and second rows, their corresponding timeEnd should stay synchronized // 3. After modifying timeStart in both first and second rows, their corresponding timeEnd should stay synchronized
await page.getByPlaceholder('Select date').first().click(); await page.getByPlaceholder('Select date').first().click();
@ -47,19 +52,19 @@ test.describe('subTable', () => {
// First row // First row
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').nth(0).getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').nth(0).getByPlaceholder('Select date'),
).toHaveValue('2024-11-08'); ).toHaveValue(expectedDateAfterModify);
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').nth(0).getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').nth(0).getByPlaceholder('Select date'),
).toHaveValue('2024-11-08'); ).toHaveValue(expectedDateAfterModify);
await expect(page.getByTestId('select-object-single').getByText('Super Admin').nth(0)).toBeVisible(); await expect(page.getByTestId('select-object-single').getByText('Super Admin').nth(0)).toBeVisible();
// Second row // Second row
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').nth(1).getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeStart-').nth(1).getByPlaceholder('Select date'),
).toHaveValue('2024-11-08'); ).toHaveValue(expectedDateAfterModify);
await expect( await expect(
page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').nth(1).getByPlaceholder('Select date'), page.getByLabel('block-item-CollectionField-group-form-group.timeEnd-').nth(1).getByPlaceholder('Select date'),
).toHaveValue('2024-11-08'); ).toHaveValue(expectedDateAfterModify);
await expect(page.getByTestId('select-object-single').getByText('Super Admin').nth(1)).toBeVisible(); await expect(page.getByTestId('select-object-single').getByText('Super Admin').nth(1)).toBeVisible();
}); });
}); });