11import React from 'react' ;
2+ import '@testing-library/jest-dom' ;
23import { fireEvent , render , screen } from '@testing-library/react' ;
34
4- import NavBrand from '@/components/bitcode/layout/NavBrand/NavBrand' ;
5+ import NavBrand , {
6+ BITCODE_WHITEPAPER_URL ,
7+ } from '@/components/bitcode/layout/NavBrand/NavBrand' ;
58
69describe ( 'NavBrand' , ( ) => {
7- it ( 'renders product-surface copy for the terminal workspace' , ( ) => {
8- render ( < NavBrand surface = "terminal" onClick = { ( ) => { } } /> ) ;
9-
10- expect ( screen . getByLabelText ( 'Bitcode logo' ) ) . toBeTruthy ( ) ;
11- expect ( screen . getByText ( 'Bitcode' ) ) . toBeTruthy ( ) ;
12- expect ( screen . getByText ( 'terminal' ) ) . toBeTruthy ( ) ;
13- } ) ;
14-
15- it ( 'renders packs copy for mounted pack activity routes' , ( ) => {
16- render ( < NavBrand surface = "network" onClick = { ( ) => { } } /> ) ;
17-
18- expect ( screen . getByLabelText ( 'Bitcode logo' ) ) . toBeTruthy ( ) ;
19- expect ( screen . getByText ( 'Bitcode' ) ) . toBeTruthy ( ) ;
20- expect ( screen . getByText ( 'packs' ) ) . toBeTruthy ( ) ;
21- } ) ;
22-
23- it ( 'renders homepage copy for the public homepage' , ( ) => {
10+ it ( 'renders logo-area docs and whitepaper links instead of page-name subtext' , ( ) => {
2411 render ( < NavBrand surface = "home" onClick = { ( ) => { } } /> ) ;
2512
2613 expect ( screen . getByLabelText ( 'Bitcode logo' ) ) . toBeTruthy ( ) ;
2714 expect ( screen . getByText ( 'Bitcode' ) ) . toBeTruthy ( ) ;
28- expect ( screen . getByText ( 'homepage' ) ) . toBeTruthy ( ) ;
15+ expect ( screen . queryByText ( 'homepage' ) ) . toBeNull ( ) ;
16+ expect ( screen . getByRole ( 'link' , { name : 'Docs' } ) ) . toHaveAttribute ( 'href' , '/docs' ) ;
17+ expect ( screen . getByRole ( 'link' , { name : 'Whitepaper' } ) ) . toHaveAttribute (
18+ 'href' ,
19+ BITCODE_WHITEPAPER_URL ,
20+ ) ;
21+ expect ( screen . getByRole ( 'link' , { name : 'Whitepaper' } ) ) . toHaveAttribute ( 'target' , '_blank' ) ;
2922 } ) ;
3023
31- it ( 'renders docs copy for mounted docs routes ' , ( ) => {
32- render ( < NavBrand surface = "docs " onClick = { ( ) => { } } /> ) ;
24+ it ( 'keeps docs | whitepaper links on product surfaces (no page-name subtext) ' , ( ) => {
25+ render ( < NavBrand surface = "deposit " onClick = { ( ) => { } } /> ) ;
3326
34- expect ( screen . getByLabelText ( 'Bitcode logo ') ) . toBeTruthy ( ) ;
35- expect ( screen . getByText ( 'Bitcode' ) ) . toBeTruthy ( ) ;
36- expect ( screen . getByText ( 'docs' ) ) . toBeTruthy ( ) ;
27+ expect ( screen . queryByText ( 'deposit ') ) . toBeNull ( ) ;
28+ expect ( screen . getByRole ( 'link' , { name : 'Docs' } ) ) . toHaveAttribute ( 'href' , '/docs' ) ;
29+ expect ( screen . getByRole ( 'link' , { name : 'Whitepaper' } ) ) . toBeInTheDocument ( ) ;
3730 } ) ;
3831
39- it ( 'renders auxillaries copy for mounted auxiliary routes' , ( ) => {
40- render ( < NavBrand surface = "auxillaries " onClick = { ( ) => { } } /> ) ;
32+ it ( 'keeps docs | whitepaper links on docs routes' , ( ) => {
33+ render ( < NavBrand surface = "docs " onClick = { ( ) => { } } /> ) ;
4134
42- expect ( screen . getByLabelText ( 'Bitcode logo' ) ) . toBeTruthy ( ) ;
43- expect ( screen . getByText ( 'Bitcode' ) ) . toBeTruthy ( ) ;
44- expect ( screen . getByText ( 'auxillaries' ) ) . toBeTruthy ( ) ;
35+ expect ( screen . queryByText ( / ^ d o c s $ / i) ) . toBeTruthy ( ) ; // the spelled docs link
36+ expect ( screen . getByRole ( 'link' , { name : 'Docs' } ) ) . toHaveAttribute ( 'href' , '/docs' ) ;
4537 } ) ;
4638
4739 it ( 'renders beta posture outside the product workspace and remains clickable' , ( ) => {
@@ -54,5 +46,15 @@ describe('NavBrand', () => {
5446 expect ( screen . getByText ( 'V26' ) ) . toBeTruthy ( ) ;
5547 expect ( screen . getByText ( 'PRC' ) ) . toBeTruthy ( ) ;
5648 expect ( onClick ) . toHaveBeenCalled ( ) ;
49+ expect ( screen . queryByRole ( 'link' , { name : 'Docs' } ) ) . toBeNull ( ) ;
50+ } ) ;
51+
52+ it ( 'home control remains clickable via the brand mark' , ( ) => {
53+ const onClick = jest . fn ( ) ;
54+
55+ render ( < NavBrand surface = "network" onClick = { onClick } /> ) ;
56+
57+ fireEvent . click ( screen . getByRole ( 'button' , { name : 'Bitcode home' } ) ) ;
58+ expect ( onClick ) . toHaveBeenCalled ( ) ;
5759 } ) ;
5860} ) ;
0 commit comments