Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mads Hermansen committed Apr 22, 2024
2 parents 2e4972e + 6b7a2aa commit 1aa5214
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 29 deletions.
35 changes: 23 additions & 12 deletions frontend/src/app/satellites/[satelliteSlug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default async function SatelliteInfoPage({

return (
<>
<div className="flex flex-col items-center ">
<div className="flex flex-col items-center">
<PageHeaderAndSubtitle>
<PageHeader>{satelliteInfo.name}</PageHeader>
<PageSubtitle>
Expand All @@ -62,22 +62,24 @@ export default async function SatelliteInfoPage({
</PageSubtitle>
</PageHeaderAndSubtitle>

{satelliteInfo.launchDate ? (
<div className="mt-6 w-full">
<LaunchDateCountDown
launchDateString={satelliteInfo.launchDate}
></LaunchDateCountDown>
</div>
) : null}
{/* Container for satname, stats and sat image */}
{satelliteInfo.noradId ? (
<div className="flex w-full flex-col border-2 border-gray-600 xl:flex-row">
{/* Stats Container */}
<div className="z-10 flex w-full flex-col border-gray-600 xl:border-r-2">
<div className="border-b border-gray-600 bg-black p-5">
{satelliteInfo.noradId
? "NORAD ID: " + satelliteInfo.noradId
: null}
{satelliteInfo.noradId ? (
<div className="flex flex-row">
<p>NORAD ID: </p>
<a
href={`https://www.n2yo.com/satellite/?s=${satelliteInfo.noradId}`}
target="_blank"
className="ml-2 underline"
>
{satelliteInfo.noradId}
</a>
</div>
) : null}
<p className="text-gray-400">
{satelliteInfo.massKg
? "Mass: " +
Expand Down Expand Up @@ -115,8 +117,17 @@ export default async function SatelliteInfoPage({
</div>
) : null}

{/* Container for launch date */}
{satelliteInfo.launchDate ? (
<div className="w-full">
<LaunchDateCountDown
launchDateString={satelliteInfo.launchDate}
></LaunchDateCountDown>
</div>
) : null}

{/* Container for body content */}
<div className="mt-6">
<div className="mt-6 px-4 sm:px-0">
<BlockRendererClient content={satelliteInfo.content} />
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/2dmap/Map2d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
predictFuturePositions,
} from "@/lib/convertSatrec";

const updateInterval = 50;
const updateInterval = 100;

export default function Map2d({ satName }: { satName: string }) {
const { satelliteData } = useSatelliteStore();
Expand Down Expand Up @@ -94,9 +94,9 @@ export default function Map2d({ satName }: { satName: string }) {

return (
<div ref={containerRef} className="w-full">
<div className="flex items-center justify-between bg-black px-6 py-4">
<h1 className="text-lg font-semibold text-white">
Current and Predicted Satellite Position
<div className="flex flex-col items-center justify-between bg-black px-6 py-4 md:flex-row">
<h1 className="text-center text-lg font-semibold text-white md:text-left">
Satellite Position
</h1>
<div className="flex flex-col items-end">
<input
Expand All @@ -106,11 +106,11 @@ export default function Map2d({ satName }: { satName: string }) {
step="60"
value={inputValue}
onChange={handleSliderChange}
className="rounded-lg bg-gray-200 py-2 text-black focus:outline-none focus:ring"
className="w-full rounded-lg bg-gray-200 py-2 text-black focus:outline-none focus:ring"
/>
<p className="mt-2 font-thin">
Positions {projectionAmount} minutes into the{" "}
{projectionAmount >= 0 ? "future" : "past"}
Projected positions {projectionAmount / 60} hours into
the {projectionAmount >= 0 ? "future" : "past"}
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function CodiconGithubProject(props: SVGProps<SVGSVGElement>) {
export default function Navbar() {
const pathname = usePathname();
const getButtonVariant = (path: string) => {
if (path === pathname) {
if (pathname.includes(path)) {
return;
}
return "ghost";
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/components/homeComponents/homeGlobe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export default function SatelliteGlobe() {
globeRef.current.controls().enablePan = false;
globeRef.current.controls().enableRotate = true;

const setGlobeSize = () => {
// lock the initial height of the globe
const setInitialGlobeSize = () => {
if (globeRef.current && chart.current) {
const { width, height } =
chart.current.getBoundingClientRect();
Expand All @@ -68,7 +69,15 @@ export default function SatelliteGlobe() {
};

// Initially set the globe size to match the container
setGlobeSize();
setInitialGlobeSize();

// set globesize on screen resize
const setGlobeSize = () => {
if (globeRef.current && chart.current) {
const { width } = chart.current.getBoundingClientRect();
globeRef.current.width(width);
}
};

// Resize listener to update the globe size
if (typeof window !== "undefined") {
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/ui/launchDateCountDown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client"; // This directive marks the component for client-side execution

"use client";
import React, { useState, useEffect } from "react";

type LaunchDateCountDownProps = {
Expand Down Expand Up @@ -62,11 +61,11 @@ const LaunchDateCountDown: React.FC<LaunchDateCountDownProps> = ({
)}
</div>

<div className="flex justify-center pt-3">
<hr className="w-32 self-center border-white"></hr>
<div className="mt-8 flex justify-center">
<hr className="w-full max-w-[350px] self-center border-white"></hr>
</div>

<div className="pt-5">
<div className="mt-4">
<div className="rounded-lg p-4 text-center text-4xl tracking-widest text-white shadow-md">
{displayTime.length > 0 && (
<div className="flex justify-center">
Expand Down
2 changes: 2 additions & 0 deletions frontend/tests/componentTests/SatelliteSelector.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import SatelliteSelector from "@/components/homeComponents/SatelliteSelector";
import { test, expect } from "@playwright/experimental-ct-react";
6 changes: 4 additions & 2 deletions frontend/tests/e2e/blog.desktop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ test.describe("Blogs pages test", () => {
await expect(page.getByTestId("pageSubtitle")).toBeVisible();
await page.getByTestId("blogsSatellitesButton").click();
await expect(page).toHaveURL("/blog?page=1&tag=Satellites");
await expect(page.getByTestId("articleTag")).toHaveText("Satellites");
await page.getByTestId("blogCardLink").click();
await expect(page.getByTestId("articleTag").first()).toHaveText(
"Satellites",
);
await page.getByTestId("blogCardLink").first().click();
await expect(page).toHaveURL(/\/blog\/.+$/);
});
test("individualBlogPagetest", async ({ page }) => {
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions frontend/tests/e2e/satellite.desktop.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test, expect } from "@playwright/test";

test.describe("All Satellites Page Test", () => {
test("CheckHeadingAndSubtitleIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(page.getByTestId("pageHeader")).toBeVisible();
await expect(page.getByTestId("pageSubtitle")).toBeVisible();
});
test("CheckIfCardIsClickable", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(
page.getByTestId("satellitesTableRow").first(),
).toBeVisible();
await page.getByTestId("satellitesTableRow").first().click();
//Checks if the URL matches /satellites/anySlug
await expect(page).toHaveURL(/\/satellites\/.+$/);
});
});

test.describe("Individual Satellite Page Test", () => {
test("TestHeadingAndParagraphIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Satellites" }).click();
await page.getByTestId("satellitesTableRow").first().click();
await expect(page).toHaveURL(/\/satellites\/.+$/);
await expect(page.getByRole("heading").first()).toBeVisible();
await expect(page.getByRole("heading").nth(2)).toBeVisible();
await expect(page.getByTestId("blockParagraph").first()).toBeVisible();
});
});
45 changes: 45 additions & 0 deletions frontend/tests/e2e/satellite.mobile.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { test, expect } from "@playwright/test";

test.describe("All Satellites Page Test", () => {
test.use({
viewport: { width: 390, height: 844 },
});

test("CheckHeadingAndSubtitleIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation").getByRole("button").click();
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(page.getByTestId("pageHeader")).toBeVisible();
await expect(page.getByTestId("pageSubtitle")).toBeVisible();
});
test("CheckIfCardIsClickable", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation").getByRole("button").click();
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(
page.getByTestId("satellitesTableRow").first(),
).toBeVisible();
await page.getByTestId("satellitesTableRow").first().click();
//Checks if the URL matches /satellites/anySlug
await expect(page).toHaveURL(/\/satellites\/.+$/);
});
});

test.describe("Individual Satellite Page Test", () => {
test.use({
viewport: { width: 390, height: 844 },
});

test("TestHeadingAndParagraphIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation").getByRole("button").click();
await page.getByRole("button", { name: "Satellites" }).click();
await page.getByTestId("satellitesTableRow").first().click();
await expect(page).toHaveURL(/\/satellites\/.+$/);
await expect(page.getByRole("heading").first()).toBeVisible();
await expect(page.getByRole("heading").nth(2)).toBeVisible();
await expect(page.getByTestId("blockParagraph").first()).toBeVisible();
});
});

0 comments on commit 1aa5214

Please sign in to comment.