Skip to content

Commit

Permalink
Fix flaky preferences test
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Sep 27, 2024
1 parent 730e335 commit 3bfb8a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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
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

0 comments on commit 3bfb8a4

Please sign in to comment.