Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(update): friends tests to validate no requests text is displayed #480

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/screenobjects/friends/FriendsScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const SELECTORS_WINDOWS = {
INCOMING_REQUESTS_LIST_LABEL: '[name="incoming-list-label"]',
INPUT_ERROR: '[name="input-error"]',
INPUT_ERROR_TEXT: "<Text>",
NO_REQUESTS: '[name="no-requests"]',
NO_REQUESTS_TEXT: "<Text>",
OUTGOING_REQUESTS_LIST: '[name="Outgoing Requests List"]',
OUTGOING_REQUESTS_LIST_LABEL: '[name="outgoing-list-label"]',
PENDING_FRIENDS_BUTTON: '[name="pending-friends-button"]',
Expand Down Expand Up @@ -120,6 +122,8 @@ const SELECTORS_MACOS = {
INCOMING_REQUESTS_LIST_LABEL: "~incoming-list-label",
INPUT_ERROR: "~input-error",
INPUT_ERROR_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
NO_REQUESTS: "~no-requests",
NO_REQUESTS_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
OUTGOING_REQUESTS_LIST: "~Outgoing Requests List",
OUTGOING_REQUESTS_LIST_LABEL: "~outgoing-list-label",
PENDING_FRIENDS_BUTTON: "~pending-friends-button",
Expand Down Expand Up @@ -330,6 +334,14 @@ export default class FriendsScreen extends UplinkMainScreen {
return this.instance.$(SELECTORS.INPUT_ERROR).$(SELECTORS.INPUT_ERROR_TEXT);
}

get noRequests() {
return this.friendsBody.$(SELECTORS.NO_REQUESTS);
}

get noRequestsText() {
return this.noRequests.$(SELECTORS.NO_REQUESTS_TEXT);
}

get outgoingRequestsList() {
return this.instance.$(SELECTORS.OUTGOING_REQUESTS_LIST);
}
Expand Down Expand Up @@ -770,11 +782,23 @@ export default class FriendsScreen extends UplinkMainScreen {
);
}

async validateIncomingListIsNotShown() {
await this.incomingRequestsList.waitForExist({
reverse: true,
});
}

async validateIncomingListIsShown() {
const incomingList = await this.incomingRequestsList;
await incomingList.waitForExist();
}

async validateNoRequestsIsShown() {
// Ensure no requests message is displayed
const noRequests = await this.noRequests;
await noRequests.waitForExist();
}

async validateOutgoingListIsNotEmpty() {
await driver[this.executor].waitUntil(
async () => {
Expand Down
44 changes: 24 additions & 20 deletions tests/specs/04-friends.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ export default async function friends() {
});

it("Switch to Blocked Friends view and validate elements displayed", async () => {
// Go to blocked list and validate that No Requests text is shown
await friendsScreenFirstUser.goToBlockedList();
await friendsScreenFirstUser.validateBlockedListIsShown();
await friendsScreenFirstUser.validateNoRequestsIsShown();

// Ensure that No requests message contains the text "Nothing to see here"
const noRequestsText = await friendsScreenFirstUser.noRequestsText;
await expect(noRequestsText).toHaveText("Nothing to see here");
});

it("Switch to All Friends view and validate elements displayed", async () => {
Expand Down Expand Up @@ -410,10 +415,11 @@ export default async function friends() {

// Get the current list of Blocked list and validate that user does not appear there now
await friendsScreenFirstUser.goToBlockedList();
await friendsScreenFirstUser.validateBlockedListIsShown();
const blockedList = await friendsScreenFirstUser.getBlockedList();
const blockedListIncludes = await blockedList.includes(friendName);
await expect(blockedListIncludes).toEqual(false);
await friendsScreenFirstUser.validateNoRequestsIsShown();

// Ensure that No requests message contains the text "Nothing to see here"
const noRequestsText = await friendsScreenFirstUser.noRequestsText;
await expect(noRequestsText).toHaveText("Nothing to see here");
});

it("Context Menu - Chat with Friend", async () => {
Expand Down Expand Up @@ -549,14 +555,10 @@ export default async function friends() {
const allListIncludes = await allFriendsList.includes(friendName);
await expect(allListIncludes).toEqual(false);

// Get the current list of incoming requests and validate that user does not appear there now
// Go to Pending Requests and ensure that only Outgoing list is displayed on screen
await friendsScreenFirstUser.goToPendingFriendsList();
await friendsScreenFirstUser.validateIncomingListIsShown();
const incomingRequestsList = await friendsScreenFirstUser.getIncomingList();
const incomingListIncludes = await incomingRequestsList.includes(
friendName
);
await expect(incomingListIncludes).toEqual(false);
await friendsScreenFirstUser.validateIncomingListIsNotShown();
await friendsScreenFirstUser.validateOutgoingListIsShown();
});

it("Context Menu - Cancel Outgoing Request", async () => {
Expand All @@ -576,10 +578,11 @@ export default async function friends() {

// Get the current list of Outgoing Requests and validate that user does not appear there now
await friendsScreenFirstUser.goToPendingFriendsList();
await friendsScreenFirstUser.validateOutgoingListIsShown();
const outgoingRequestsList = await friendsScreenFirstUser.getOutgoingList();
const outgoingListIncludes = outgoingRequestsList.includes(friendName);
await expect(outgoingListIncludes).toEqual(false);
await friendsScreenFirstUser.validateNoRequestsIsShown();

// Ensure that No requests message contains the text "Nothing to see here"
const noRequestsText = await friendsScreenFirstUser.noRequestsText;
await expect(noRequestsText).toHaveText("Nothing to see here");
});

it("Context Menu - Unblock User", async () => {
Expand All @@ -602,9 +605,10 @@ export default async function friends() {

// Get the current list of Blocked list and validate that user does not appear there now
await friendsScreenFirstUser.goToBlockedList();
await friendsScreenFirstUser.validateBlockedListIsShown();
const blockedList = await friendsScreenFirstUser.getBlockedList();
const blockedListIncludes = await blockedList.includes(friendName);
await expect(blockedListIncludes).toEqual(false);
await friendsScreenFirstUser.validateNoRequestsIsShown();

// Ensure that No requests message contains the text "Nothing to see here"
const noRequestsText = await friendsScreenFirstUser.noRequestsText;
await expect(noRequestsText).toHaveText("Nothing to see here");
});
}