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

chore(project): add anchor tags for better seo #345

Merged
merged 26 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2b18938
fix(project): e2e tests
olga-jwp Jul 25, 2023
f0398a1
fix(project): set card url prop required
olga-jwp Jul 26, 2023
9d86f5e
fix(project): fix Card tests
olga-jwp Jul 26, 2023
ae61a01
chore(project): code cleanup for cards seo
olga-jwp Jul 26, 2023
5af16a3
fix(project): aff url for card tests
olga-jwp Jul 26, 2023
ea1e4d6
fix(project): remove conditional url
olga-jwp Jul 26, 2023
8a1dff2
fix(project): update test snap
olga-jwp Jul 26, 2023
7778618
fix(project): search refactoring
olga-jwp Jul 26, 2023
5233e2d
chore(project): code cleanup
olga-jwp Jul 27, 2023
9b168f4
chore(project): code cleanup
olga-jwp Jul 27, 2023
f0ada87
chore(project): code cleanup
olga-jwp Jul 28, 2023
c6fbbc7
chore(project): fix unit test
olga-jwp Jul 28, 2023
508d4c3
Merge branch 'develop' into chore/seo-add-anchor-tag
olga-jwp Jul 28, 2023
db164ae
Merge branch 'feature/cumulative-seo-cards' into chore/seo-add-anchor…
olga-jwp Jul 28, 2023
595e55d
fix(project): resolve merge conflicts
olga-jwp Jul 28, 2023
48a983a
chore(project): add redirect url for series cards
olga-jwp Jul 28, 2023
32465ce
fix(project): remove onKeyDown from card
olga-jwp Jul 31, 2023
541a188
fix(project): update e2e tests
olga-jwp Aug 1, 2023
74d2423
chore(project): add getURL for setting anchor links
olga-jwp Aug 2, 2023
2d69e3c
fix(project): fix urls for card links
olga-jwp Aug 2, 2023
5abe506
fix(project): fix urls for card links
olga-jwp Aug 2, 2023
ff2e153
fix(project): update CardGrid tests
olga-jwp Aug 2, 2023
d83c736
Merge branch 'feature/cumulative-seo-cards' into chore/seo-add-anchor…
olga-jwp Aug 2, 2023
9e8c5cc
fix(project): update CardGrid tests
olga-jwp Aug 2, 2023
1388ad2
fix(project): e2e tests
olga-jwp Aug 2, 2023
b6c6df5
fix(project): e2e mobile tests
olga-jwp Aug 2, 2023
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
8 changes: 4 additions & 4 deletions src/components/Card/Card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ const itemWithImage = { title: 'This is a movie', duration: 120, cardImage: 'htt

describe('<Card>', () => {
it('renders card with video title', () => {
const { getByText } = renderWithRouter(<Card item={item} onClick={() => ''} />);
const { getByText } = renderWithRouter(<Card item={item} onClick={() => ''} url="" />);
dbudzins marked this conversation as resolved.
Show resolved Hide resolved
expect(getByText(/aa/i)).toBeTruthy();
});

it('renders tag with correct duration', () => {
const { getByText } = renderWithRouter(<Card item={item} onClick={() => ''} />);
const { getByText } = renderWithRouter(<Card item={item} onClick={() => ''} url="" />);
expect(getByText(/2/i)).toBeTruthy();
});

it('renders the image with the image prop when valid', () => {
const { getByAltText } = renderWithRouter(<Card item={itemWithImage} onClick={() => ''} />);
const { getByAltText } = renderWithRouter(<Card item={itemWithImage} onClick={() => ''} url="" />);

expect(getByAltText('This is a movie')).toHaveAttribute('src', 'http://movie.jpg?width=320');
});

it('makes the image visible after load', () => {
const { getByAltText } = renderWithRouter(<Card item={itemWithImage} onClick={() => ''} />);
const { getByAltText } = renderWithRouter(<Card item={itemWithImage} onClick={() => ''} url="" />);

expect(getByAltText('This is a movie')).toHaveAttribute('src', 'http://movie.jpg?width=320');
expect(getByAltText('This is a movie')).toHaveStyle({ opacity: 0 });
Expand Down
4 changes: 2 additions & 2 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type CardProps = {
isCurrent?: boolean;
isLocked?: boolean;
currentLabel?: string;
url?: string;
url: string;
};

function Card({
Expand Down Expand Up @@ -90,7 +90,7 @@ function Card({

return (
<Link
to={url ?? ''}
to={disabled ? '/' : url}
dbudzins marked this conversation as resolved.
Show resolved Hide resolved
className={cardClassName}
onClick={onClick}
onMouseEnter={onHover}
Expand Down
4 changes: 2 additions & 2 deletions src/components/CardGrid/CardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CardGridProps = {
hasLoadMore?: boolean;
loadMore?: () => void;
onCardHover?: (item: PlaylistItem) => void;
onCardClick: (item: PlaylistItem, playlistId?: string) => void;
onCardClick?: (item: PlaylistItem, playlistId?: string) => void;
};

function CardGrid({
Expand Down Expand Up @@ -78,7 +78,7 @@ function CardGrid({
<Card
progress={watchHistory ? watchHistory[mediaid] : undefined}
url={url}
onClick={() => onCardClick(playlistItem, playlistItem.feedid)}
onClick={() => onCardClick && onCardClick(playlistItem, playlistItem.feedid)}
onHover={typeof onCardHover === 'function' ? () => onCardHover(playlistItem) : undefined}
loading={isLoading}
isCurrent={currentCardItem && currentCardItem.mediaid === mediaid}
Expand Down
1 change: 0 additions & 1 deletion src/components/Favorites/Favorites.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('<Favorites>', () => {
playlist={playlist}
error={error}
isLoading={isLoading}
onCardClick={() => null}
onCardHover={() => null}
onClearFavoritesClick={() => null}
hasSubscription={true}
Expand Down
4 changes: 1 addition & 3 deletions src/components/Favorites/Favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Props = {
isLoading: boolean;
accessModel: AccessModel;
hasSubscription: boolean;
onCardClick: (item: PlaylistItem) => void;
onCardHover?: (item: PlaylistItem) => void;
onClearFavoritesClick: () => void;
};
Expand All @@ -30,7 +29,7 @@ const cols: Breakpoints = {
[Breakpoint.xl]: 3,
};

const Favorites = ({ playlist, error, isLoading, accessModel, hasSubscription, onCardClick, onCardHover, onClearFavoritesClick }: Props): JSX.Element => {
const Favorites = ({ playlist, error, isLoading, accessModel, hasSubscription, onCardHover, onClearFavoritesClick }: Props): JSX.Element => {
const { t } = useTranslation('user');

if (isLoading) return <LoadingOverlay />;
Expand All @@ -48,7 +47,6 @@ const Favorites = ({ playlist, error, isLoading, accessModel, hasSubscription, o
{playlist.playlist.length > 0 ? (
<CardGrid
playlist={playlist}
onCardClick={onCardClick}
onCardHover={onCardHover}
cols={cols}
isLoading={isLoading}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Shelf/Shelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Shelf = ({
isLocked={isLocked(accessModel, isLoggedIn, hasSubscription, item)}
posterAspect={posterAspect}
item={item}
url={isInView ? url : undefined}
url={url}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import shallow from 'zustand/shallow';

import styles from './PlaylistGrid.module.scss';

import { mediaURL } from '#src/utils/formatting';
import { filterPlaylist, getFiltersFromConfig } from '#src/utils/collection';
import CardGrid from '#components/CardGrid/CardGrid';
import Filter from '#components/Filter/Filter';
import { useAccountStore } from '#src/stores/AccountStore';
import { useConfigStore } from '#src/stores/ConfigStore';
import type { Playlist, PlaylistItem } from '#types/playlist';
import type { Playlist } from '#types/playlist';
import type { ScreenComponent } from '#types/screens';

const PlaylistGrid: ScreenComponent<Playlist> = ({ data, isLoading }) => {
const navigate = useNavigate();
const { config, accessModel } = useConfigStore(({ config, accessModel }) => ({ config, accessModel }), shallow);

const [filter, setFilter] = useState<string>('');
Expand All @@ -32,8 +29,6 @@ const PlaylistGrid: ScreenComponent<Playlist> = ({ data, isLoading }) => {
setFilter('');
}, [data.feedid]);

const onCardClick = (playlistItem: PlaylistItem) => navigate(mediaURL({ media: playlistItem, playlistId: data.feedid }));

const pageTitle = `${data.title} - ${config.siteName}`;

return (
Expand All @@ -48,14 +43,7 @@ const PlaylistGrid: ScreenComponent<Playlist> = ({ data, isLoading }) => {
{shouldShowFilter && <Filter name="genre" value={filter} defaultLabel="All" options={categories} setValue={setFilter} />}
</header>
<main className={styles.main}>
<CardGrid
playlist={filteredPlaylist}
onCardClick={onCardClick}
accessModel={accessModel}
isLoggedIn={!!user}
hasSubscription={!!subscription}
isLoading={isLoading}
/>
<CardGrid playlist={filteredPlaylist} accessModel={accessModel} isLoggedIn={!!user} hasSubscription={!!subscription} isLoading={isLoading} />
dbudzins marked this conversation as resolved.
Show resolved Hide resolved
</main>
</div>
);
Expand Down
9 changes: 2 additions & 7 deletions src/pages/Search/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React, { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router';
import { useParams } from 'react-router';
import { Helmet } from 'react-helmet';
import { useTranslation } from 'react-i18next';
import shallow from 'zustand/shallow';

import styles from './Search.module.scss';

import { useUIStore } from '#src/stores/UIStore';
import { mediaURL } from '#src/utils/formatting';
import { useAccountStore } from '#src/stores/AccountStore';
import { useConfigStore } from '#src/stores/ConfigStore';
import useFirstRender from '#src/hooks/useFirstRender';
import type { PlaylistItem } from '#types/playlist';
import useSearchQueryUpdater from '#src/hooks/useSearchQueryUpdater';
import CardGrid from '#components/CardGrid/CardGrid';
import ErrorPage from '#components/ErrorPage/ErrorPage';
Expand All @@ -25,7 +23,6 @@ const Search = () => {
const firstRender = useFirstRender();
const searchQuery = useUIStore((state) => state.searchQuery);
const { updateSearchQuery } = useSearchQueryUpdater();
const navigate = useNavigate();
const params = useParams();
const query = params['*'];
const { isFetching, error, data: playlist } = usePlaylist(features?.searchPlaylist || '', { search: query || '' }, true, !!query);
Expand All @@ -44,13 +41,11 @@ const Search = () => {
}
}, [firstRender, query, searchQuery, updateSearchQuery]);

const onCardClick = (playlistItem: PlaylistItem) => {
const onCardClick = () => {
useUIStore.setState({
dbudzins marked this conversation as resolved.
Show resolved Hide resolved
searchQuery: '',
searchActive: false,
});

navigate(mediaURL({ media: playlistItem, playlistId: features?.searchPlaylist }));
};

if ((error || !playlist) && !isFetching) {
Expand Down
4 changes: 0 additions & 4 deletions src/pages/User/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import shallow from 'zustand/shallow';
import styles from './User.module.scss';

import PlaylistContainer from '#src/containers/PlaylistContainer/PlaylistContainer';
import { mediaURL } from '#src/utils/formatting';
import AccountCircle from '#src/icons/AccountCircle';
import Favorite from '#src/icons/Favorite';
import BalanceWallet from '#src/icons/BalanceWallet';
Expand All @@ -20,7 +19,6 @@ import Payment from '#components/Payment/Payment';
import AccountComponent from '#components/Account/Account';
import Button from '#components/Button/Button';
import Favorites from '#components/Favorites/Favorites';
import type { PlaylistItem } from '#types/playlist';
import { getReceipt, logout } from '#src/stores/AccountController';
import { clear as clearFavorites } from '#src/stores/FavoritesController';
import { getSubscriptionSwitches } from '#src/stores/CheckoutController';
Expand Down Expand Up @@ -58,7 +56,6 @@ const User = (): JSX.Element => {
const offerSwitches = useCheckoutStore((state) => state.offerSwitches);
const location = useLocation();

const onCardClick = (playlistItem: PlaylistItem) => navigate(mediaURL({ media: playlistItem }));
const onLogout = useCallback(async () => {
// Empty customer on a user page leads to navigate (code bellow), so we don't repeat it here
await logout();
Expand Down Expand Up @@ -154,7 +151,6 @@ const User = (): JSX.Element => {
playlist={playlist}
error={error}
isLoading={isLoading}
onCardClick={onCardClick}
onClearFavoritesClick={() => setClearFavoritesOpen(true)}
accessModel={accessModel}
hasSubscription={!!subscription}
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/tests/playlist_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Scenario('I can filter and click on a card and navigate to the video screen', as
});

function canNavigateToBigBuckBunny(I: CodeceptJS.I) {
I.click({ css: 'div[aria-label="Play Big Buck Bunny"]' });
I.click({ css: 'a[aria-label="Big Buck Bunny"]' });

I.see(constants.bigBuckBunnyDescription);
I.see(constants.startWatchingButton);
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/tests/watch_history/local_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Scenario('I can see my watch history on the Home screen', async ({ I }) => {
I.see('10 min');
});

const selector = `${makeShelfXpath(ShelfId.continueWatching)}//div[@aria-label="Play ${videoTitle}"]`;
const selector = `${makeShelfXpath(ShelfId.continueWatching)}//a[@aria-label="${videoTitle}"]`;
await checkProgress(I, selector, (200 / videoLength) * 100);

I.click(selector);
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/tests/watch_history/logged_in_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function runTestSuite(config: typeof testConfigs.svod, configNoWatchlist: typeof
I.see('10 min');
});

const selector = `${makeShelfXpath(ShelfId.continueWatching)}//div[@aria-label="Play ${videoTitle}"]`;
const selector = `${makeShelfXpath(ShelfId.continueWatching)}//a[@aria-label="${videoTitle}"]`;
await checkProgress(I, selector, (80 / videoLength) * 100);

I.click(selector);
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/utils/steps_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ const stepsObj = {
scrollToTheRight: boolean = true,
preOpenCallback?: (locator: string) => void,
) {
const locator = `//div[@aria-label="Play ${name}"]`;
const locator = `//a[@aria-label="${name}"]`;
const shelfXpath = shelf ? makeShelfXpath(shelf) : undefined;

if (shelfXpath) {
Expand Down
Loading