Skip to content

Commit 6fe6532

Browse files
authored
feat: Add e2e tests for react-nextjs -> nextjs-host-remote sample (#2759)
1 parent 460a3d3 commit 6fe6532

File tree

18 files changed

+762
-266
lines changed

18 files changed

+762
-266
lines changed

cypress/common/base.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {CssAttr} from "../types/cssAttr";
2020
import {StubTypes} from "../types/stubTypes";
2121
import {RequestsTypes} from "../types/requestsTypes";
2222
import { readFile, writeTofile } from "../helpers/file-actions-helper";
23+
import {CommonTestData} from "../fixtures/commonTestData";
2324

2425
export class BaseMethods {
2526

@@ -897,6 +898,99 @@ export class BaseMethods {
897898
this.checkUrlText(link, isInclude, true)
898899
}
899900

901+
public changeRootFile({
902+
changedContentFilePath,
903+
rootFilePath,
904+
originalContentFilePath,
905+
}: {
906+
changedContentFilePath: string,
907+
rootFilePath: string,
908+
originalContentFilePath: string
909+
}): void {
910+
cy.wait(2000)
911+
this.checkElementWithTextPresence({
912+
selector: baseSelectors.tags.paragraph,
913+
text: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.start,
914+
visibilityState: 'be.visible'
915+
})
916+
this.writeContentToFile({
917+
contentFilePath: changedContentFilePath,
918+
filePath: rootFilePath,
919+
wait: 1000
920+
})
921+
this.reloadWindow()
922+
this.checkElementWithTextPresence({
923+
selector: baseSelectors.tags.paragraph,
924+
text: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.start,
925+
isVisible: false
926+
})
927+
this.checkElementWithTextPresence({
928+
selector: baseSelectors.tags.paragraph,
929+
text: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.start.replace('started', 'TESTED'),
930+
visibilityState: 'be.visible'
931+
})
932+
this.writeContentToFile({
933+
contentFilePath: originalContentFilePath,
934+
filePath: rootFilePath,
935+
wait: 1000
936+
})
937+
this.reloadWindow()
938+
this.checkElementWithTextPresence({
939+
selector: baseSelectors.tags.paragraph,
940+
text: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.start,
941+
visibilityState: 'be.visible'
942+
})
943+
}
944+
945+
public checkLinkedCardsFunctionality(host: number): void {
946+
this.checkOutsideResourceUrl({
947+
parentSelector: baseSelectors.tags.headers.h1,
948+
selector: baseSelectors.tags.coreElements.link,
949+
text: CommonTestData.nextJsAppsHeaderLinkName,
950+
link: Constants.commonConstantsData.commonLinks.nextJs,
951+
})
952+
Constants.commonConstantsData.nextJsAppsCommonPhrases.linksCardsText.forEach((text: string, index: number) => {
953+
this.openLocalhost(host)
954+
this.checkOutsideResourceUrl({
955+
selector: commonSelectors.nextJsAppsLinkCard,
956+
text,
957+
link: Constants.commonConstantsData.commonLinks.nextJsAppsCardsLinks[index],
958+
})
959+
})
960+
// TODO: Failed for now due to dynamic animations loading on new page. Extra investigate required
961+
// this.openLocalhost(host)
962+
// this.checkOutsideResourceUrl({
963+
// parentSelector: baseSelectors.tags.footer,
964+
// selector: baseSelectors.tags.coreElements.link,
965+
// text: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.engine,
966+
// link: Constants.commonConstantsData.commonLinks.vercel,
967+
// })
968+
}
969+
970+
public checkLinkedCardsHoverAnimation(): void {
971+
Constants.commonConstantsData.nextJsAppsCommonPhrases.linksCardsText.forEach((text: string) => {
972+
this.reloadWindow()
973+
this.checkElementHaveProperty({
974+
selector: commonSelectors.nextJsAppsLinkCard,
975+
prop: CssAttr.color,
976+
value: Constants.color.skyBlue,
977+
text,
978+
isInclude: false,
979+
})
980+
this.hoverElement({
981+
selector: commonSelectors.nextJsAppsLinkCard,
982+
text,
983+
wait: 2000
984+
})
985+
this.checkElementHaveProperty({
986+
selector: commonSelectors.nextJsAppsLinkCard,
987+
prop: CssAttr.color,
988+
value: Constants.color.skyBlue,
989+
text,
990+
})
991+
})
992+
}
993+
900994

901995
/*
902996
*---------------------------------------------------

cypress/common/selectors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const commonSelectors = {
7272
commonWidget: '[data-e2e="APP_{appQuantity}__WIDGET"]',
7373
formField: '[data-e2e="FORM_FIELD__{fieldName}"]',
7474
commonMicroFrontendsAppsCard: '[data-e2e="APP__CARD"]',
75+
nextJsAppsLinkCard: '[data-e2e="TEXTED_LINK_CARD"]'
7576
}
7677

7778
export const selectors = {
@@ -177,9 +178,6 @@ export const selectors = {
177178
completeReactCaseApp: {
178179
toolTip: '.tool-tip',
179180
},
180-
nextJsHostReactRemoteApp: {
181-
linkCard: '[data-e2e="TEXTED_LINK_CARD"]'
182-
}
183181
}
184182

185183
export const updatedSelectors = {

cypress/fixtures/commonTestData.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,31 @@ export class CommonTestData {
5151
appName: Constants.commonConstantsData.commonCountAppNames.app2
5252
}
5353
];
54-
public static readonly nextJsHostReactRemoteAppLinkName = Constants.commonPhrases.nextJsHostReactRemoteApp.messages.welcome.split('to')[1].trim()
54+
public static readonly commonNextJsAppsData = [
55+
{
56+
messageType: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.welcome.split(' ')[0].trim(),
57+
selector: baseSelectors.tags.headers.h1,
58+
message: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.welcome,
59+
linkText: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.welcome.split('to')[1].trim(),
60+
},
61+
{
62+
messageType: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.start.split('by')[0].trim(),
63+
selector: baseSelectors.tags.paragraph,
64+
message: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.start,
65+
},
66+
{
67+
messageType: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.engine,
68+
selector: baseSelectors.tags.footer,
69+
message: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.engine,
70+
linkText: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.engine,
71+
},
72+
{
73+
messageType: baseSelectors.tags.footer.charAt(0).toUpperCase() + baseSelectors.tags.footer.slice(1),
74+
selector: baseSelectors.tags.coreElements.body,
75+
message: Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.footer,
76+
}
77+
]
78+
public static readonly nextJsAppsHeaderLinkName = Constants.commonConstantsData.nextJsAppsCommonPhrases.messages.welcome.split('to')[1].trim()
5579
}
5680

5781
export function returnCommonDynamicAppsData(paragraphText: string[]) {

0 commit comments

Comments
 (0)