Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: SSR E2E Test Scenarios (#17666) #17903

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open

test: SSR E2E Test Scenarios (#17666) #17903

wants to merge 13 commits into from

Conversation

Zeyber
Copy link
Contributor

@Zeyber Zeyber commented Oct 3, 2023

No description provided.

Platonn and others added 8 commits July 10, 2023 10:54
Previous behavior: When `/products` endpoint returned a http error, the code broke in [this line](https://github.com/SAP/spartacus/blob/ed1e1a78c488b1e1214491ffa736612287f8cf70/projects/core/src/product/store/effects/product.effect.ts#L77), complaining that `this` is undefined.

Fix: Preserve the context of `this` which was lost in [this line](https://github.com/SAP/spartacus/blob/ed1e1a78c488b1e1214491ffa736612287f8cf70/projects/core/src/product/store/effects/product.effect.ts#L52)

The problem was revealed only after we implemented [CXSPA-2251](https://jira.tools.sap/browse/CXSPA-2251) where we referenced `this` by adding `this.logger` to the method `ProductEffects.productLoadEffect`

fixes https://jira.tools.sap/browse/CXSPA-3902
Co-authored-by: Krzysztof Platis <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Krzysztof Platis <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
# Conflicts:
#	projects/core/src/product/store/actions/product-references.action.ts
#	projects/core/src/product/store/actions/product-reviews.action.ts
#	projects/core/src/product/store/effects/product-reviews.effect.ts
#	projects/core/src/state/utils/entity-loader/entity-loader.action.ts
This pull request introduces methodologies for integrating multiple error interceptors that manage errors within the Server-Side Rendering (SSR) framework. This architectural augmentation preserves backward compatibility, mitigating any potential disruptions for end-users upon the incorporation of new error interceptors into the system.

With the introduction of this enhancement, it becomes easier for users to include new error interceptors, giving them the flexibility to determine the order in which these interceptors are applied within the system. This priority setting allows users to control how these interceptors operate and influence the workflow of the system.

The order is:
High priority
Normal or no priority
Low priority

Preserves the original order within a group of interceptors with the same priority.
@Zeyber Zeyber requested a review from a team as a code owner October 3, 2023 08:13
@Zeyber Zeyber temporarily deployed to dev October 16, 2023 20:06 — with GitHub Actions Inactive
@Zeyber Zeyber temporarily deployed to dev October 18, 2023 11:35 — with GitHub Actions Inactive
Comment on lines +66 to +68
export async function sendRequest(path: string) {
return new Promise((resolve, reject) => {
const req = http.get({ ...REQUEST_OPTIONS, path }, (res: any) => {
Copy link
Contributor

@Platonn Platonn Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's allow for injecting extra Spartacus config chunk, by passing it via a special cookie.
We already have a mechanism for this (implemented in Spartacus TestConfigModule) and it's already used in our Cypress E2E tests. Let's just use it here as well.
The cookie name is cxConfigE2E and the Spartacus TestConfigModule reads it and injects
the config passed via the cookie into Spartacus global config.

Beloww a snippet of code to pass a the cxConfig as an extra cookie:
NOTE: btw. I've changed the signature of the function's argument from path:string to object {path:string, cxConfig?: Config}

Suggested change
export async function sendRequest(path: string) {
return new Promise((resolve, reject) => {
const req = http.get({ ...REQUEST_OPTIONS, path }, (res: any) => {
import { Config } from '@spartacus/core';
/* ... */
export async function sendRequest({
path,
cxConfig
}: {
path: string,
cxConfig?: Config
}) {
return new Promise((resolve, reject) => {
const req = http.get({
...REQUEST_OPTIONS,
path,
headers: {
Cookie: buildCxConfigCookie(cxConfig)
}, (res: any) => {

and let's add a function:

/**
  * Builds a cookie string with key 'cxConfigE2E' and the given `cxConfig`
  * object as a value that is stringified and URI-encoded.
  *
  * Note: `TestConfigModule` of Spartacus will read this cookie
  * and inject the passed config chunk into Spartacus global config.
  */
function buildCxConfigE2ECookie(cxConfig?: object): string {
  if(!cxConfig) {
    return {};
  }
  const cookieKey = 'cxConfigE2E';
  const cookieValue = encodeURIComponent(JSON.stringify(cxConfig));
  return `${cookieKey}=${cookieValue}`
}

@Zeyber Zeyber changed the base branch from epic/ssr-error-handling to develop April 25, 2024 13:25
@Zeyber Zeyber requested a review from a team April 25, 2024 13:25
@Zeyber Zeyber requested review from a team as code owners April 25, 2024 13:25
@Zeyber Zeyber changed the base branch from develop to epic/ssr-error-handling April 25, 2024 13:28
Base automatically changed from epic/ssr-error-handling to develop September 10, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants