-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat-e2e): overlay sandbox component (#2776)
- Loading branch information
1 parent
1d196c0
commit 37b9936
Showing
32 changed files
with
892 additions
and
634 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { BaseAssertion } from '@/src/assertions'; | ||
import { ExpectedMessages } from '@/src/testData'; | ||
import { Attributes } from '@/src/ui/domData'; | ||
import { BaseElement } from '@/src/ui/webElements'; | ||
import { expect } from '@playwright/test'; | ||
|
||
const translatePropertyRegex = /translate\((\d+)px,\s*(\d+)px\)/; | ||
const propertyNotDefinedError = | ||
'Translate property is not defined for the element!'; | ||
|
||
export class OverlayAssertion extends BaseAssertion { | ||
public async assertOverlayManagerIsVisible(overlayContainer: BaseElement) { | ||
const styleAttribute = await overlayContainer | ||
.getElementLocator() | ||
.getAttribute(Attributes.style); | ||
const match = styleAttribute?.match(translatePropertyRegex); | ||
if (match) { | ||
expect.soft(+match[1], ExpectedMessages.elementIsVisible).toBe(0); | ||
expect.soft(+match[2], ExpectedMessages.elementIsVisible).toBe(0); | ||
} else { | ||
throw new Error(propertyNotDefinedError); | ||
} | ||
} | ||
|
||
public async assertOverlayManagerIsHidden( | ||
overlayContainer: BaseElement, | ||
viewportSize: { width: number; height: number }, | ||
) { | ||
const styleAttribute = await overlayContainer | ||
.getElementLocator() | ||
.getAttribute(Attributes.style); | ||
const translateRegex = /translate\((\d+)px,\s*(\d+)px\)/; | ||
const match = styleAttribute?.match(translateRegex); | ||
if (match) { | ||
expect | ||
.soft(+match[1], ExpectedMessages.elementIsNotVisible) | ||
.toBeGreaterThan(viewportSize.width); | ||
expect | ||
.soft(+match[2], ExpectedMessages.elementIsNotVisible) | ||
.toBeGreaterThan(viewportSize.height); | ||
} else { | ||
throw new Error(propertyNotDefinedError); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.