You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dispatch custom events on marketing components (#14875)
* Dispatch custom events on marketing components appearing and disappearing in the viewport.
* eventTypes structured
* remove eventEmitter from epicContent.apps
Copy file name to clipboardExpand all lines: dotcom-rendering/src/components/SignInGate/README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
## Quick Setup Guide
4
4
5
5
1. Create AB test switch in [guardian/frontend](https://github.com/guardian/frontend/blob/main/common/app/conf/switches/ABTestSwitches.scala), [docs](https://github.com/guardian/frontend/blob/main/docs/03-dev-howtos/01-ab-testing.md#adding-a-switch)
6
-
2. Add test definition to `src/web/experiments/tests` folder, and import test in the `src/web/experiments/ab-tests.ts` file. Variant name in test definition must be unique.
6
+
2. Add test definition to `src/experiments/tests` folder, and import test in the `src/experiments/ab-tests.ts` file. Variant name in test definition must be unique.
7
7
3. Import test definition in the `signInGateTests` array in the `signInGate.ts`
8
8
4. If the test needs a design, make it in the `gateDesigns` folder
9
9
5. Set up individual variants in the `gates` folder, exports the `SignInGateComponent` type. Display rules defined here in the `canShow` method. Helpers in `displayRule.ts`.
@@ -78,7 +78,7 @@ When running dotcom-rendering locally for development, it is useful to have fron
78
78
79
79
#### AB Test Definition
80
80
81
-
Once the switch is set up, you'll need to add a test definition to the `src/web/experiments/tests` folder. Here's an example of a test definition.
81
+
Once the switch is set up, you'll need to add a test definition to the `src/experiments/tests` folder. Here's an example of a test definition.
82
82
83
83
```ts
84
84
import { ABTest } from'@guardian/ab-core';
@@ -124,13 +124,13 @@ The most important properties are:
124
124
-`canRun` - A function to determine if the test is allowed to run (Eg, so you can target individual pages, segments etc.). For the sign in gate, this is likely always just returning true, since the display rules for the gate are determined in the component itself.
125
125
-`variants` - An array of objects representing the groups (variants) in the test. In terms of the object properties, the main one that's required for the sign in gate is the `id` property. This is the `id` of the variant, and should be unique across all sign in gate tests. The `run` property should just be void, since we display the test elsewhere.
126
126
127
-
Once you've made the test definition, you'll need to import it into the `tests` array in the `src/web/experiments/ab-tests.ts` file.
127
+
Once you've made the test definition, you'll need to import it into the `tests` array in the `src/experiments/ab-tests.ts` file.
128
128
129
129
The test definition should also be replicated in `frontend` too if the same sign in gate tests is required on both `DCR` and `frontend`. Use the existing documentation in [`frontend`](https://github.com/guardian/frontend/blob/main/static/src/javascripts/projects/common/modules/identity/sign-in-gate/README.md) to set up the tests there. Tests should be mirrored is as far as possible.
130
130
131
131
### Sign In Gate Design
132
132
133
-
The designs for the gate live as React components in the `src/web/components/SignInGate/gateDesigns` folder.
133
+
The designs for the gate live as React components in the `src/components/SignInGate/gateDesigns` folder.
134
134
135
135
#### Gate Component
136
136
@@ -144,10 +144,10 @@ The ideal way to view/develop the design is to use Storybook. See "Storybook" in
144
144
145
145
### Sign In Gate Component
146
146
147
-
In the `src/web/components/SignInGate/gates` folder, we have a file for each unique variant. Each file exports a `SignInGateComponent` type which is defined as:
147
+
In the `src/components/SignInGate/gates` folder, we have a file for each unique variant. Each file exports a `SignInGateComponent` type which is defined as:
Now that the required components have been set up, the AB tests must be matched to the SignInGateComponent that we've created.
225
225
226
-
All of the following section happens in the `src/web/components/SignInGate/signInGate.ts` file.
226
+
All of the following section happens in the `src/components/SignInGate/signInGate.ts` file.
227
227
228
228
#### AB Tests
229
229
@@ -398,7 +398,7 @@ To run the cypress tests interactively, make sure the development server is runn
398
398
399
399
Since the Cypress tests rely on a production article, it would normally get the AB switch state from there. In some cases this switch may not be on, or may not be defined yet, in turn meaning that the Cypress tests will fail.
400
400
401
-
To decouple the switch state from production, we define the state of the switch in DCR that will be set only when running within Cypress. In `src/web/experiments/cypress-switches.ts` update the `cypressSwitches` object to add the switch and state for your new test.
401
+
To decouple the switch state from production, we define the state of the switch in DCR that will be set only when running within Cypress. In `src/experiments/cypress-switches.ts` update the `cypressSwitches` object to add the switch and state for your new test.
402
402
403
403
```ts
404
404
...
@@ -413,6 +413,6 @@ Now the AB test will be picked up even if the switch does not exist yet in Front
413
413
414
414
#### Unit Tests
415
415
416
-
Finally for specific code which can be unit tested too, there are some tests for those too. For display rules, you'll find them in `src/web/components/SignInGate/displayRule.test.ts` and for the setting/checking if the gate has been dismissed in `src/web/components/SignInGate/dismissGate.test.ts`. Ideally unit tests should not be a replacement for the integration tests.
416
+
Finally for specific code which can be unit tested too, there are some tests for those too. For display rules, you'll find them in `src/components/SignInGate/displayRule.test.ts` and for the setting/checking if the gate has been dismissed in `src/components/SignInGate/dismissGate.test.ts`. Ideally unit tests should not be a replacement for the integration tests.
417
417
418
-
You can run tests using `pnpm test`, if you want to run for a specific test file use `pnpm test ./path/to/file` e.g. `pnpm test ./src/web/components/SignInGate/displayRule.test.ts`
418
+
You can run tests using `pnpm test`, if you want to run for a specific test file use `pnpm test ./path/to/file` e.g. `pnpm test ./src/components/SignInGate/displayRule.test.ts`
0 commit comments