This repository was archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-44.5 KB
e2e/suites/screens/entry.spec.ts-snapshots/Аватар-1-chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-41.3 KB
e2e/suites/screens/entry.spec.ts-snapshots/Аватар-2-chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-41.9 KB
e2e/suites/screens/entry.spec.ts-snapshots/Аватар-3-chromium-linux.png
Binary file not shown.
Binary file modified
BIN
+47 Bytes
(100%)
e2e/suites/screens/entry.spec.ts-snapshots/Страница-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { Page } from "@playwright/test" | ||
|
||
// TODO: share AVAILABLE_AVATARS between client and e2e | ||
|
||
const AVAILABLE_AVATARS = 21 | ||
|
||
export async function useAvatar(page: Page, id: number) { | ||
const prevButtonLocator = page.getByTestId("avatar-prev") | ||
const nextButtonLocator = page.getByTestId("avatar-next") | ||
|
||
const rawCurrentAvatarId = await page | ||
.getByTestId("avatar") | ||
.getAttribute("data-test-avatar-id") | ||
|
||
if (rawCurrentAvatarId == null) { | ||
throw new Error("[data-test-avatar-id] is not defined on avatar image") | ||
} | ||
|
||
const currentAvatarId = Number(rawCurrentAvatarId) | ||
|
||
if (currentAvatarId == id) { | ||
return | ||
} | ||
|
||
const nIterationsPrev = | ||
id < currentAvatarId | ||
? currentAvatarId - id | ||
: currentAvatarId - 1 + AVAILABLE_AVATARS - currentAvatarId | ||
|
||
const nIterationsNext = | ||
id > currentAvatarId | ||
? id - currentAvatarId | ||
: AVAILABLE_AVATARS - currentAvatarId + id | ||
|
||
const nIterations = Math.min(nIterationsNext, nIterationsPrev) | ||
|
||
for (let i = 0; i < nIterations; i++) { | ||
const locator = | ||
nIterationsNext > nIterationsPrev ? prevButtonLocator : nextButtonLocator | ||
await locator.click() | ||
} | ||
} |