This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: place guest order with proper params and load sessionContext (#590
- Loading branch information
Showing
10 changed files
with
118 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { PaymentMethod } from "../models/checkout/payment/PaymentMethod"; | ||
import { ShippingMethod } from "../models/checkout/shipping/ShippingMethod"; | ||
import { Country } from "../models/system/country/Country"; | ||
import { User } from "../models/system/user/User"; | ||
|
||
export interface ContextTokenResponse { | ||
contextToken: string; | ||
} | ||
|
||
export interface SessionContext { | ||
token: string; | ||
currentCustomerGroup: { | ||
id: string; | ||
name: string; | ||
}; | ||
fallbackCustomerGroup: { | ||
id: string; | ||
name: string; | ||
}; | ||
currency: { | ||
id: string; | ||
name: string; | ||
}; | ||
salesChannel: { | ||
id: string; | ||
name: string; | ||
}; | ||
taxRules: { | ||
id: string; | ||
name: string; | ||
}[]; | ||
customer?: User; | ||
paymentMethod: PaymentMethod; | ||
shippingMethod: ShippingMethod; | ||
shippingLocation: { | ||
country: Country; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/shopware-6-client/__tests__/services/ContextService/getSessionContext.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { apiService } from "../../../src/apiService"; | ||
import { getSessionContext } from "@shopware-pwa/shopware-6-client"; | ||
import { SessionContext } from "@shopware-pwa/commons/interfaces/response/SessionContext"; | ||
|
||
jest.mock("../../../src/apiService"); | ||
const mockedAxios = apiService as jest.Mocked<typeof apiService>; | ||
|
||
describe("ContextService - getSessionContext", () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
it("should return sessionContext", async () => { | ||
mockedAxios.get.mockResolvedValueOnce({ data: { token: "qwerty" } }); | ||
|
||
const result: SessionContext = await getSessionContext(); | ||
expect(mockedAxios.get).toBeCalledTimes(1); | ||
expect(mockedAxios.get).toBeCalledWith("/context"); | ||
expect(result.token).toEqual("qwerty"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters