Skip to content

Commit

Permalink
Merge pull request #2062 from ita-social-projects/refactor-clubsPage-…
Browse files Browse the repository at this point in the history
…test

Refactor clubsPage test spec
  • Loading branch information
softservedata authored Dec 9, 2023
2 parents e858847 + 7340604 commit 215cb28
Showing 1 changed file with 52 additions and 47 deletions.
99 changes: 52 additions & 47 deletions src/test/playwright/tests/clubsPage-test.spec.js
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();
});

0 comments on commit 215cb28

Please sign in to comment.