Skip to content

Commit 08fd436

Browse files
authored
Merge pull request #223 from w3bdesign/development
CV with tabs
2 parents 09e75e0 + e4e3c16 commit 08fd436

File tree

11 files changed

+371
-115
lines changed

11 files changed

+371
-115
lines changed

__tests__/CV/CVContent.test.tsx

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,54 @@
22
* @jest-environment jsdom
33
*/
44

5+
import React from "react";
56
import { render, screen } from "@testing-library/react";
6-
77
import CVContent from "../../src/components/CV/CVContent.component";
88

9+
const mockCVData = {
10+
keyQualifications: ["Qualification 1", "Qualification 2"],
11+
experience: [
12+
{
13+
period: "2020-2022",
14+
company: "Example Company",
15+
role: "Software Developer",
16+
description: "Worked on various projects",
17+
},
18+
],
19+
education: [
20+
{
21+
period: "2016-2020",
22+
institution: "University of Example",
23+
degree: "Bachelor in Computer Science",
24+
description: "Studied various aspects of computer science",
25+
},
26+
],
27+
};
28+
929
describe("CVContent", () => {
10-
it("CVContent laster inn og kan vises", () => {
11-
render(<CVContent />);
12-
const cvcontent = screen.getByRole("heading", { name: /cv/i });
13-
expect(cvcontent).toBeInTheDocument();
14-
});
30+
it("CVContent renders correctly with mock data", () => {
31+
render(<CVContent cvData={mockCVData} />);
32+
33+
// Check if the CV header is present
34+
const cvHeader = screen.getByRole("heading", { name: /cv/i });
35+
expect(cvHeader).toBeInTheDocument();
36+
37+
// Check if the "Last ned PDF" button is present
38+
const pdfButton = screen.getByRole("link", { name: /last ned pdf/i });
39+
expect(pdfButton).toBeInTheDocument();
40+
41+
// Check if tabs are present
42+
const qualificationsTab = screen.getByRole("tab", {
43+
name: /nøkkelkvalifikasjoner/i,
44+
});
45+
const experienceTab = screen.getByRole("tab", { name: /erfaring/i });
46+
const educationTab = screen.getByRole("tab", { name: /utdanning/i });
47+
expect(qualificationsTab).toBeInTheDocument();
48+
expect(experienceTab).toBeInTheDocument();
49+
expect(educationTab).toBeInTheDocument();
1550

16-
/*
17-
it("PDF laster inn og kan vises", async () => {
18-
render(<CVContent />);
19-
const pdf = await screen.findByText(/nøkkelkvalifikasjoner/i);
20-
expect(pdf).toBeInTheDocument();
51+
// Check if mock data is rendered (you might need to click on tabs to see this content)
52+
const qualification = screen.getByText(/qualification 1/i);
53+
expect(qualification).toBeInTheDocument();
2154
});
22-
*/
2355
});

cypress/e2e/cv.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ describe("Test at CV vises og laster", () => {
1111

1212
it("Se at CV vises", () => {
1313
cy.get("main#maincontent").should("be.visible");
14-
cy.get('.container img[alt="CV"]')
15-
.should("have.length", 2)
14+
cy.get('#tab-qualifications')
15+
.should("have.length", 1)
1616
.and("be.visible");
1717
cy.get('a[href="./cv.pdf"]').should("be.visible");
1818
});

pnpm-lock.yaml

Lines changed: 30 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/cv/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import Header from "@/components/Layout/Header.component";
22
import CVContent from "@/components/CV/CVContent.component";
33

4+
import { client } from "@/lib/sanity/client";
5+
import { cvQuery } from "@/lib/sanity/queries";
6+
47
import { Metadata } from "next/types";
58

69
export const metadata: Metadata = {
710
title: "CV - Dfweb",
811
description: "Daniel Fjeldstad | Frontend Web Utvikler | Portefølje",
912
};
1013

11-
export default async function PostIndex() {
14+
export default async function CVPage() {
15+
const cvData = await client.fetch(cvQuery);
16+
1217
return (
1318
<>
1419
<Header />
15-
<CVContent />
20+
<CVContent cvData={cvData} />
1621
</>
1722
);
1823
}

src/app/middleware.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { NextRequest, NextResponse } from 'next/server'
2-
1+
import { NextRequest, NextResponse } from "next/server";
2+
33
export function middleware(request: NextRequest) {
4-
const nonce = Buffer.from(crypto.randomUUID()).toString('base64')
4+
const nonce = Buffer.from(crypto.randomUUID()).toString("base64");
55
const cspHeader = `
66
default-src 'self';
77
script-src 'self' 'nonce-${nonce}' 'strict-dynamic';
@@ -13,29 +13,29 @@ export function middleware(request: NextRequest) {
1313
form-action 'self';
1414
frame-ancestors 'none';
1515
upgrade-insecure-requests;
16-
`
16+
`;
1717
// Replace newline characters and spaces
1818
const contentSecurityPolicyHeaderValue = cspHeader
19-
.replace(/\s{2,}/g, ' ')
20-
.trim()
21-
22-
const requestHeaders = new Headers(request.headers)
23-
requestHeaders.set('x-nonce', nonce)
24-
19+
.replace(/\s{2,}/g, " ")
20+
.trim();
21+
22+
const requestHeaders = new Headers(request.headers);
23+
requestHeaders.set("x-nonce", nonce);
24+
2525
requestHeaders.set(
26-
'Content-Security-Policy',
27-
contentSecurityPolicyHeaderValue
28-
)
29-
26+
"Content-Security-Policy",
27+
contentSecurityPolicyHeaderValue,
28+
);
29+
3030
const response = NextResponse.next({
3131
request: {
3232
headers: requestHeaders,
3333
},
34-
})
34+
});
3535
response.headers.set(
36-
'Content-Security-Policy',
37-
contentSecurityPolicyHeaderValue
38-
)
39-
40-
return response
41-
}
36+
"Content-Security-Policy",
37+
contentSecurityPolicyHeaderValue,
38+
);
39+
40+
return response;
41+
}

0 commit comments

Comments
 (0)