-
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): publish single chat tests (#2182)
- Loading branch information
1 parent
7cdee44
commit e077478
Showing
51 changed files
with
1,442 additions
and
265 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
4 changes: 4 additions & 0 deletions
4
apps/chat-e2e/src/assertions/conversationToApproveAssertion.ts
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,4 @@ | ||
import { PublishEntityAssertion } from '@/src/assertions/publishEntityAssertion'; | ||
import { ConversationsToApproveTree } from '@/src/ui/webElements/entityTree'; | ||
|
||
export class ConversationToApproveAssertion extends PublishEntityAssertion<ConversationsToApproveTree> {} |
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,173 @@ | ||
import { | ||
CheckboxState, | ||
ElementState, | ||
ExpectedMessages, | ||
TreeEntity, | ||
} from '@/src/testData'; | ||
import { Styles } from '@/src/ui/domData'; | ||
import { EntitiesTree } from '@/src/ui/webElements/entityTree'; | ||
import { expect } from '@playwright/test'; | ||
|
||
export class EntityTreeAssertion<T extends EntitiesTree> { | ||
readonly treeEntities: T; | ||
|
||
constructor(treeEntities: T) { | ||
this.treeEntities = treeEntities; | ||
} | ||
|
||
public async assertEntityState( | ||
entity: TreeEntity, | ||
expectedState: ElementState, | ||
) { | ||
const entityLocator = this.treeEntities.getEntityByName( | ||
entity.name, | ||
entity.index, | ||
); | ||
expectedState === 'visible' | ||
? await expect | ||
.soft(entityLocator, ExpectedMessages.entityIsVisible) | ||
.toBeVisible() | ||
: await expect | ||
.soft(entityLocator, ExpectedMessages.entityIsNotVisible) | ||
.toBeHidden(); | ||
} | ||
|
||
public async assertEntityCheckbox( | ||
entity: TreeEntity, | ||
expectedState: ElementState, | ||
) { | ||
const entityCheckboxLocator = this.treeEntities.getEntityCheckbox( | ||
entity.name, | ||
entity.index, | ||
); | ||
expectedState === 'visible' | ||
? await expect | ||
.soft(entityCheckboxLocator, ExpectedMessages.entityIsChecked) | ||
.toBeVisible() | ||
: await expect | ||
.soft(entityCheckboxLocator, ExpectedMessages.entityIsNotChecked) | ||
.toBeHidden(); | ||
} | ||
|
||
public async assertEntityCheckboxState( | ||
entity: TreeEntity, | ||
expectedState: CheckboxState, | ||
) { | ||
const message = | ||
expectedState === CheckboxState.checked | ||
? ExpectedMessages.entityIsChecked | ||
: ExpectedMessages.entityIsNotChecked; | ||
expect | ||
.soft( | ||
await this.treeEntities.getEntityCheckboxState( | ||
entity.name, | ||
entity.index, | ||
), | ||
message, | ||
) | ||
.toBe(expectedState); | ||
} | ||
|
||
public async assertEntityBackgroundColor( | ||
entity: TreeEntity, | ||
expectedColor: string, | ||
) { | ||
const entityBackgroundColor = | ||
await this.treeEntities.getEntityBackgroundColor( | ||
entity.name, | ||
entity.index, | ||
); | ||
expect | ||
.soft( | ||
entityBackgroundColor, | ||
ExpectedMessages.entityBackgroundColorIsValid, | ||
) | ||
.toBe(expectedColor); | ||
} | ||
|
||
public async assertEntityCheckboxColor( | ||
entity: TreeEntity, | ||
expectedColor: string, | ||
) { | ||
const checkboxElement = this.treeEntities.getEntityCheckboxElement( | ||
entity.name, | ||
entity.index, | ||
); | ||
const color = await checkboxElement.getComputedStyleProperty(Styles.color); | ||
expect | ||
.soft(color[0], ExpectedMessages.iconColorIsValid) | ||
.toBe(expectedColor); | ||
} | ||
|
||
public async assertEntityCheckboxBorderColors( | ||
entity: TreeEntity, | ||
expectedColor: string, | ||
) { | ||
const checkboxElement = this.treeEntities.getEntityCheckboxElement( | ||
entity.name, | ||
entity.index, | ||
); | ||
const borderColors = await checkboxElement.getAllBorderColors(); | ||
|
||
Object.values(borderColors).forEach((borders) => { | ||
borders.forEach((borderColor) => { | ||
expect | ||
.soft(borderColor, ExpectedMessages.borderColorsAreValid) | ||
.toBe(expectedColor); | ||
}); | ||
}); | ||
} | ||
|
||
public async assertEntityIcon(entity: TreeEntity, expectedIcon: string) { | ||
const entityIcon = await this.treeEntities.getEntityIcon( | ||
entity.name, | ||
entity.index, | ||
); | ||
expect | ||
.soft(entityIcon, ExpectedMessages.entityIconIsValid) | ||
.toBe(expectedIcon); | ||
} | ||
|
||
public async assertEntityArrowIconState( | ||
entity: TreeEntity, | ||
expectedState: ElementState, | ||
) { | ||
const arrowIcon = this.sideBarEntitiesTree.getEntityArrowIcon( | ||
entity.name, | ||
entity.index, | ||
); | ||
expectedState === 'visible' | ||
? await expect | ||
.soft(arrowIcon, ExpectedMessages.sharedEntityIconIsVisible) | ||
.toBeVisible() | ||
: await expect | ||
.soft(arrowIcon, ExpectedMessages.sharedEntityIconIsNotVisible) | ||
.toBeHidden(); | ||
} | ||
|
||
public async assertEntityArrowIconColor( | ||
entity: TreeEntity, | ||
expectedColor: string, | ||
) { | ||
const arrowIconColor = | ||
await this.sideBarEntitiesTree.getEntityArrowIconColor( | ||
entity.name, | ||
entity.index, | ||
); | ||
expect | ||
.soft(arrowIconColor[0], ExpectedMessages.sharedIconColorIsValid) | ||
.toBe(expectedColor); | ||
} | ||
|
||
public async assertEntityArrowIconsCount( | ||
entity: TreeEntity, | ||
expectedCount: number, | ||
) { | ||
const arrowIconsCount = await this.sideBarEntitiesTree | ||
.getEntityArrowIcon(entity.name, entity.index) | ||
.count(); | ||
expect | ||
.soft(arrowIconsCount, ExpectedMessages.entitiesIconsCountIsValid) | ||
.toBe(expectedCount); | ||
} | ||
} |
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,32 @@ | ||
export * from './api/apiAssertion'; | ||
export * from './api/shareApiAssertion'; | ||
|
||
export * from './accountSettingsAssertion'; | ||
export * from './chatAssertion'; | ||
export * from './chatHeaderAssertion'; | ||
export * from './chatMessagesAssertion'; | ||
export * from './confirmationDialogAssertion'; | ||
export * from './conversationAssertion'; | ||
export * from './conversationToApproveAssertion'; | ||
export * from './downloadAssertion'; | ||
export * from './entitySettingAssertion'; | ||
export * from './entityTreeAssertion'; | ||
export * from './errorToastAssertion'; | ||
export * from './folderAssertion'; | ||
export * from './footerAssertion'; | ||
export * from './menuAssertion'; | ||
export * from './playbackAssertion'; | ||
export * from './promptAssertion'; | ||
export * from './promptListAssertion'; | ||
export * from './promptModalAssertion'; | ||
export * from './publishEntityAssertion'; | ||
export * from './publishingApprovalModalAssertion'; | ||
export * from './publishingRequestModalAssertion'; | ||
export * from './recentEntitiesAssertion'; | ||
export * from './sendMessageAssertion'; | ||
export * from './sharedPromptPreviewModalAssertion'; | ||
export * from './sharedWithMePromptsAssertion'; | ||
export * from './shareModalAssertion'; | ||
export * from './sideBarAssertion'; | ||
export * from './tooltipAssertion'; | ||
export * from './variableModalAssertion'; |
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,27 @@ | ||
import { EntityTreeAssertion } from '@/src/assertions/entityTreeAssertion'; | ||
import { PublishingExpectedMessages, TreeEntity } from '@/src/testData'; | ||
import { PublishEntitiesTree } from '@/src/ui/webElements/entityTree'; | ||
import { expect } from '@playwright/test'; | ||
|
||
export class PublishEntityAssertion< | ||
T extends PublishEntitiesTree, | ||
> extends EntityTreeAssertion<PublishEntitiesTree> { | ||
readonly publishEntities: T; | ||
|
||
constructor(publishEntities: T) { | ||
super(publishEntities); | ||
this.publishEntities = publishEntities; | ||
} | ||
|
||
public async assertEntityVersion( | ||
entity: TreeEntity, | ||
expectedVersion: string, | ||
) { | ||
await expect | ||
.soft( | ||
this.publishEntities.getEntityVersion(entity.name, entity.index), | ||
PublishingExpectedMessages.entityVersionIsValid, | ||
) | ||
.toHaveText(expectedVersion); | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
apps/chat-e2e/src/assertions/publishingApprovalModalAssertion.ts
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,118 @@ | ||
import { Publication } from '@/chat/types/publication'; | ||
import { | ||
ElementState, | ||
ExpectedConstants, | ||
ExpectedMessages, | ||
PublishingExpectedMessages, | ||
} from '@/src/testData'; | ||
import { BaseElement, PublishingApprovalModal } from '@/src/ui/webElements'; | ||
import { DateUtil } from '@/src/utils'; | ||
import { expect } from '@playwright/test'; | ||
|
||
export class PublishingApprovalModalAssertion { | ||
readonly publishingApprovalModal: PublishingApprovalModal; | ||
|
||
constructor(publishingApprovalModal: PublishingApprovalModal) { | ||
this.publishingApprovalModal = publishingApprovalModal; | ||
} | ||
|
||
public async assertPublishingApprovalModalState(expectedState: ElementState) { | ||
expectedState === 'visible' | ||
? await expect | ||
.soft( | ||
this.publishingApprovalModal.getElementLocator(), | ||
ExpectedMessages.modalWindowIsOpened, | ||
) | ||
.toBeVisible() | ||
: await expect | ||
.soft( | ||
this.publishingApprovalModal.getElementLocator(), | ||
ExpectedMessages.modalWindowIsClosed, | ||
) | ||
.toBeHidden(); | ||
} | ||
|
||
public async assertPublishToLabelState(expectedState: ElementState) { | ||
await this.assertElementState( | ||
this.publishingApprovalModal.publishToPathLabel, | ||
expectedState, | ||
ExpectedConstants.publishToLabel, | ||
); | ||
} | ||
|
||
public async assertPublishToPath(expectedPath: string) { | ||
expect | ||
.soft( | ||
await this.publishingApprovalModal.publishToPath.getElementInnerContent(), | ||
PublishingExpectedMessages.publishToPathIsValid, | ||
) | ||
.toBe(expectedPath); | ||
} | ||
|
||
public async assertRequestCreationDate(publicationRequest: Publication) { | ||
expect | ||
.soft( | ||
await this.publishingApprovalModal.publishDate.getElementInnerContent(), | ||
PublishingExpectedMessages.publishToPathIsValid, | ||
) | ||
.toBe( | ||
DateUtil.convertUnixTimestampToLocalDate(publicationRequest.createdAt), | ||
); | ||
} | ||
|
||
public async assertRequestCreationDateLabelState( | ||
expectedState: ElementState, | ||
) { | ||
await this.assertElementState( | ||
this.publishingApprovalModal.publishDateLabel, | ||
expectedState, | ||
ExpectedConstants.requestCreationDateLabel, | ||
); | ||
} | ||
|
||
public async assertAllowAccessLabelState(expectedState: ElementState) { | ||
await this.assertElementState( | ||
this.publishingApprovalModal.allowAccessLabel, | ||
expectedState, | ||
ExpectedConstants.allowAccessLabel, | ||
); | ||
} | ||
|
||
public async assertNoChangesLabelState(expectedState: ElementState) { | ||
await this.assertElementState( | ||
this.publishingApprovalModal.noChangesLabel, | ||
expectedState, | ||
ExpectedConstants.noChangesLabel, | ||
); | ||
} | ||
|
||
public async assertAvailabilityLabelState(expectedState: ElementState) { | ||
await this.assertElementState( | ||
this.publishingApprovalModal.availabilityLabel, | ||
expectedState, | ||
ExpectedConstants.availabilityLabel, | ||
); | ||
} | ||
|
||
public async assertElementState( | ||
element: BaseElement, | ||
expectedState: ElementState, | ||
expectedText?: string, | ||
) { | ||
const elementLocator = element.getElementLocator(); | ||
if (expectedState === 'visible') { | ||
await expect | ||
.soft(elementLocator, ExpectedMessages.entityIsVisible) | ||
.toBeVisible(); | ||
if (expectedText !== undefined) { | ||
await expect | ||
.soft(elementLocator, ExpectedMessages.fieldLabelIsValid) | ||
.toHaveText(expectedText); | ||
} | ||
} else { | ||
await expect | ||
.soft(elementLocator, ExpectedMessages.entityIsVisible) | ||
.toBeHidden(); | ||
} | ||
} | ||
} |
Oops, something went wrong.