Skip to content

Commit 5b69994

Browse files
committed
test: add searching for username and going to profile test
1 parent 673459b commit 5b69994

1 file changed

Lines changed: 60 additions & 16 deletions

File tree

e2e/specs/explore.e2e.js

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ExploreScreen from '../pageobjects/Explore/ExploreScreen.page';
44
import ForYouScreen from '../pageobjects/Home/ForYouScreen.page';
55
import LoginEmailScreen from '../pageobjects/Login/LoginEmail.page';
66
import LoginPasswordScreen from '../pageobjects/Login/LoginPassword.page';
7+
import ProfileScreen from '../pageobjects/Profile/ProfileScreen.page';
78
import SearchFiltersScreen from '../pageobjects/Search/SearchFiltersScreen.page';
89
import SearchScreen from '../pageobjects/Search/SearchScreen.page';
910
import StartScreen from '../pageobjects/StartScreen.page';
@@ -21,10 +22,7 @@ describe('Explore and Search Flow', () => {
2122
await ForYouScreen.forYouTab.waitForDisplayed();
2223
};
2324

24-
// Helper to ensure we're on the Explore tab
2525
const ensureOnExplore = async () => {
26-
// Step 1: Check if we're in the Search screen (ROOT.SEARCH is separate from BottomTabs)
27-
// If search-back button is visible, we're in search and need to exit first
2826
try {
2927
await SearchScreen.searchBack.waitForDisplayed();
3028
await SearchScreen.searchBack.click();
@@ -33,7 +31,6 @@ describe('Explore and Search Flow', () => {
3331
// Not in search results screen, continue
3432
}
3533

36-
// Step 2: Also handle cancel-search button (for when in search input mode without results)
3734
try {
3835
await SearchScreen.cancelSearch.waitForDisplayed();
3936
await SearchScreen.cancelSearch.click();
@@ -42,14 +39,11 @@ describe('Explore and Search Flow', () => {
4239
// Not in search input mode, continue
4340
}
4441

45-
// Step 3: Wait for the ExploreTab to actually be present and visible
46-
// This ensures we're back in the BottomTabs navigator
4742
const exploreTab = await $('~ExploreTab');
4843
await exploreTab.waitForDisplayed({ timeout: 5000 });
4944
await exploreTab.click();
5045
await driver.pause(500);
5146

52-
// Step 4: Verify we're actually on the Explore screen by waiting for ForYouTab
5347
await ExploreScreen.forYouTab.waitForDisplayed({ timeout: 5000 });
5448
await ExploreScreen.waitForContentToLoad();
5549
};
@@ -139,7 +133,6 @@ describe('Explore and Search Flow', () => {
139133

140134
it('should submit search query and show results', async () => {
141135
await SearchScreen.searchFor('test');
142-
// Verify we're on search results screen with Top tab visible
143136
await expect(await SearchScreen.isTopTabDisplayed()).toBe(true);
144137
});
145138

@@ -220,6 +213,15 @@ describe('Explore and Search Flow', () => {
220213
it('should display the trending list', async () => {
221214
await expect(await ExploreScreen.trendingList.waitForDisplayed({ timeout: 5000 })).toBe(true);
222215
});
216+
217+
it('should click on a trend and navigate to search results', async () => {
218+
const clicked = await ExploreScreen.clickFirstTrendCard();
219+
if (clicked) {
220+
await expect(await SearchScreen.isTopTabDisplayed()).toBe(true);
221+
await SearchScreen.goBack();
222+
await expect(await ExploreScreen.isTrendingTabDisplayed()).toBe(true);
223+
}
224+
});
223225
});
224226

225227
describe('Hashtag Search', () => {
@@ -230,36 +232,78 @@ describe('Explore and Search Flow', () => {
230232
it('should search for a hashtag and display results', async () => {
231233
await ExploreScreen.openSearch();
232234
await SearchScreen.searchFor('#test');
233-
// Verify search results screen is shown with Top tab
234235
await expect(await SearchScreen.isTopTabDisplayed()).toBe(true);
235236
});
236237

238+
it('should switch to People tab and verify results list', async () => {
239+
await SearchScreen.switchToPeopleTab();
240+
await expect(await SearchScreen.isPeopleTabDisplayed()).toBe(true);
241+
const hasPeopleResults = await SearchScreen.isPeopleResultsDisplayed();
242+
await expect(hasPeopleResults).toBe(true);
243+
});
244+
237245
it('should return to explore', async () => {
238246
await SearchScreen.goBack();
239247
await expect(await ExploreScreen.forYouTab.waitForDisplayed()).toBe(true);
240248
});
241249
});
242250

243-
describe('Username Search', () => {
251+
describe('Search Empty State', () => {
244252
before(async () => {
245253
await ensureOnExplore();
246254
await ExploreScreen.openSearch();
247255
});
248256

249-
it('should search for username and display results', async () => {
250-
await SearchScreen.searchFor('@notnowomar');
251-
// Verify search results screen is shown
257+
it('should search for gibberish and show empty or no results', async () => {
258+
await SearchScreen.searchFor('zzzxxx999nonexistent42');
252259
await expect(await SearchScreen.isTopTabDisplayed()).toBe(true);
253260
});
254261

255-
it('should switch to People tab to see matching users', async () => {
256-
await SearchScreen.switchToPeopleTab();
257-
await expect(await SearchScreen.isPeopleTabDisplayed()).toBe(true);
262+
it('should display empty state or no results message', async () => {
263+
await driver.pause(1000);
264+
const hasEmptyState = await SearchScreen.isEmptyStateDisplayed();
265+
await expect(hasEmptyState).toBe(true);
258266
});
259267

260268
it('should return to explore', async () => {
261269
await SearchScreen.goBack();
262270
await expect(await ExploreScreen.forYouTab.waitForDisplayed()).toBe(true);
263271
});
264272
});
273+
274+
describe('Username Search with Profile Navigation', () => {
275+
const targetUsername = 'notnowomar';
276+
277+
before(async () => {
278+
await ensureOnExplore();
279+
await ExploreScreen.openSearch();
280+
});
281+
282+
it('should search for username and display results', async () => {
283+
await SearchScreen.searchFor(`@${targetUsername}`);
284+
await expect(await SearchScreen.isTopTabDisplayed()).toBe(true);
285+
});
286+
287+
it('should find the user in Top tab results', async () => {
288+
await driver.pause(1000);
289+
await driver.pause(1000);
290+
const hasUser = await SearchScreen.hasUserInResults(targetUsername);
291+
await expect(hasUser).toBe(true);
292+
});
293+
294+
it('should click on user and navigate to their profile', async () => {
295+
await SearchScreen.clickOnUserInResults(targetUsername);
296+
await expect(await ProfileScreen.username.waitForDisplayed()).toBe(true);
297+
});
298+
299+
it('should display the correct username on profile', async () => {
300+
const usernameText = await ProfileScreen.username.getText();
301+
await expect(usernameText).toContain(targetUsername);
302+
});
303+
304+
it('should go back to search results', async () => {
305+
await ProfileScreen.goBack();
306+
await expect(await SearchScreen.isTopTabDisplayed()).toBe(true);
307+
});
308+
});
265309
});

0 commit comments

Comments
 (0)