@@ -26,56 +26,60 @@ test.describe('Website Router', () => {
2626 await expect ( mainContent ) . toBeVisible ( )
2727
2828 // Check for the Projects heading
29- const projectsHeading = page . locator ( 'h2:has-text("Projects") ' )
29+ const projectsHeading = page . locator ( '[data-testid="projects-heading"] ' )
3030 await expect ( projectsHeading ) . toBeVisible ( )
3131
3232 // Check for project links in the list
33- const projectLinks = page . locator ( 'ul li a' )
33+ const projectLinks = page . locator ( '[data-testid="projects-list"] li a' )
3434 const count = await projectLinks . count ( )
3535
3636 // We should have at least one project link
3737 expect ( count ) . toBeGreaterThan ( 0 )
3838
3939 // Check for the Checklists heading
40- const checklistsHeading = page . locator ( 'h2:has-text("Checklists") ' )
40+ const checklistsHeading = page . locator ( '[data-testid="checklists-heading"] ' )
4141 await expect ( checklistsHeading ) . toBeVisible ( )
4242
4343 // Check for the first table
44- const firstTable = page . locator ( 'table' ) . first ( )
45- await expect ( firstTable ) . toBeVisible ( )
44+ const checklistsTable = page . locator ( '[data-testid="checklists- table"]' )
45+ await expect ( checklistsTable ) . toBeVisible ( )
4646 // Check that the table headers exist
47- const docHeader = firstTable . locator ( 'thead tr th:has-text("Documentation")' )
48- const titleHeader = firstTable . locator ( 'thead tr th:has-text("Title")' )
49- const descHeader = firstTable . locator ( 'thead tr th:has-text("Description")' )
50- const authorHeader = firstTable . locator ( 'thead tr th:has-text("Author")' )
47+ const docHeader = checklistsTable . locator ( 'thead tr th:has-text("Documentation")' )
48+ const titleHeader = checklistsTable . locator ( 'thead tr th:has-text("Title")' )
49+ const descHeader = checklistsTable . locator ( 'thead tr th:has-text("Description")' )
50+ const authorHeader = checklistsTable . locator ( 'thead tr th:has-text("Author")' )
5151
5252 await expect ( docHeader ) . toBeVisible ( )
5353 await expect ( titleHeader ) . toBeVisible ( )
5454 await expect ( descHeader ) . toBeVisible ( )
5555 await expect ( authorHeader ) . toBeVisible ( )
5656
5757 // Check for at least one row in the table
58- const rows = await firstTable . locator ( 'tr' )
58+ const rows = await checklistsTable . locator ( 'tr' )
5959 expect ( await rows . count ( ) ) . toBeGreaterThan ( 0 )
6060
6161 // Check for the Compliance Checks heading
62- const complianceChecksHeading = page . locator ( 'h2:has-text("Compliance Checks") ' )
62+ const complianceChecksHeading = page . locator ( '[data-testid="compliance-checks-heading"] ' )
6363 await expect ( complianceChecksHeading ) . toBeVisible ( )
6464
65+ // Check for Compliance Checks Description
66+ const complianceChecksDescription = page . locator ( '[data-testid="compliance-checks-description"]' )
67+ await expect ( complianceChecksDescription ) . toBeVisible ( )
68+
6569 // Check for the second table
66- const secondTable = page . locator ( 'table' ) . last ( )
67- await expect ( secondTable ) . toBeVisible ( )
70+ const complianceChecksTable = page . locator ( '[data-testid="compliance-checks- table"]' )
71+ await expect ( complianceChecksTable ) . toBeVisible ( )
6872 // Check that the table headers exist
69- const docHeader2 = secondTable . locator ( 'thead tr th:has-text("Documentation")' )
70- const nameHeader = secondTable . locator ( 'thead tr th:has-text("Name")' )
71- const descHeader2 = secondTable . locator ( 'thead tr th:has-text("Description")' )
73+ const docHeader2 = complianceChecksTable . locator ( 'thead tr th:has-text("Documentation")' )
74+ const nameHeader = complianceChecksTable . locator ( 'thead tr th:has-text("Name")' )
75+ const descHeader2 = complianceChecksTable . locator ( 'thead tr th:has-text("Description")' )
7276
7377 await expect ( docHeader2 ) . toBeVisible ( )
7478 await expect ( nameHeader ) . toBeVisible ( )
7579 await expect ( descHeader2 ) . toBeVisible ( )
7680
7781 // Check for at least one row in the table
78- const rows2 = await secondTable . locator ( 'tr' )
82+ const rows2 = await complianceChecksTable . locator ( 'tr' )
7983 expect ( await rows2 . count ( ) ) . toBeGreaterThan ( 0 )
8084 } )
8185
@@ -87,7 +91,7 @@ test.describe('Website Router', () => {
8791 await expect ( page ) . toHaveURL ( `/projects/${ testProjectId } ` )
8892
8993 // Check for the project name in the heading
90- const projectHeading = page . locator ( 'h1 ' )
94+ const projectHeading = page . locator ( '[data-testid="project-heading"] ' )
9195 await expect ( projectHeading ) . toBeVisible ( )
9296 await expect ( projectHeading ) . toContainText ( 'Report' )
9397
@@ -97,41 +101,32 @@ test.describe('Website Router', () => {
97101
98102 // Check for section headings that should be present on project pages
99103 const sectionHeadings = [
100- 'Alerts' ,
101- 'Results' ,
102- 'Tasks'
104+ '[data-testid="alerts-heading"]' ,
105+ '[data-testid="results-heading"]' ,
106+ '[data-testid="tasks-heading"]' ,
107+ '[data-testid="ossf-scorecard-heading"]' ,
108+ '[data-testid="github-orgs-heading"]' ,
109+ '[data-testid="github-repos-heading"]'
103110 ]
104111
105112 for ( const headingText of sectionHeadings ) {
106- const heading = page . locator ( `h2:has-text(" ${ headingText } ")` )
113+ const heading = page . locator ( headingText )
107114 await expect ( heading ) . toBeVisible ( )
108115 }
109116
110- // Check for OSSF scorecard section
111- const ossfHeading = page . locator ( 'h2:has-text("OSSF Scorecard Analysis")' )
112- await expect ( ossfHeading ) . toBeVisible ( )
113-
114- // Check for GitHub organizations section
115- const githubOrgsHeading = page . locator ( 'h2:has-text("GitHub Organizations in scope")' )
116- await expect ( githubOrgsHeading ) . toBeVisible ( )
117-
118- // Check for an organization list
119- const list = page . locator ( 'ul li' )
117+ // Check for a GitHub organization list
118+ const list = page . locator ( '[data-testid="github-orgs-list"] li' )
120119 await expect ( list ) . toBeVisible ( )
121120
122- // Check for GitHub repositories section
123- const githubReposHeading = page . locator ( 'h2:has-text("GitHub repositories in scope")' )
124- await expect ( githubReposHeading ) . toBeVisible ( )
125-
126- // Check for the first table
127- const firstTable = page . locator ( 'table' ) . first ( )
128- await expect ( firstTable ) . toBeVisible ( )
121+ // Check for the GitHub repositories table
122+ const githubReposTable = page . locator ( '[data-testid="github-repos-table"]' )
123+ await expect ( githubReposTable ) . toBeVisible ( )
129124 // Check that the table headers exist
130- const repositoryHeader = firstTable . locator ( 'thead tr th:has-text("Repository")' )
131- const starsHeader = firstTable . locator ( 'thead tr th:has-text("Stars")' )
132- const forksHeader = firstTable . locator ( 'thead tr th:has-text("Forks")' )
133- const subscribersHeader = firstTable . locator ( 'thead tr th:has-text("Subscribers")' )
134- const issuesHeader = firstTable . locator ( 'thead tr th:has-text("Open Issues")' )
125+ const repositoryHeader = githubReposTable . locator ( 'thead tr th:has-text("Repository")' )
126+ const starsHeader = githubReposTable . locator ( 'thead tr th:has-text("Stars")' )
127+ const forksHeader = githubReposTable . locator ( 'thead tr th:has-text("Forks")' )
128+ const subscribersHeader = githubReposTable . locator ( 'thead tr th:has-text("Subscribers")' )
129+ const issuesHeader = githubReposTable . locator ( 'thead tr th:has-text("Open Issues")' )
135130
136131 await expect ( repositoryHeader ) . toBeVisible ( )
137132 await expect ( starsHeader ) . toBeVisible ( )
@@ -140,7 +135,7 @@ test.describe('Website Router', () => {
140135 await expect ( issuesHeader ) . toBeVisible ( )
141136
142137 // Check for at least one row in the table
143- const rows = await firstTable . locator ( 'tr' )
138+ const rows = await githubReposTable . locator ( 'tr' )
144139 expect ( await rows . count ( ) ) . toBeGreaterThan ( 0 )
145140 } )
146141
@@ -149,14 +144,14 @@ test.describe('Website Router', () => {
149144 await page . goto ( '/projects/invalid' )
150145
151146 // Check for the Not Found heading
152- const notFoundHeading = page . locator ( 'h1:has-text("Not Found!") ' )
147+ const notFoundHeading = page . locator ( '[data-testid="not-found-title"] ' )
153148 await expect ( notFoundHeading ) . toBeVisible ( )
154149
155150 // Test with non-existent numeric ID
156151 await page . goto ( '/projects/999999' )
157152
158153 // Check for the Not Found heading
159- const notFoundHeading2 = page . locator ( 'h1:has-text("Not Found!") ' )
154+ const notFoundHeading2 = page . locator ( '[data-testid="not-found-title"] ' )
160155 await expect ( notFoundHeading2 ) . toBeVisible ( )
161156 } )
162157
0 commit comments