generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2062 from ita-social-projects/refactor-clubsPage-…
…test Refactor clubsPage test spec
- Loading branch information
Showing
1 changed file
with
52 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,58 @@ | ||
import { test} from "@playwright/test"; | ||
import { test, chromium } from "@playwright/test"; | ||
import ApiService from "../services/ApiService"; | ||
import ClubsPage from "../PO/ClubsPage"; | ||
import BasePage from "../PO/BasePage"; | ||
import {SIMPLE_SEARCH_PARAMETERS} from "../constants/searchQueries.constants"; | ||
import {CITIES} from "../constants/general.constants"; | ||
import { SIMPLE_SEARCH_PARAMETERS } from "../constants/searchQueries.constants"; | ||
import { CITIES } from "../constants/general.constants"; | ||
import { USER_ROLES } from "../constants/general.constants"; | ||
|
||
let apiService, clubsPage, basePage; | ||
let page, apiService, clubsPage, basePage; | ||
|
||
test.describe.configure({ | ||
mode: "parallel" | ||
}) | ||
|
||
test.beforeEach(async({page})=>{ | ||
apiService = new ApiService(page); | ||
clubsPage = new ClubsPage(page); | ||
await apiService.apiLoginAs('admin'); | ||
await clubsPage.gotoClubsPage(); | ||
}) | ||
|
||
test("Verify that clubs received in the result of the simple search contain search query (search by club name/description)", async ({ page }) => { | ||
// Search by the club name and verification | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.clubNameSearchQuery); | ||
await clubsPage.verifyClubCardsContainText(SIMPLE_SEARCH_PARAMETERS.clubNameSearchQuery); | ||
|
||
// Change the search (by the club description) and verify that the results are correct | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.descriptionSearchQuery); | ||
await clubsPage.verifyClubCardsContainText(SIMPLE_SEARCH_PARAMETERS.descriptionSearchQuery); | ||
}); | ||
|
||
test("Verify that clubs received in the result of the simple search contain search query (search by category name)", async ({ page }) => { | ||
// Search by the club category and verification/different city | ||
basePage = new BasePage(page); | ||
await basePage.selectCityInNavBar(CITIES.kharkiv) | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.categorySearchQuery); | ||
await clubsPage.verifyClubCardsContainText(SIMPLE_SEARCH_PARAMETERS.categorySearchQuery); | ||
}); | ||
|
||
test("Verify that respective message will be shown when there are no results", async ({ page }) => { | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.incorrectSearchQuery); | ||
await clubsPage.verifyElementVisibility(clubsPage.noResultsMessage); | ||
}); | ||
|
||
test("Verify that after advanced search toggle, cards are sorted in alphabetical order", async({page})=>{ | ||
basePage = new BasePage(page); | ||
await clubsPage.toggleAdvancedSearch(); | ||
await clubsPage.verifyClubsSortedByTitlesAsc(); | ||
}) | ||
|
||
|
||
test.afterEach(async({page})=>{ | ||
await page.close(); | ||
}) | ||
mode: "parallel", | ||
}); | ||
|
||
test.beforeAll(async () => { | ||
const browser = await chromium.launch(); | ||
const context = await browser.newContext(); | ||
page = await context.newPage(); | ||
apiService = new ApiService(page); | ||
basePage = new BasePage(page); | ||
clubsPage = new ClubsPage(page); | ||
await apiService.apiLoginAs(USER_ROLES.admin); | ||
}); | ||
|
||
test.beforeEach(async () => { | ||
await clubsPage.gotoClubsPage(); | ||
}); | ||
|
||
test("Verify that clubs received in the result of the simple search contain search query (search by club name/description)", async () => { | ||
// Search by the club name and verification | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.clubNameSearchQuery); | ||
await clubsPage.verifyClubCardsContainText(SIMPLE_SEARCH_PARAMETERS.clubNameSearchQuery); | ||
|
||
// Change the search (by the club description) and verify that the results are correct | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.descriptionSearchQuery); | ||
await clubsPage.verifyClubCardsContainText(SIMPLE_SEARCH_PARAMETERS.descriptionSearchQuery); | ||
}); | ||
|
||
test("Verify that clubs received in the result of the simple search contain search query (search by category name)", async () => { | ||
// Search by the club category and verification/different city | ||
await basePage.selectCityInNavBar(CITIES.kharkiv); | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.categorySearchQuery); | ||
await clubsPage.verifyClubCardsContainText(SIMPLE_SEARCH_PARAMETERS.categorySearchQuery); | ||
}); | ||
|
||
test("Verify that respective message will be shown when there are no results", async () => { | ||
await clubsPage.simpleSearchByQuery(SIMPLE_SEARCH_PARAMETERS.incorrectSearchQuery); | ||
await clubsPage.verifyElementVisibility(clubsPage.noResultsMessage); | ||
}); | ||
|
||
test("Verify that after advanced search toggle, cards are sorted in alphabetical order", async () => { | ||
await clubsPage.toggleAdvancedSearch(); | ||
await clubsPage.verifyClubsSortedByTitlesAsc(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await page.close(); | ||
}); |