1
+ /**********************************************************************
2
+ * Copyright (C) 2025 Red Hat, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * SPDX-License-Identifier: Apache-2.0
17
+ ***********************************************************************/
18
+
19
+ import type { Locator , Page } from '@playwright/test' ;
20
+ import test , { expect as playExpect } from '@playwright/test' ;
21
+ import { BasePage } from '@podman-desktop/tests-playwright' ;
22
+
23
+ export class SSOAuthenticationProviderCardPage extends BasePage {
24
+ readonly parent : Locator ;
25
+ readonly providerInformation : Locator ;
26
+ readonly providerActions : Locator ;
27
+ readonly signinButton : Locator ;
28
+ readonly providerName : Locator ;
29
+ readonly providerStatus : Locator ;
30
+ readonly logoutButton : Locator ;
31
+ readonly userName : Locator ;
32
+ readonly signoutButton : Locator ;
33
+
34
+ constructor ( page : Page ) {
35
+ super ( page ) ;
36
+ this . parent = this . page . getByRole ( 'listitem' , { name : 'Red Hat SSO' } ) ;
37
+ this . providerInformation = this . parent . getByLabel ( 'Provider Information' ) ;
38
+ this . providerActions = this . parent . getByLabel ( 'Provider Actions' ) ;
39
+ this . signinButton = this . providerActions . getByRole ( 'button' , { name : 'Sign in' } ) ;
40
+ this . providerName = this . providerInformation . getByLabel ( 'Provider Name' ) ;
41
+ this . providerStatus = this . providerInformation . getByLabel ( 'Provider Status' ) ;
42
+ this . userName = this . providerInformation . getByLabel ( 'Logged In Username' ) ;
43
+ this . signoutButton = this . providerInformation . getByRole ( 'button' , { name : 'Sign out of ' , exact : false } ) ;
44
+ }
45
+
46
+ public async signIn ( ) : Promise < void > {
47
+ await test . step ( 'Perform Sign In' , async ( ) => {
48
+ console . log ( `Signin Button is enabled` ) ;
49
+ await playExpect ( this . signinButton ) . toBeEnabled ( ) ;
50
+ console . log ( `Clicking on the button...` ) ;
51
+ await this . signinButton . click ( ) ;
52
+ console . log ( `Button clicked` ) ;
53
+ } ) ;
54
+ }
55
+
56
+ public async logout ( ) : Promise < void > {
57
+ await test . step ( 'Perform Sign Out' , async ( ) => {
58
+ await playExpect ( this . signoutButton ) . toBeEnabled ( ) ;
59
+ await this . signoutButton . click ( ) ;
60
+ } ) ;
61
+ }
62
+
63
+ public async checkUserIsLoggedIn ( loggedIn = true ) : Promise < void > {
64
+ await test . step ( loggedIn ? 'User si logged In' : 'User is logged out' , async ( ) => {
65
+ await playExpect ( this . providerStatus ) . toBeVisible ( ) ;
66
+ console . log ( `Status text: ${ await this . providerStatus . innerText ( ) } ` ) ;
67
+ await playExpect ( this . providerStatus ) . toContainText ( loggedIn ? 'logged in' : 'logged out' , { ignoreCase : true } ) ;
68
+ } ) ;
69
+ }
70
+ }
0 commit comments