@@ -53,6 +53,30 @@ describe('Attribution Component', () => {
5353 expect ( linksContainer ) . toHaveClass ( 'attribution-links' ) ;
5454 expect ( firstLink ) . toHaveClass ( 'attribution-link' ) ;
5555 } ) ;
56+
57+ it ( 'should display the repository section' , ( ) => {
58+ render ( < Attribution /> ) ;
59+
60+ expect ( screen . getByText ( 'Open Source Project' ) ) . toBeInTheDocument ( ) ;
61+ expect ( screen . getByText ( 'View on GitHub' ) ) . toBeInTheDocument ( ) ;
62+
63+ const repoLink = screen . getByLabelText ( 'View source code on GitHub' ) ;
64+ expect ( repoLink ) . toBeInTheDocument ( ) ;
65+ expect ( repoLink ) . toHaveAttribute ( 'href' , 'https://github.com/DeDuckProject/epp-demo' ) ;
66+ expect ( repoLink ) . toHaveClass ( 'repository-link' ) ;
67+ } ) ;
68+
69+ it ( 'should style the repository section correctly' , ( ) => {
70+ render ( < Attribution /> ) ;
71+
72+ const repoSection = screen . getByText ( 'Open Source Project' ) . closest ( '.repository-section' ) ;
73+ const repoText = screen . getByText ( 'Open Source Project' ) ;
74+ const repoLink = screen . getByLabelText ( 'View source code on GitHub' ) ;
75+
76+ expect ( repoSection ) . toHaveClass ( 'repository-section' ) ;
77+ expect ( repoText ) . toHaveClass ( 'repository-text' ) ;
78+ expect ( repoLink ) . toHaveClass ( 'repository-link' ) ;
79+ } ) ;
5680 } ) ;
5781
5882 describe ( 'when users interact with the attribution' , ( ) => {
@@ -74,6 +98,7 @@ describe('Attribution Component', () => {
7498 expect ( screen . getByLabelText ( 'LinkedIn profile' ) ) . toBeInTheDocument ( ) ;
7599 expect ( screen . getByLabelText ( 'X (Twitter) profile' ) ) . toBeInTheDocument ( ) ;
76100 expect ( screen . getByLabelText ( 'Bluesky profile' ) ) . toBeInTheDocument ( ) ;
101+ expect ( screen . getByLabelText ( 'View source code on GitHub' ) ) . toBeInTheDocument ( ) ;
77102 } ) ;
78103 } ) ;
79104
@@ -90,13 +115,20 @@ describe('Attribution Component', () => {
90115
91116 // The story continues: They want to connect with the creator
92117 const socialLinks = screen . getAllByRole ( 'link' ) ;
93- expect ( socialLinks ) . toHaveLength ( 4 ) ;
118+ expect ( socialLinks ) . toHaveLength ( 5 ) ; // Updated to include repository link
94119
95- // The story concludes: They can easily access the creator's profiles
120+ // The story concludes: They can easily access the creator's profiles and the source code
96121 socialLinks . forEach ( link => {
97122 expect ( link ) . toBeVisible ( ) ;
98123 expect ( link . getAttribute ( 'href' ) ) . toMatch ( / ^ h t t p s : \/ \/ / ) ;
99124 } ) ;
125+
126+ // And they can find the open source repository
127+ const repoText = screen . getByText ( 'Open Source Project' ) ;
128+ const repoLink = screen . getByLabelText ( 'View source code on GitHub' ) ;
129+ expect ( repoText ) . toBeVisible ( ) ;
130+ expect ( repoLink ) . toBeVisible ( ) ;
131+ expect ( repoLink . getAttribute ( 'href' ) ) . toBe ( 'https://github.com/DeDuckProject/epp-demo' ) ;
100132 } ) ;
101133 } ) ;
102134} ) ;
0 commit comments