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

test: Rewrite disabled Dashboard tests #2964

Merged
merged 10 commits into from
Oct 14, 2024
2 changes: 1 addition & 1 deletion frontend/js/src/common/listens/ListenCountCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function ListenCountCard(props: ListenCountCardProps) {

if (listenCount) {
content = (
<div>
<div data-testid="listen-count-card-content">
{isCurrentUser ? "You have" : `${user.name} has`} listened to
<hr />
{listenCount.toLocaleString()}
Expand Down
4 changes: 3 additions & 1 deletion frontend/js/src/report-user/ReportUserModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useCallback, useState, useContext } from "react";
import * as React from "react";
import { toast } from "react-toastify";
import { Link } from "react-router-dom";
import GlobalAppContext from "../utils/GlobalAppContext";
import { ToastMsg } from "../notifications/Notifications";

const { useCallback, useState, useContext } = React;

type ReportUserModalProps = {
onSubmit: (optionalReason?: string) => void;
reportedUserName: string;
Expand Down
12 changes: 8 additions & 4 deletions frontend/js/tests/common/listens/ListenCountCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ const globalContext: GlobalAppContextT = {
describe("ListenCountCard", () => {
it("renders correctly when listen count is not zero", () => {
const wrapper = mount(<ListenCountCard user={user} listenCount={100} />);
expect(wrapper.getDOMNode()).toHaveTextContent("track_listener has listened to100songs so far");
expect(wrapper.getDOMNode()).toHaveTextContent(
"track_listener has listened to100songs so far"
);
});
it("renders correctly when listen count is zero or undefined", () => {
const wrapper = mount(<ListenCountCard user={user} />);
expect(wrapper.getDOMNode()).toHaveTextContent("track_listener's listens counttrack_listener hasn't listened to any songs yet.")
expect(wrapper.getDOMNode()).toHaveTextContent(
"track_listener's listens counttrack_listener hasn't listened to any songs yet."
);
});
it("renders user's name instead of 'You' when visiting another user's page", () => {
const wrapper = mount(
Expand All @@ -46,7 +50,7 @@ describe("ListenCountCard", () => {
const countCard = wrapper.find("#listen-count-card").first().children();
const cardDiv = countCard.children().first();
expect(cardDiv.html()).toEqual(
'<div>track_listener has listened to<hr>100<br><small class="text-muted">songs so far</small></div>'
'<div data-testid="listen-count-card-content">track_listener has listened to<hr>100<br><small class="text-muted">songs so far</small></div>'
);
});
it("renders 'You' when on current user's page", () => {
Expand All @@ -58,7 +62,7 @@ describe("ListenCountCard", () => {
const countCard = wrapper.find("#listen-count-card").first().children();
const cardDiv = countCard.children().first();
expect(cardDiv.html()).toEqual(
'<div>You have listened to<hr>100<br><small class="text-muted">songs so far</small></div>'
'<div data-testid="listen-count-card-content">You have listened to<hr>100<br><small class="text-muted">songs so far</small></div>'
);
});
});
Loading
Loading