Открыть боковую панель
Teknokomo
universo-react
Коммиты
2a9a6855
Не подтверждена
Коммит
2a9a6855
создал
Дек 13, 2023
по автору
Peng Xiao
Просмотр файлов
test(core): rewrite some flaky assertions (#5287)
владелец
ad2c254c
Изменения
7
Скрыть пробелы
Построчно
Рядом
tests/affine-desktop/e2e/basic.spec.ts
Просмотр файла @
2a9a6855
...
...
@@ -142,19 +142,19 @@ test('affine onboarding button', async ({ page }) => {
await
page
.
getByTestId
(
'
help-island
'
).
click
();
await
page
.
getByTestId
(
'
easy-guide
'
).
click
();
const
onboardingModal
=
page
.
locator
(
'
[data-testid=onboarding-modal]
'
);
expect
(
await
onboardingModal
.
is
Visible
()
).
toEqual
(
true
)
;
await
expect
(
onboardingModal
).
toBe
Visible
();
const
switchVideo
=
page
.
locator
(
'
[data-testid=onboarding-modal-switch-video]
'
);
expect
(
await
switchVideo
.
is
Visible
()
).
toEqual
(
true
)
;
await
expect
(
switchVideo
).
toBe
Visible
();
await
page
.
getByTestId
(
'
onboarding-modal-next-button
'
).
click
();
const
editingVideo
=
page
.
locator
(
'
[data-testid=onboarding-modal-editing-video]
'
);
expect
(
await
editingVideo
.
is
Visible
()
).
toEqual
(
true
)
;
await
expect
(
editingVideo
).
toBe
Visible
();
await
page
.
getByTestId
(
'
onboarding-modal-close-button
'
).
click
();
expect
(
await
onboardingModal
.
isVisible
()).
toEqual
(
false
);
await
expect
(
onboardingModal
).
toBeHidden
(
);
});
test
(
'
windows only check
'
,
async
({
page
})
=>
{
...
...
tests/affine-local/e2e/drag-page.spec.ts
Просмотр файла @
2a9a6855
...
...
@@ -24,7 +24,7 @@ const dragToFavourites = async (
const
dragToCollection
=
async
(
page
:
Page
,
dragItem
:
Locator
)
=>
{
await
page
.
getByTestId
(
'
slider-bar-add-collection-button
'
).
click
();
const
input
=
page
.
getByTestId
(
'
input-collection-title
'
);
await
input
.
is
Visible
();
await
expect
(
input
).
toBe
Visible
();
await
input
.
fill
(
'
test collection
'
);
await
page
.
getByTestId
(
'
save-collection
'
).
click
();
const
collection
=
page
.
getByTestId
(
'
collection-item
'
);
...
...
tests/affine-local/e2e/duplicate-page.spec.ts
Просмотр файла @
2a9a6855
...
...
@@ -13,10 +13,11 @@ test('Duplicate page should work', async ({ page }) => {
await
waitForEditorLoad
(
page
);
await
clickNewPageButton
(
page
);
const
title
=
getBlockSuiteEditorTitle
(
page
);
await
title
.
pressSequentially
(
'
test
'
);
await
expect
(
title
).
toBeVisible
();
await
title
.
fill
(
'
test
'
);
await
clickPageMoreActions
(
page
);
const
duplicateButton
=
page
.
getByTestId
(
'
editor-option-menu-duplicate
'
);
await
duplicateButton
.
click
(
{
delay
:
100
}
);
await
duplicateButton
.
click
();
const
title2
=
getBlockSuiteEditorTitle
(
page
);
await
expect
(
title2
).
toHaveText
(
'
test(1)
'
,
{
timeout
:
1000
}
);
await
expect
(
title2
).
toHaveText
(
'
test(1)
'
);
});
tests/affine-local/e2e/image-preview.spec.ts
Просмотр файла @
2a9a6855
...
...
@@ -82,7 +82,7 @@ test('image go left and right', async ({ page }) => {
await
importImage
(
page
,
'
http://localhost:8081/affine-preview.png
'
);
}
const
locator
=
page
.
getByTestId
(
'
image-preview-modal
'
);
expect
(
locator
.
isVisible
()).
toBeTruthy
();
await
expect
(
locator
).
toBeHidden
();
await
page
.
locator
(
'
img
'
).
first
().
dblclick
();
await
page
.
waitForTimeout
(
1000
);
{
...
...
@@ -125,7 +125,7 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
const
naturalWidth
=
await
locator
.
evaluate
(
(
img
:
HTMLImageElement
)
=>
img
.
naturalWidth
);
expect
(
locator
.
is
Visible
()
).
toBeTruthy
()
;
await
expect
(
locator
).
toBe
Visible
();
const
{
width
,
height
}
=
await
page
.
evaluate
(()
=>
({
width
:
window
.
innerWidth
,
height
:
window
.
innerHeight
,
...
...
@@ -660,10 +660,10 @@ test('keypress esc should close the modal', async ({ page }) => {
await
importImage
(
page
,
'
http://localhost:8081/large-image.png
'
);
await
page
.
locator
(
'
img
'
).
first
().
dblclick
();
const
locator
=
page
.
getByTestId
(
'
image-preview-modal
'
);
expect
(
locator
.
is
Visible
()
).
toBeTruthy
()
;
await
expect
(
locator
).
toBe
Visible
();
await
page
.
keyboard
.
press
(
'
Escape
'
);
await
page
.
waitForTimeout
(
1000
);
expect
(
await
locator
.
isVisible
()).
toBeFalsy
();
await
expect
(
locator
).
toBeHidden
();
});
test
(
'
when mouse moves outside, the modal should be closed
'
,
async
({
...
...
@@ -706,7 +706,7 @@ test('caption should be visible and different styles were applied if image zoome
await
page
.
getByPlaceholder
(
'
Write a caption
'
).
fill
(
sampleCaption
);
await
page
.
locator
(
'
img
'
).
first
().
dblclick
();
const
locator
=
page
.
getByTestId
(
'
image-preview-modal
'
);
expect
(
await
locator
.
is
Visible
()
).
toBeTruthy
()
;
await
expect
(
locator
).
toBe
Visible
();
await
page
.
waitForTimeout
(
1000
);
let
captionLocator
=
locator
.
getByTestId
(
'
image-caption-zoomedout
'
);
await
expect
(
captionLocator
).
toBeVisible
();
...
...
tests/affine-local/e2e/local-first-collections-items.spec.ts
Просмотр файла @
2a9a6855
...
...
@@ -43,7 +43,7 @@ const createAndPinCollection = async (
delay
:
200
,
});
const
title
=
page
.
getByTestId
(
'
input-collection-title
'
);
await
title
.
is
Visible
();
await
expect
(
title
).
toBe
Visible
();
await
title
.
fill
(
options
?.
collectionName
??
'
test collection
'
);
await
page
.
getByTestId
(
'
save-collection
'
).
click
();
await
page
.
waitForTimeout
(
100
);
...
...
@@ -162,7 +162,7 @@ test('add collection from sidebar', async ({ page }) => {
await
expect
(
nullCollection
).
toBeVisible
();
await
page
.
getByTestId
(
'
slider-bar-add-collection-button
'
).
click
();
const
title
=
page
.
getByTestId
(
'
input-collection-title
'
);
await
title
.
is
Visible
();
await
expect
(
title
).
toBe
Visible
();
await
title
.
fill
(
'
test collection
'
);
await
page
.
getByTestId
(
'
save-collection
'
).
click
();
await
page
.
waitForTimeout
(
100
);
...
...
tests/affine-local/e2e/shortcuts.spec.ts
Просмотр файла @
2a9a6855
...
...
@@ -10,7 +10,7 @@ test('Open shortcuts modal', async ({ page }) => {
const
shortcutsIcon
=
page
.
locator
(
'
[data-testid=shortcuts-icon]
'
);
await
page
.
waitForTimeout
(
1000
);
expect
(
await
shortcutsIcon
.
is
Visible
()
).
toEqual
(
true
)
;
await
expect
(
shortcutsIcon
).
toBe
Visible
();
await
shortcutsIcon
.
click
();
await
page
.
waitForTimeout
(
1000
);
...
...
tests/kit/utils/cloud.ts
Просмотр файла @
2a9a6855
...
...
@@ -185,27 +185,8 @@ export async function enableCloudWorkspaceFromShareButton(page: Page) {
const
shareMenuButton
=
page
.
getByTestId
(
'
local-share-menu-button
'
);
await
expect
(
shareMenuButton
).
toBeVisible
();
// FIXME: this is a workaround for the flaky test
// For unknown reasons,
// the online ci test on GitHub is unable to detect the local-share-menu,
// although it works fine in local testing.
// To ensure the tests pass consistently, I’ve made the following temporary adjustments.
// {
const
maxAttempts
=
5
;
let
attempt
=
0
;
let
menuVisible
=
false
;
while
(
!
menuVisible
&&
attempt
<
maxAttempts
)
{
try
{
await
shareMenuButton
.
click
();
menuVisible
=
await
page
.
getByTestId
(
'
local-share-menu
'
).
isVisible
();
}
catch
(
e
)
{
console
.
error
(
`Attempt
${
attempt
+
1
}
failed:
${
e
}
`
);
attempt
+=
1
;
}
}
expect
(
menuVisible
).
toBeTruthy
();
// }
await
shareMenuButton
.
click
();
await
expect
(
page
.
getByTestId
(
'
local-share-menu
'
)).
toBeVisible
();
await
page
.
getByTestId
(
'
share-menu-enable-affine-cloud-button
'
).
click
();
await
page
.
getByTestId
(
'
confirm-enable-affine-cloud-button
'
).
click
();
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать