1
+ import { expect , test } from '@playwright/test'
2
+ import { DashboardPage } from './pages/DashboardPage' ;
3
+
4
+ const tag = { tag : [ '@teams-comparison' ] } ;
5
+
6
+ test . describe ( 'Teams Comparison tests' , ( ) => {
7
+
8
+ let dashboard : DashboardPage ;
9
+
10
+ test . beforeAll ( async ( { browser } ) => {
11
+ const page = await browser . newPage ( ) ;
12
+ await page . goto ( '/orgs/mocked-org?mock=true' ) ;
13
+
14
+ dashboard = new DashboardPage ( page ) ;
15
+
16
+ // wait for the data
17
+ await dashboard . expectMetricLabelsVisible ( ) ;
18
+ } ) ;
19
+
20
+ test . afterAll ( async ( ) => {
21
+ await dashboard ?. close ( ) ;
22
+ } ) ;
23
+
24
+ test ( 'has teams tab available' , tag , async ( ) => {
25
+ // Verify that teams tab is visible for org scope
26
+ await dashboard . expectTeamsTabVisible ( ) ;
27
+ } ) ;
28
+
29
+ test ( 'teams comparison functionality with team selection' , tag , async ( ) => {
30
+ // Click on teams tab
31
+ await dashboard . gotoTeamsTab ( ) ;
32
+
33
+ // Wait for teams dropdown to be visible
34
+ const teamsDropdown = dashboard . page . getByRole ( 'combobox' ) . first ( ) ;
35
+ await expect ( teamsDropdown ) . toBeVisible ( ) ;
36
+
37
+ // Click on the dropdown to open it
38
+ await teamsDropdown . click ( ) ;
39
+
40
+ // Wait for team options to appear
41
+ const teamOptions = dashboard . page . locator ( '[role="listbox"] [role="option"]' ) ;
42
+ await expect ( teamOptions . first ( ) ) . toBeVisible ( ) ;
43
+
44
+ // Select at least 2 teams as requested in the comment
45
+ // Get the first two team options
46
+ const firstTeam = teamOptions . first ( ) ;
47
+ const secondTeam = teamOptions . nth ( 1 ) ;
48
+
49
+ await firstTeam . click ( ) ;
50
+ await secondTeam . click ( ) ;
51
+
52
+ // Close dropdown by pressing Escape
53
+ await dashboard . page . keyboard . press ( 'Escape' ) ;
54
+
55
+ // Verify that teams are selected
56
+ const selectedTeamsSection = dashboard . page . locator ( 'text=Selected Teams' ) . first ( ) ;
57
+ await expect ( selectedTeamsSection ) . toBeVisible ( ) ;
58
+
59
+ // Verify that team metrics cards are visible
60
+ const teamsSelectedCard = dashboard . page . locator ( 'text=Teams Selected' ) . first ( ) ;
61
+ await expect ( teamsSelectedCard ) . toBeVisible ( ) ;
62
+
63
+ const totalActiveUsersCard = dashboard . page . locator ( 'text=Total Active Users' ) . first ( ) ;
64
+ await expect ( totalActiveUsersCard ) . toBeVisible ( ) ;
65
+
66
+ // Verify that charts are displayed
67
+ const acceptanceRateChart = dashboard . page . locator ( 'h2:has-text("Acceptance Rate by Count (%)")' ) ;
68
+ await expect ( acceptanceRateChart ) . toBeVisible ( ) ;
69
+
70
+ const languageUsageChart = dashboard . page . locator ( 'text=Language Usage by Team' ) ;
71
+ await expect ( languageUsageChart ) . toBeVisible ( ) ;
72
+
73
+ const editorUsageChart = dashboard . page . locator ( 'text=Editor Usage by Team' ) ;
74
+ await expect ( editorUsageChart ) . toBeVisible ( ) ;
75
+
76
+ // Take a screenshot for documentation purposes
77
+ await dashboard . page . screenshot ( {
78
+ path : 'images/teams-comparison-test.png' ,
79
+ fullPage : true
80
+ } ) ;
81
+ } ) ;
82
+
83
+ test ( 'teams comparison empty state' , tag , async ( ) => {
84
+ // Click on teams tab
85
+ await dashboard . gotoTeamsTab ( ) ;
86
+
87
+ // Verify empty state message when no teams are selected
88
+ const emptyStateMessage = dashboard . page . locator ( 'text=No Teams Selected' ) ;
89
+ await expect ( emptyStateMessage ) . toBeVisible ( ) ;
90
+
91
+ const emptyStateDescription = dashboard . page . locator ( 'text=Select one or more teams from the dropdown above to view and compare their metrics.' ) ;
92
+ await expect ( emptyStateDescription ) . toBeVisible ( ) ;
93
+ } ) ;
94
+ } ) ;
0 commit comments