Skip to content

Commit

Permalink
current progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kayra1 committed May 24, 2024
1 parent 618afe2 commit 97398ed
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 107 deletions.
8 changes: 8 additions & 0 deletions ui/src/app/certificate_requests/page.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import CertificateRequests from './page'

test('CertificateRequestsPage', () => {
render(< CertificateRequests />)
expect(screen.getByRole('table', {})).toBeDefined()
})
1 change: 0 additions & 1 deletion ui/src/app/certificate_requests/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client"

import { useState } from "react"
import { CertificateRequestsTable } from "./table"

export default function CertificateRequests() {
Expand Down
14 changes: 14 additions & 0 deletions ui/src/app/certificate_requests/row.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import Row from './row'

test('Certificate Requests Table Row', () => {
render(<Row id={1} csr='' certificate='' />)
expect(screen.getByRole('table', {})).toBeDefined()

Check failure on line 7 in ui/src/app/certificate_requests/row.test.tsx

View workflow job for this annotation

GitHub Actions / unit-test-frontend / nextjs-unit-tests

src/app/certificate_requests/row.test.tsx > Certificate Requests Table Row

TestingLibraryElementError: Unable to find an accessible element with the role "table" Here are the accessible roles: row: Name "1 CN: example.com SAN: example.com, 127.0.0.1, 1.2.3.4.5.56 outstanding Sign Reject Delete CSR": <tr data-test-model-uuid="2f995dee-392e-4459-8eb9-839c501590af" /> -------------------------------------------------- cell: Name "1": <td class="" data-test-column="id" /> Name "CN: example.com SAN: example.com, 127.0.0.1, 1.2.3.4.5.56": <td class="u-overflow--visible" data-test-column="details" /> Name "outstanding": <td class="" data-test-column="status" /> Name "Sign Reject": <td class="" data-test-column="action" /> Name "Delete CSR": <td class="" data-test-column="delete" /> -------------------------------------------------- paragraph: Name "": <p /> Name "": <p /> -------------------------------------------------- button: Name "Sign": <button /> Name "Reject": <button /> Name "Delete CSR": <button /> -------------------------------------------------- Ignored nodes: comments, script, style <body> <div> <tr data-test-model-uuid="2f995dee-392e-4459-8eb9-839c501590af" > <td class="" data-test-column="id" > 1 </td> <td class="u-overflow--visible" data-test-column="details" > <p> CN: example.com </p> <p> SAN: example.com, 127.0.0.1, 1.2.3.4.5.56 </p> </td> <td class="" data-test-column="status" > outstanding </td> <td class="" data-test-column="action" > <button> Sign </button> <button> Reject </button> </td> <td class="" data-test-column="delete" > <button> Delete CSR </button> </td> </tr> </div> </body> ❯ Object.getElementError node_modules/@testing-library/dom/dist/config.js:37:19 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:76:38 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:52:17 ❯ node_modules/@testing-library/dom/dist/query-helpers.js:95:19 ❯ src/app/certificate_requests/row.test.tsx:7:19
})
// when certificate rejected => rejected status
// when certificate empty => outstanding status
// when certificate anything else => certificate.NotAfter


// TODO button call correct api endpoints test
32 changes: 32 additions & 0 deletions ui/src/app/certificate_requests/row.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const extractCSR = (csrPemString: string) => {
//TODO
}

const extractCert = (certPemString: string) => {
//TODO
}

type rowProps = {
id: number,
csr: string,
certificate: string
}
export default function Row({ id, csr, certificate }: rowProps) {
return (
<tr data-test-model-uuid="2f995dee-392e-4459-8eb9-839c501590af">
<td className="" data-test-column="id">{id}</td>
<td className="u-overflow--visible" data-test-column="details">
<p>CN: example.com</p>
<p>SAN: example.com, 127.0.0.1, 1.2.3.4.5.56</p>
</td>
<td className="" data-test-column="status">{certificate == "" ? "outstanding" : (certificate == "rejected" ? "rejected" : "certificate expiry date here")}</td>
<td className="" data-test-column="action">
<button>Sign</button>
<button>Reject</button>
</td>
<td className="" data-test-column="delete">
<button>Delete CSR</button>
</td>
</tr>
)
}
2 changes: 2 additions & 0 deletions ui/src/app/certificate_requests/table.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

// when add cert button clicked, asideOpen called
21 changes: 5 additions & 16 deletions ui/src/app/certificate_requests/table.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Dispatch, SetStateAction, useContext } from "react"
import { AsideContext } from "../nav"
import Row from "./row"


export function CertificateRequestsTable() {
const { isOpen: isAsideOpen, setIsOpen: setAsideIsOpen } = useContext(AsideContext)
return (
<div className="p-panel">
<div className="p-panel__header">
<div className="p-panel__header is-sticky">
<h4 className="p-panel__title">Certificate Requests</h4>
<div className="p-panel__controls">
<button className="u-no-margin--bottom" onClick={() => setAsideIsOpen(true)}>Add New CSR</button>
Expand All @@ -25,21 +26,9 @@ export function CertificateRequestsTable() {
</tr>
</thead>
<tbody>
<tr data-test-model-uuid="2f995dee-392e-4459-8eb9-839c501590af">
<td className="" data-test-column="id">1</td>
<td className="u-overflow--visible" data-test-column="details">
<p>CN: example.com</p>
<p>SAN: example.com, 127.0.0.1, 1.2.3.4.5.56</p>
</td>
<td className="" data-test-column="status">outstanding</td>
<td className="" data-test-column="action">
<button>Sign</button>
<button>Reject</button>
</td>
<td className="" data-test-column="delete">
<button>Delete CSR</button>
</td>
</tr>
<Row id={1} csr="csr1" certificate="" />
<Row id={2} csr="csr2" certificate="rejected" />
<Row id={3} csr="csr3" certificate="a real cert" />
</tbody>
</table>
</div>
Expand Down
90 changes: 1 addition & 89 deletions ui/src/app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,4 @@
@import 'node_modules/vanilla-framework';

// Include all of Vanilla Framework
@include vanilla;

body {
margin: 0 !important;
/* override codepen embedded examples styles */
}

/* application layout demo styles */
.l-application .u-fixed-width {
/* temporary, as I don't want to change the global setting */
max-width: 95rem;
}

.demo-status {
background-color: #f7f7f7;
/* $colors--light-theme--background-alt; */
padding-bottom: 0.75rem;
/* $spv--medium; */
padding-top: 0.75rem;
}

/* demo JAAS CSS */
.u-flex {
display: flex;
}

.u-flex--block {
flex: 1 1 auto;
}

.has-icon [class*='p-icon']:first-child {
margin-right: 0.25rem;
margin-top: 0.25rem;
}

.status-icon {
display: inline-block;
padding-left: 1.5rem;
position: relative;
}

.status-icon::before {
content: '\00B7';
font-size: 5rem;
left: 0;
position: absolute;
top: -6px;
}

.status-icon.is-blocked::before,
.status-icon.is-down::before,
.status-icon.is-error::before,
.status-icon.is-provisioning::before {
color: #c7162b;
}

.status-icon.is-alert::before,
.status-icon.is-attention::before,
.status-icon.is-maintenance::before,
.status-icon.is-pending::before,
.status-icon.is-stopped::before,
.status-icon.is-waiting::before {
color: #f99b11;
}

.status-icon.is-active::before,
.status-icon.is-running::before,
.status-icon.is-started::before {
color: #cdcdcd;
}

.status-icon.is-unknown::before {
border: 1px solid #cdcdcd;
border-radius: 50%;
content: '';
height: 0.6rem;
left: 0.35rem;
top: 0.5rem;
width: 0.6rem;
}

table thead::after {
content: none;
}

td,
th {
min-width: 150px;
}
@include vanilla;
2 changes: 1 addition & 1 deletion ui/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export default function RootLayout({
</body>
</html>
);
}
}
Empty file added ui/src/app/nav.test.tsx
Empty file.

0 comments on commit 97398ed

Please sign in to comment.