@@ -82,5 +82,118 @@ describe('Catalog', () => {
8282 . contains ( 'Sub-page 1' )
8383 . should ( 'be.visible' ) ;
8484 } ) ;
85+
86+ it ( 'Should render addons on docs tab homepage' , ( ) => {
87+ cy . loginAsGuest ( ) ;
88+
89+ cy . visit ( '/catalog' ) ;
90+
91+ cy . contains ( 'techdocs-e2e-fixture' ) . click ( ) ;
92+
93+ cy . location ( ) . should ( loc => {
94+ expect ( loc . pathname ) . to . eq (
95+ '/catalog/default/component/techdocs-e2e-fixture' ,
96+ ) ;
97+ } ) ;
98+
99+ cy . getCatalogDocsTab ( ) . click ( ) ;
100+
101+ cy . wait ( 300 ) ;
102+
103+ cy . getTechDocsShadowRoot ( )
104+ . find ( 'h1' )
105+ . contains ( 'Home page' )
106+ . should ( 'be.visible' ) ;
107+
108+ // highlight a snippet of text
109+ cy . getTechDocsShadowRoot ( )
110+ . find ( 'article > p' )
111+ . then ( $el => {
112+ const el = $el [ 0 ] ;
113+ const document = el . ownerDocument ;
114+ const range = document . createRange ( ) ;
115+ range . selectNodeContents ( el ) ;
116+ document ?. getSelection ( ) ?. removeAllRanges ( ) ;
117+ document ?. getSelection ( ) ?. addRange ( range ) ;
118+ } ) ;
119+
120+ cy . document ( ) . trigger ( 'selectionchange' ) ;
121+
122+ // wait for new issue default debounce time
123+ cy . wait ( 600 ) ;
124+
125+ // assert that the new issue button has a right url
126+ cy . getTechDocsShadowRoot ( )
127+ . contains ( 'Open new Github issue' )
128+ . should (
129+ 'have.attr' ,
130+ 'href' ,
131+ 'https://github.com/backstage/backstage/issues/new?title=Documentation%20feedback%3A%20This%20is%20a%20basic%20documentation%20used%20for%20end-to-end%20tests.&body=%23%23%20Documentation%20Feedback%20%F0%9F%93%9D%0A%0A%20%23%23%23%23%20The%20highlighted%20text%3A%20%0A%0A%20%3E%20This%20is%20a%20basic%20documentation%20used%20for%20end-to-end%20tests.%0A%0A%20%23%23%23%23%20The%20comment%20on%20the%20text%3A%20%0A%20_%3Ereplace%20this%20line%20with%20your%20comment%3C_%0A%0A%20___%0ABackstage%20URL%3A%20%3Chttp%3A%2F%2Flocalhost%3A7007%2Fcatalog%2Fdefault%2Fcomponent%2Ftechdocs-e2e-fixture%2Fdocs%3E%20%0AMarkdown%20URL%3A%20%3Chttps%3A%2F%2Fgithub.com%2Fbackstage%2Fbackstage%2Fblob%2Fmaster%2Fcypress%2Ffixtures%2Fdocs%2Findex.md%3E' ,
132+ ) ;
133+ } ) ;
134+
135+ it ( 'Should render addons on docs tab sup-page' , ( ) => {
136+ cy . loginAsGuest ( ) ;
137+
138+ cy . visit ( '/catalog' ) ;
139+
140+ cy . contains ( 'techdocs-e2e-fixture' ) . click ( ) ;
141+
142+ cy . location ( ) . should ( loc => {
143+ expect ( loc . pathname ) . to . eq (
144+ '/catalog/default/component/techdocs-e2e-fixture' ,
145+ ) ;
146+ } ) ;
147+
148+ cy . getCatalogDocsTab ( ) . click ( ) ;
149+
150+ cy . wait ( 300 ) ;
151+
152+ cy . getTechDocsShadowRoot ( )
153+ . find ( 'h1' )
154+ . contains ( 'Home page' )
155+ . should ( 'be.visible' ) ;
156+
157+ cy . getTechDocsShadowRoot ( ) . within ( ( ) => {
158+ cy . getTechDocsNavigation ( ) . find ( 'a' ) . contains ( 'Sub-page 1' ) . click ( ) ;
159+ } ) ;
160+
161+ cy . location ( ) . should ( loc => {
162+ expect ( loc . pathname ) . to . eq (
163+ '/catalog/default/component/techdocs-e2e-fixture/docs/sub-page-one/' ,
164+ ) ;
165+ } ) ;
166+
167+ cy . getTechDocsShadowRoot ( )
168+ . find ( 'h1' )
169+ . contains ( 'Sub-page 1' )
170+ . should ( 'be.visible' ) ;
171+
172+ // highlight a snippet of text
173+ cy . getTechDocsShadowRoot ( )
174+ . find ( '#section-11' )
175+ . then ( $el => {
176+ const el = $el [ 0 ] ;
177+ const document = el . ownerDocument ;
178+ const range = document . createRange ( ) ;
179+ range . selectNodeContents ( el ) ;
180+ document ?. getSelection ( ) ?. removeAllRanges ( ) ;
181+ document ?. getSelection ( ) ?. addRange ( range ) ;
182+ } ) ;
183+
184+ cy . document ( ) . trigger ( 'selectionchange' ) ;
185+
186+ // wait for new issue default debounce time
187+ cy . wait ( 600 ) ;
188+
189+ // assert that the new issue button has a right url
190+ cy . getTechDocsShadowRoot ( )
191+ . contains ( 'Open new Github issue' )
192+ . should (
193+ 'have.attr' ,
194+ 'href' ,
195+ 'https://github.com/backstage/backstage/issues/new?title=Documentation%20feedback%3A%20Section%201.1%C2%B6&body=%23%23%20Documentation%20Feedback%20%F0%9F%93%9D%0A%0A%20%23%23%23%23%20The%20highlighted%20text%3A%20%0A%0A%20%3E%20Section%201.1%C2%B6%0A%0A%20%23%23%23%23%20The%20comment%20on%20the%20text%3A%20%0A%20_%3Ereplace%20this%20line%20with%20your%20comment%3C_%0A%0A%20___%0ABackstage%20URL%3A%20%3Chttp%3A%2F%2Flocalhost%3A7007%2Fcatalog%2Fdefault%2Fcomponent%2Ftechdocs-e2e-fixture%2Fdocs%2Fsub-page-one%2F%3E%20%0AMarkdown%20URL%3A%20%3Chttps%3A%2F%2Fgithub.com%2Fbackstage%2Fbackstage%2Fblob%2Fmaster%2Fcypress%2Ffixtures%2Fdocs%2Fsub-page-one.md%3E' ,
196+ ) ;
197+ } ) ;
85198 } ) ;
86199} ) ;
0 commit comments