1+ import { read } from "fs" ;
12import { test , expect } from "../fixtures/fixtures" ;
23
34import { AddItem } from "../pages/AddItemToCart" ;
45
56import { Checkout } from "../pages/Checkout" ;
67
78test . describe ( "Checkout" , ( ) => {
8- test ( "Successfull checkout" , async ( { page , loginPage , cartReady } ) => {
9- const checkout = new Checkout ( page ) ;
9+ test ( "Successfull checkout" , async ( { readyForCheckout } ) => {
10+ const { page , checkoutPage } = readyForCheckout ;
1011
11- await checkout . clickCheckout ( ) ;
12- await checkout . completeInfo ( "Kamran" , "Musadirli" , "12345" ) ;
13- await checkout . clickContinue ( ) ;
12+ await checkoutPage . completeInfo ( "Kamran" , "Musadirli" , "12345" ) ;
13+ await checkoutPage . clickContinue ( ) ;
1414 await page . waitForTimeout ( 2000 ) ;
1515
1616 await expect ( page ) . toHaveURL (
1717 "https://www.saucedemo.com/checkout-step-two.html"
1818 ) ;
1919
20- await checkout . clickFinish ( ) ;
20+ await checkoutPage . clickFinish ( ) ;
2121
2222 await expect ( page . locator ( ".complete-header" ) ) . toHaveText (
2323 "Thank you for your order!"
2424 ) ;
2525 } ) ;
2626
2727 test . describe ( "Checkout with invalid data" , ( ) => {
28- test ( "Checkout with no data" , async ( { page , loginPage , cartReady } ) => {
29- const checkout = new Checkout ( page ) ;
28+ test ( "Checkout with no data" , async ( { readyForCheckout } ) => {
29+ const { page , checkoutPage } = readyForCheckout ;
3030
31- await checkout . clickCheckout ( ) ;
32-
33- // without filling the data
34-
35- await checkout . clickContinue ( ) ;
31+ await checkoutPage . clickContinue ( ) ;
3632
3733 await expect (
3834 page . locator ( ".error-message-container.error" )
@@ -46,17 +42,13 @@ test.describe("Checkout", () => {
4642 } ) ;
4743
4844 test ( "Checkout without Last Name And Zip Code" , async ( {
49- page,
50- loginPage,
51- cartReady,
45+ readyForCheckout,
5246 } ) => {
53- const checkout = new Checkout ( page ) ;
54-
55- await checkout . clickCheckout ( ) ;
47+ const { page, checkoutPage } = readyForCheckout ;
5648
57- await checkout . completeInfo ( "Kamran" ) ;
49+ await checkoutPage . completeInfo ( "Kamran" ) ;
5850
59- await checkout . clickContinue ( ) ;
51+ await checkoutPage . clickContinue ( ) ;
6052
6153 await expect (
6254 page . locator ( ".error-message-container.error" )
@@ -69,18 +61,12 @@ test.describe("Checkout", () => {
6961 await page . waitForTimeout ( 2000 ) ;
7062 } ) ;
7163
72- test ( "Checkout without Zip Code" , async ( {
73- page,
74- loginPage,
75- cartReady,
76- } ) => {
77- const checkout = new Checkout ( page ) ;
78-
79- await checkout . clickCheckout ( ) ;
64+ test ( "Checkout without Zip Code" , async ( { readyForCheckout } ) => {
65+ const { page, checkoutPage } = readyForCheckout ;
8066
81- await checkout . completeInfo ( "Kamran" , "Musadirli" ) ;
67+ await checkoutPage . completeInfo ( "Kamran" , "Musadirli" ) ;
8268
83- await checkout . clickContinue ( ) ;
69+ await checkoutPage . clickContinue ( ) ;
8470
8571 await expect (
8672 page . locator ( ".error-message-container.error" )
0 commit comments