Skip to content

Commit

Permalink
Add test setup for e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat committed Dec 28, 2023
1 parent 0c55f52 commit 04a73a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
8 changes: 7 additions & 1 deletion frontend/test/playwright/e2e/all-results-analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { test } from "@playwright/test"

import { openFirstResult } from "~~/test/playwright/utils/navigation"
import {
openFirstResult,
preparePageForTests,
turnOnAnalytics,
} from "~~/test/playwright/utils/navigation"
import {
collectAnalyticsEvents,
expectEventPayloadToMatch,
Expand All @@ -10,6 +14,8 @@ import { AUDIO, IMAGE } from "~/constants/media"

test.describe("all results grid analytics test", () => {
test.beforeEach(async ({ page }) => {
await preparePageForTests(page, "xl")
await turnOnAnalytics(page)
await page.goto("/search/?q=birds")
})

Expand Down
8 changes: 8 additions & 0 deletions frontend/test/playwright/e2e/audio-detail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
collectAnalyticsEvents,
expectEventPayloadToMatch,
} from "~~/test/playwright/utils/analytics"
import {
preparePageForTests,
turnOnAnalytics,
} from "~~/test/playwright/utils/navigation"

const goToCustomAudioPage = async (page: Page) => {
// Test in a custom audio detail page, it should apply the same for any audio.
Expand Down Expand Up @@ -37,6 +41,10 @@ test.describe("analytics", () => {
id: "7e063ee6-343f-48e4-a4a5-f436393730f6",
provider: "jamendo",
}
test.beforeEach(async ({ page }) => {
await preparePageForTests(page, "xl")
await turnOnAnalytics(page)
})
test("sends GET_MEDIA event on CTA button click", async ({
context,
page,
Expand Down
9 changes: 8 additions & 1 deletion frontend/test/playwright/e2e/global-audio.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { expect, test } from "@playwright/test"

import { sleep, t } from "~~/test/playwright/utils/navigation"
import {
preparePageForTests,
sleep,
t,
} from "~~/test/playwright/utils/navigation"
import breakpoints from "~~/test/playwright/utils/breakpoints"
import audio from "~~/test/playwright/utils/audio"

Expand All @@ -9,6 +13,7 @@ test.describe("Global Audio", () => {
test("track continues playing when navigating from search to details page", async ({
page,
}) => {
await preparePageForTests(page, "xs")
await page.goto("/search/audio?q=honey&length=shortest")
// Find and play the first audio result
const firstAudioRow = await audio.getNthAudioRow(page, 0)
Expand All @@ -25,6 +30,7 @@ test.describe("Global Audio", () => {
})

test("track can be closed while playing", async ({ page }) => {
await preparePageForTests(page, "xs")
await page.goto("/search/audio?q=honey")
// Find and play the first audio result
const firstAudioRow = await audio.getNthAudioRow(page, 0)
Expand All @@ -45,6 +51,7 @@ test.describe("Global Audio", () => {
test("player does not reproduce an audio different that the current audio in the details page", async ({
page,
}) => {
await preparePageForTests(page, "xs")
await page.goto("/search/audio?q=honey&length=shortest")
// Find and play the first audio result
const firstAudioRow = await audio.getNthAudioRow(page, 0)
Expand Down

0 comments on commit 04a73a2

Please sign in to comment.