1
1
import { expect , Locator , Page } from '@playwright/test' ;
2
2
3
- export const SIGNUP_LINK = 'https://surveys.jetbrains.com/s3/kotlin-slack-signup-educators' as const ;
4
3
export const MAILTO_LINK = 'mailto:[email protected] ' as const ;
4
+ export const SIGNUP_LINK = 'https://surveys.jetbrains.com/s3/kotlin-slack-signup-educators' as const ;
5
5
export const MATERIALS_LINK = 'https://drive.google.com/drive/folders/1nN3LuyEfmBaSDZpnb4VA9kDuLakmVXH1?usp=drive_link' as const ;
6
6
7
7
const NAV_LINKS = [
@@ -10,18 +10,34 @@ const NAV_LINKS = [
10
10
[ 'List of Courses' , '/education/courses.html' ]
11
11
] as const ;
12
12
13
- export async function checkTeachSubnav ( page : Page , selected : typeof NAV_LINKS [ number ] [ 0 ] ) {
14
- await expect ( page . locator ( '.teach-sticky-menu > div > a[href="/education/"]' ) ) . toBeVisible ( ) ;
15
- await expect ( page . locator ( '.teach-sticky-menu > div > nav span' ) . getByText ( selected ) ) . toBeVisible ( ) ;
13
+ export async function checkTeachNav ( page : Page , selected : typeof NAV_LINKS [ number ] [ 0 ] ) {
14
+ const navBar = page . locator ( '.teach-sticky-menu' ) ;
15
+
16
+ // Check section title to root of nav
17
+ const sectionLink = navBar . getByRole ( 'link' , { name : 'Teach' , exact : true } ) ;
18
+ await expect ( sectionLink ) . toBeVisible ( ) ;
19
+ await expect ( sectionLink ) . toHaveAttribute ( 'href' , '/education/' ) ;
20
+
21
+ // Check the Join button
22
+ const joinLink = navBar . getByRole ( 'link' , { name : 'Join Educators' , exact : true } ) ;
23
+ await expect ( joinLink ) . toBeVisible ( ) ;
24
+ await expect ( joinLink ) . toHaveAttribute ( 'href' , SIGNUP_LINK ) ;
25
+
26
+ const subNav = navBar . getByRole ( 'navigation' ) ;
16
27
28
+ // Check sub-nav link
17
29
for ( let [ title , link ] of NAV_LINKS ) {
18
- if ( title == selected ) continue ;
19
- await expect ( page . locator ( `.teach-sticky-menu > div > nav a[href="${ link } "]` ) ) . toBeVisible ( ) ;
30
+ if ( title == selected ) {
31
+ await expect ( subNav . getByRole ( 'link' , { name : title } ) ) . toHaveCount ( 0 ) ;
32
+ await expect ( subNav . getByText ( title ) ) . toBeVisible ( ) ;
33
+ continue ;
34
+ }
35
+
36
+ const subLink = subNav . getByRole ( 'link' , { name : title } ) . filter ( { visible : true } ) ;
37
+ await expect ( subLink ) . toHaveAttribute ( 'href' , link ) ;
20
38
}
21
39
22
- await expect ( page . locator ( `.teach-sticky-menu > div > a[href="${ SIGNUP_LINK } "]` ) ) . toBeVisible ( ) ;
23
-
24
- expect ( await page . locator ( '.teach-sticky-menu' ) . screenshot ( ) ) . toMatchSnapshot ( 'sticky-menu.png' ) ;
40
+ expect ( await navBar . screenshot ( ) ) . toMatchSnapshot ( 'sticky-menu.png' ) ;
25
41
}
26
42
27
43
export async function checkTeachMap ( page : Page , map : Locator ) {
@@ -45,7 +61,7 @@ export async function checkTeachMap(page: Page, map: Locator) {
45
61
} ) ;
46
62
47
63
// Check if at least one marker is visible
48
- let marker = markers . nth ( 36 ) ;
64
+ let marker = markers . last ( ) ;
49
65
await expect ( marker ) . toBeVisible ( ) ;
50
66
await expect ( marker ) . not . toHaveClass ( 'teach-map-marker teach-map-marker_active' ) ;
51
67
@@ -59,19 +75,28 @@ export async function checkTeachMap(page: Page, map: Locator) {
59
75
await page . mouse . up ( ) ;
60
76
61
77
await expect ( marker ) . toHaveClass ( 'teach-map-marker teach-map-marker_active' ) ;
78
+
62
79
const tooltip = marker . locator ( '.teach-map-tooltip' ) ;
63
80
await expect ( tooltip ) . toBeVisible ( ) ;
64
81
}
65
82
66
83
export async function checkTeachCta ( { page } ) {
67
- // Look for the "Connect with us" section which contains the CTA buttons
84
+ // Get the CTA wrapper element from the page
68
85
const connectUs = page . locator ( 'section [class*=ktl-cta-block-module_wrapper_]' ) ;
69
86
70
- const title = connectUs . getByText ( 'Connect with us' ) ;
87
+ // Check if the "Connect with us" heading is visible
88
+ const title = connectUs . getByRole ( 'heading' , { name : 'Connect with us' , exact : true } ) ;
71
89
await expect ( title ) . toBeVisible ( ) ;
72
90
73
- await expect ( connectUs . locator ( `a[href="${ SIGNUP_LINK } "]` ) ) . toBeVisible ( ) ;
74
- await expect ( connectUs . locator ( `a[href="${ MAILTO_LINK } "]` ) ) . toBeVisible ( ) ;
91
+ // Check if the Slack link is visible and has the correct href
92
+ const slackLink = connectUs . getByRole ( 'link' , { name : 'Slack-channel →' , exact : true } ) ;
93
+ await expect ( slackLink ) . toBeVisible ( ) ;
94
+ await expect ( slackLink ) . toHaveAttribute ( 'href' , SIGNUP_LINK ) ;
95
+
96
+ // Check if the email link is visible and has the correct mailto href
97
+ const eduLink = connectUs . getByRole ( 'link' , { name :
'[email protected] ' , exact :
true } ) ;
98
+ await expect ( eduLink ) . toBeVisible ( ) ;
99
+ await expect ( eduLink ) . toHaveAttribute ( 'href' , MAILTO_LINK ) ;
75
100
76
101
expect ( await connectUs . screenshot ( ) ) . toMatchSnapshot ( 'connect-us.png' ) ;
77
- }
102
+ }
0 commit comments