Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Remove the searchBy creator filter from the filters list #2146

Merged
merged 7 commits into from
Feb 15, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const NoResultsTemplate = (args) => ({
license_type: "",
mature: false,
q: "sad person",
searchBy: "",
},
}}
>
Expand Down
1 change: 0 additions & 1 deletion src/components/VExternalSearch/VExternalSearchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export default defineComponent({
/**
* Find the last focusable element in VSearchGridFilter to add a 'Tab' keydown event
* handler to it.
* We could actually hard-code this because 'searchBy' is always the last now.
*/
const lastFocusableElement = computed<HTMLElement>(() => {
const focusable = getFocusableElements(sectionRef.value)
Expand Down
14 changes: 3 additions & 11 deletions src/components/VFilters/VFilterChecklist.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<fieldset class="mb-8">
<legend v-if="title" class="text-sm font-semibold">
{{ title }}
</legend>
<legend class="label-bold">{{ title }}</legend>
<div
v-for="(item, index) in options"
:key="index"
Expand All @@ -12,7 +10,7 @@
:id="item.code"
:key="index"
:checked="item.checked"
:name="itemName"
:name="title"
:value="item.code"
:disabled="isDisabled(item)"
@change="onValueChange"
Expand Down Expand Up @@ -57,7 +55,7 @@
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from "@nuxtjs/composition-api"
import { defineComponent, PropType } from "@nuxtjs/composition-api"

import { useSearchStore } from "~/stores/search"
import { useI18n } from "~/composables/use-i18n"
Expand Down Expand Up @@ -114,11 +112,6 @@ export default defineComponent({
},
setup(props, { emit }) {
const i18n = useI18n()
const itemName = computed(() => {
return props.filterType === "searchBy"
? i18n.t("filters.search-by.title")
: props.title
})

const itemLabel = (item: FilterItem) =>
["audioProviders", "imageProviders"].indexOf(props.filterType) > -1
Expand Down Expand Up @@ -149,7 +142,6 @@ export default defineComponent({

return {
icons,
itemName,
isDisabled,
itemLabel,
onValueChange,
Expand Down
4 changes: 1 addition & 3 deletions src/components/VFilters/VSearchGridFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ export default defineComponent({
() => Object.keys(filters.value) as NonMatureFilterCategory[]
)
const filterTypeTitle = (filterType: string) =>
filterType === "searchBy"
? ""
: i18n.t(`filters.${kebab(filterType)}.title`)
i18n.t(`filters.${kebab(filterType)}.title`)

/**
* This watcher fires even when the queries are equal. We update the path only
Expand Down
7 changes: 5 additions & 2 deletions src/stores/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,14 @@ export const useSearchStore = defineStore("search", {
},

/**
* Returns the object with filters for selected search type, with codes, names for i18n labels, and checked status.
* Returns the object with filters for selected search type,
* with codes, names for i18n labels, and checked status.
*
* Excludes `searchBy` and `mature` filters that we don't display.
*/
searchFilters(state) {
return mediaFilterKeys[state.searchType]
.filter((filterKey) => filterKey !== "mature")
.filter((filterKey) => !["searchBy", "mature"].includes(filterKey))
.reduce((obj, filterKey) => {
obj[filterKey] = this.filters[filterKey]
return obj
Expand Down
198 changes: 0 additions & 198 deletions test/playwright/e2e/filters-old.spec.ts

This file was deleted.

17 changes: 10 additions & 7 deletions test/playwright/e2e/filters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const assertCheckboxCount = async (
}

const FILTER_COUNTS = {
[ALL_MEDIA]: 11,
[AUDIO]: 32,
[IMAGE]: 70,
[ALL_MEDIA]: 10,
[AUDIO]: 31,
[IMAGE]: 69,
}

breakpoints.describeMobileAndDesktop(() => {
Expand All @@ -65,7 +65,8 @@ breakpoints.describeMobileAndDesktop(() => {
"/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page)
const expectedFilters = ["cc0", "commercial", "creator"]
// Creator filter was removed from the UI
const expectedFilters = ["cc0", "commercial"]

for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
Expand All @@ -79,7 +80,8 @@ breakpoints.describeMobileAndDesktop(() => {
"/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
)
await openFilters(page)
const expectedFilters = ["cc0", "commercial", "creator"]
// Creator filter was removed from the UI
const expectedFilters = ["cc0", "commercial"]

for (const checkbox of expectedFilters) {
await assertCheckboxStatus(page, checkbox)
Expand All @@ -103,14 +105,15 @@ breakpoints.describeMobileAndDesktop(() => {
)
await openFilters(page)

for (const checkbox of ["cc0", "commercial", "creator"]) {
// Creator filter was removed from the UI
for (const checkbox of ["cc0", "commercial"]) {
await assertCheckboxStatus(page, checkbox)
}

await changeContentType(page, "All content")

await openFilters(page)
await expect(page.locator('input[type="checkbox"]:checked')).toHaveCount(3)
await expect(page.locator('input[type="checkbox"]:checked')).toHaveCount(2)

await expect(page).toHaveURL(
"/search/?q=cat&license_type=commercial&license=cc0&searchBy=creator"
Expand Down
Loading