-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
map and add,edit game test code added
- Loading branch information
Showing
5 changed files
with
289 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
export default { | ||
data: [ | ||
{ | ||
_id: "671797bdaa12e197d1cc4de4", | ||
gameName: "Overwatch 2", | ||
reviews: { | ||
rating: 5, | ||
username: "overwatchfan", | ||
email: "[email protected]", | ||
latitude: "40.7128", | ||
longitude: "-74.0060", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4de4", | ||
gameName: "Overwatch 2", | ||
reviews: { | ||
rating: 4, | ||
username: "gamer123", | ||
email: "[email protected]", | ||
latitude: "51.5074", | ||
longitude: "-0.1278", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4dec", | ||
gameName: "PUBG: BATTLEGROUNDS", | ||
reviews: { | ||
rating: 4, | ||
username: "pubgplayer", | ||
email: "[email protected]", | ||
latitude: "37.7749", | ||
longitude: "-122.4194", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4dee", | ||
gameName: "Enlisted", | ||
reviews: { | ||
rating: 5, | ||
username: "historybuff", | ||
email: "[email protected]", | ||
latitude: "52.5200", | ||
longitude: "13.4050", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4df0", | ||
gameName: "Forge of Empires", | ||
reviews: { | ||
rating: 4, | ||
username: "citybuilder", | ||
email: "[email protected]", | ||
latitude: "51.5074", | ||
longitude: "-0.1278", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4df2", | ||
gameName: "Genshin Impact", | ||
reviews: { | ||
rating: 5, | ||
username: "adventurer", | ||
email: "[email protected]", | ||
latitude: "35.6895", | ||
longitude: "139.6917", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4de7", | ||
gameName: "Diablo Immortal", | ||
reviews: { | ||
rating: 4, | ||
username: "diablofan", | ||
email: "[email protected]", | ||
latitude: "35.6895", | ||
longitude: "139.6917", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4de9", | ||
gameName: "Lost Ark", | ||
reviews: { | ||
rating: 5, | ||
username: "arkexplorer", | ||
email: "[email protected]", | ||
latitude: "37.5665", | ||
longitude: "126.9780", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4de9", | ||
gameName: "Lost Ark", | ||
reviews: { | ||
rating: 3, | ||
username: "casualgamer", | ||
email: "[email protected]", | ||
latitude: "40.7128", | ||
longitude: "-74.0060", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4df4", | ||
gameName: "Fall Guys", | ||
reviews: { | ||
rating: 5, | ||
username: "beanlover", | ||
email: "[email protected]", | ||
latitude: "51.5074", | ||
longitude: "-0.1278", | ||
}, | ||
}, | ||
{ | ||
_id: "671797bdaa12e197d1cc4df4", | ||
gameName: "Fall Guys", | ||
reviews: { | ||
rating: 4, | ||
username: "partygamer", | ||
email: "[email protected]", | ||
latitude: "37.7749", | ||
longitude: "-122.4194", | ||
}, | ||
}, | ||
], | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { API_ROUTES } from "../support/constants"; | ||
import { gameListResponse, moderatorExistsResponse } from "../fixtures"; | ||
|
||
test.describe("Games: Add, Edit from Admin panel", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.route(API_ROUTES.CHECK_MODERATOR, async (route) => { | ||
await route.fulfill({ json: moderatorExistsResponse }); | ||
}); | ||
|
||
await page.goto("/login"); | ||
|
||
await page.route(API_ROUTES.LOGIN, async (route) => { | ||
route.fulfill({ | ||
body: JSON.stringify({ token: "mockToken" }), | ||
}); | ||
}); | ||
|
||
await page.fill('input[placeholder="Email"]', "[email protected]"); | ||
await page.fill('input[placeholder="Password"]', "password123"); | ||
await page.click("button"); | ||
|
||
await page.route(API_ROUTES.GAME_LIST, async (route) => { | ||
await route.fulfill({ json: gameListResponse }); | ||
}); | ||
|
||
await page.goto("/games"); | ||
await page.waitForLoadState("networkidle"); | ||
}); | ||
|
||
test("Add Games validations check", async ({ page }) => { | ||
await page.click("#add-game-button"); | ||
await page.click("#save-button-add-game"); | ||
|
||
await expect(page.locator("text=Game Name must be provided")).toBeVisible(); | ||
await expect( | ||
page.locator("text=Game Image must be a valid URL") | ||
).toBeVisible(); | ||
await expect( | ||
page.locator("text=Description must be provided") | ||
).toBeVisible(); | ||
|
||
await page.click("#cancel-button-add-game"); | ||
}); | ||
|
||
test("Edit games validations check", async ({ page }) => { | ||
const editButton = page.locator('[data-button="edit-game"]').first(); | ||
await editButton.click(); | ||
|
||
await page.fill('input[placeholder="Game Name"]', ""); | ||
await page.fill('input[placeholder="Game Image (URL Only)"]', ""); | ||
await page.fill('textarea[placeholder="Game description..."]', ""); | ||
|
||
await page.click("#save-button-add-game"); | ||
|
||
await expect(page.locator("text=Game Name must be provided")).toBeVisible(); | ||
await expect( | ||
page.locator("text=Game Image must be a valid URL") | ||
).toBeVisible(); | ||
await expect( | ||
page.locator("text=Description must be provided") | ||
).toBeVisible(); | ||
|
||
await page.click("#cancel-button-add-game"); | ||
}); | ||
|
||
// test("Check add new games", async ({ page }) => { | ||
// await page.click("#add-game-button"); | ||
|
||
// await page.fill('input[placeholder="Game Name"]', "Lost Ark 2"); | ||
// await page.fill( | ||
// 'input[placeholder="Game Image (URL Only)"]', | ||
// "https://www.freetogame.com/g/517/thumbnail.jpg" | ||
// ); | ||
// await page.fill( | ||
// 'textarea[placeholder="Game description..."]', | ||
// "Free-to-play multiplayer massive adventure filled with lands waiting to be explored" | ||
// ); | ||
|
||
// await page.click("#save-button-add-game"); | ||
// await expect(page.locator("text=Game created successfully")).toBeVisible(); | ||
// }); | ||
|
||
// test("Check edit games", async ({ page }) => { | ||
// const editButton = page.locator('[data-button="edit-game"]').first(); | ||
// await editButton.click(); | ||
|
||
// await page.fill('input[placeholder="Game Name"]', "Lost Ark 2 Edited"); | ||
// await page.fill( | ||
// 'input[placeholder="Game Image (URL Only)"]', | ||
// "https://www.freetogame.com/g/517/thumbnail.jpg" | ||
// ); | ||
// await page.fill( | ||
// 'textarea[placeholder="Game description..."]', | ||
// "Edited Free-to-play multiplayer massive adventure filled with lands waiting to be explored" | ||
// ); | ||
|
||
// await page.click("#save-button-add-game"); | ||
// await expect(page.locator("text=Game update successfully")).toBeVisible(); | ||
// }); | ||
|
||
// test("Check delete game", async ({ page }) => { | ||
// const deleteButton = page.locator('[data-button="delete-game"]').first(); | ||
// await deleteButton.click(); | ||
// await expect(page.locator("text=Game deleted successfully")).toBeVisible(); | ||
// }); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { API_ROUTES } from "../support/constants"; | ||
import { mapDataResponse, moderatorExistsResponse } from "../fixtures"; | ||
|
||
test.describe("Leaflet Map Test", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.route(API_ROUTES.CHECK_MODERATOR, async (route) => { | ||
await route.fulfill({ json: moderatorExistsResponse }); | ||
}); | ||
|
||
await page.goto("/login"); | ||
|
||
await page.route(API_ROUTES.LOGIN, async (route) => { | ||
route.fulfill({ | ||
body: JSON.stringify({ token: "mockToken" }), | ||
}); | ||
}); | ||
|
||
await page.fill('input[placeholder="Email"]', "[email protected]"); | ||
await page.fill('input[placeholder="Password"]', "password123"); | ||
await page.click("button"); | ||
|
||
await page.route(API_ROUTES.GET_MAP_DATA, async (route) => { | ||
await route.fulfill({ json: mapDataResponse }); | ||
}); | ||
|
||
await page.goto("/map"); | ||
await page.waitForLoadState("networkidle"); | ||
}); | ||
|
||
test("should render the leaflet map", async ({ page }) => { | ||
const mapContainer = await page.locator("#map-container"); | ||
await expect(mapContainer).toBeVisible(); | ||
}); | ||
|
||
test("should render the map and display markers", async ({ page }) => { | ||
const markers = await page.locator(".leaflet-marker-icon"); | ||
|
||
// Check if markers count is at least 1 | ||
const count = await markers.count(); | ||
expect(count).toBeGreaterThan(0); // Check if count is greater than 0 | ||
|
||
// Ensure all markers are visible | ||
for (let i = 0; i < count; i++) { | ||
await expect(markers.nth(i)).toBeVisible(); | ||
} | ||
}); | ||
|
||
test("should open a popup when a marker is clicked", async ({ page }) => { | ||
const firstMarker = await page.locator(".leaflet-marker-icon").first(); | ||
await firstMarker.click({ force: true }); | ||
await expect(page.locator(".leaflet-popup")).toBeVisible(); | ||
}); | ||
}); |