Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test from #4995 #4999

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/src/pages/preferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useFeatureFlagStore } from "~/stores/feature-flag"
import { isFlagName } from "~/types/feature-flag"
import { SWITCHABLE, ON, OFF } from "~/constants/feature-flag"

import { useHydrating } from "~/composables/use-hydrating"

import VContentPage from "~/components/VContentPage.vue"
import VCheckbox from "~/components/VCheckbox/VCheckbox.vue"

Expand Down Expand Up @@ -50,6 +52,8 @@ const flagsBySwitchable = computed(() => {
const featureGroups = computed(() => {
return featureFlagStore.getFeatureGroups()
})

const doneHydrating = computed(() => useHydrating())
</script>

<template>
Expand Down Expand Up @@ -86,6 +90,7 @@ const featureGroups = computed(() => {
class="flex-row items-center"
:checked="flag.state === ON"
is-switch
:disabled="!doneHydrating"
@change="handleChange"
>{{ $t(`prefPage.features.${flag.name}`) }}</VCheckbox
>
Expand Down
5 changes: 4 additions & 1 deletion frontend/test/playwright/e2e/attribution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ const copyAttribution = async (
) => {
const formatPattern = new RegExp(formatTitle[formatId], "i")

// Ensure the page is fully hydrated before interacting with it.
const copyButton = getCopyButton(page)
await expect(copyButton).toBeEnabled()

await page.getByRole("tab", { name: formatPattern }).click()

await expect(
page.getByRole("tabpanel", { name: formatPattern })
).toBeVisible()

const copyButton = getCopyButton(page)
await expect(copyButton).toHaveAttribute("id", `copyattr-${formatId}`)
await copyButton.click()

Expand Down
6 changes: 5 additions & 1 deletion frontend/test/playwright/e2e/preferences.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect, Page } from "@playwright/test"
import { expect, Page, test } from "@playwright/test"

import { preparePageForTests } from "~~/test/playwright/utils/navigation"

Expand Down Expand Up @@ -114,8 +114,12 @@ test.describe("switchable features", () => {
}) => {
await page.goto(`/preferences`)
const featureFlag = await getSwitchableInput(page, name, checked)

await featureFlag.click()

// Ensure the feature flag is updated
await getSwitchableInput(page, name, !checked)

const storageCookie = { cookie: "features", session: "sessionFeatures" }[
featureData.features[name as FlagName].storage as "cookie" | "session"
]
Expand Down