Skip to content

Commit 795bd72

Browse files
committed
Fix for e2e Tests
Signed-off-by: Mike Lischke <mike@lischke-online.de>
1 parent f458f6e commit 795bd72

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default defineConfig({
1515
trace: "on-first-retry",
1616
screenshot: "only-on-failure",
1717
video: "retain-on-failure",
18+
storageState: "tests/e2e/storage-state.json",
1819
},
1920
webServer: {
2021
command: process.env.CI ? "npm run serve:e2e" : "npm run build && npm run serve:e2e",

src/ui/TutorialWizard.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export class TutorialWizard extends Component<ITutorialWizardProps, ITutorialWiz
4747
}
4848

4949
public override componentDidUpdate(_prevProps: ITutorialWizardProps, prevState: ITutorialWizardState): void {
50-
if (prevState.currentStep !== this.state.currentStep) {
50+
const { currentStep } = this.state;
51+
52+
if (prevState.currentStep !== currentStep) {
5153
this.syncObserver();
5254
}
5355
}
@@ -78,8 +80,10 @@ export class TutorialWizard extends Component<ITutorialWizardProps, ITutorialWiz
7880
}
7981

8082
public open(): void {
83+
const { onStepChange } = this.props;
84+
8185
this.setState({ currentStep: 0 }, () => {
82-
this.props.onStepChange?.(0);
86+
onStepChange?.(0);
8387
this.portalRef.current?.open({
8488
backgroundOpacity: 0,
8589
closeOnEscape: true,
@@ -94,23 +98,25 @@ export class TutorialWizard extends Component<ITutorialWizardProps, ITutorialWiz
9498
}
9599

96100
private cleanupObserver(): void {
101+
const { targetRect } = this.state;
102+
97103
this.resizeObserver?.disconnect();
98104
this.resizeObserver = undefined;
99105
this.observedElement = undefined;
100-
if (this.state.targetRect) {
106+
if (targetRect) {
101107
this.setState({ targetRect: undefined });
102108
}
103109
}
104110

105111
private syncObserver(): void {
106112
const { steps } = this.props;
107-
const { currentStep } = this.state;
113+
const { currentStep, targetRect } = this.state;
108114
const step = steps[currentStep];
109115

110116
if (!step.targetSelector) {
111117
this.resizeObserver?.disconnect();
112118
this.observedElement = undefined;
113-
if (this.state.targetRect) {
119+
if (targetRect) {
114120
this.setState({ targetRect: undefined });
115121
}
116122

tests/e2e/storage-state.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"cookies": [],
3+
"origins": [
4+
{
5+
"origin": "http://127.0.0.1:4173",
6+
"localStorage": [
7+
{
8+
"name": "asb-ui-settings",
9+
"value": "{\"tutorialEnabled\":false}"
10+
}
11+
]
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)