@@ -14,7 +14,7 @@ test.describe('Authentication Tests', () => {
1414
1515 test ( 'TC-AUTH-001: Valid Login' , async ( { page } ) => {
1616 await test . step ( 'Enter valid credentials and login' , async ( ) => {
17- await loginPage . login ( 'Admin' , 'admin123' ) ;
17+ await loginPage . loginAndWaitForDashboard ( 'Admin' , 'admin123' ) ;
1818 } ) ;
1919
2020 await test . step ( 'Verify dashboard is displayed' , async ( ) => {
@@ -27,6 +27,7 @@ test.describe('Authentication Tests', () => {
2727 test ( 'TC-AUTH-002: Invalid Username' , async ( { page } ) => {
2828 await test . step ( 'Enter invalid username' , async ( ) => {
2929 await loginPage . login ( 'InvalidUser' , 'admin123' ) ;
30+ await loginPage . errorMessage . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
3031 } ) ;
3132
3233 await test . step ( 'Verify error message is displayed' , async ( ) => {
@@ -38,6 +39,7 @@ test.describe('Authentication Tests', () => {
3839 test ( 'TC-AUTH-003: Invalid Password' , async ( { page } ) => {
3940 await test . step ( 'Enter invalid password' , async ( ) => {
4041 await loginPage . login ( 'Admin' , 'WrongPassword' ) ;
42+ await loginPage . errorMessage . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
4143 } ) ;
4244
4345 await test . step ( 'Verify error message is displayed' , async ( ) => {
@@ -70,7 +72,7 @@ test.describe('Authentication Tests', () => {
7072
7173 test ( 'TC-AUTH-006: Logout Functionality' , async ( { page } ) => {
7274 await test . step ( 'Login successfully' , async ( ) => {
73- await loginPage . login ( 'Admin' , 'admin123' ) ;
75+ await loginPage . loginAndWaitForDashboard ( 'Admin' , 'admin123' ) ;
7476 await expect ( page ) . toHaveURL ( / .* d a s h b o a r d / ) ;
7577 } ) ;
7678
@@ -88,6 +90,7 @@ test.describe('Authentication Tests', () => {
8890 test ( 'TC-AUTH-008: SQL Injection Prevention' , async ( { page } ) => {
8991 await test . step ( 'Attempt SQL injection in username' , async ( ) => {
9092 await loginPage . login ( "Admin' OR '1'='1" , 'anything' ) ;
93+ await loginPage . errorMessage . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
9194 } ) ;
9295
9396 await test . step ( 'Verify login fails securely' , async ( ) => {
@@ -99,6 +102,7 @@ test.describe('Authentication Tests', () => {
99102 test ( 'TC-AUTH-009: XSS Prevention' , async ( { page } ) => {
100103 await test . step ( 'Attempt XSS in username field' , async ( ) => {
101104 await loginPage . login ( "<script>alert('XSS')</script>" , 'admin123' ) ;
105+ await loginPage . errorMessage . waitFor ( { state : 'visible' , timeout : 10000 } ) ;
102106 } ) ;
103107
104108 await test . step ( 'Verify no script execution' , async ( ) => {
0 commit comments