Skip to content

Commit 44df2b9

Browse files
committed
Refactor
create page file
1 parent 99476f2 commit 44df2b9

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
1-
import {Selector, t} from 'testcafe';
1+
import {t} from 'testcafe';
2+
import {OnboardingPage, BrowserPage} from '../pageObjects';
23

4+
const onboardingPage = new OnboardingPage();
5+
const browserPage = new BrowserPage();
36
export class OnboardActions {
47
/**
58
@param stepName title of the step
69
verify onboarding step visible based on title
710
*/
811
async verifyStepVisible(stepName: string): Promise<void> {
9-
await t.expect(Selector('[data-testid=step-title]').withText(stepName).exists).ok(`${stepName} step is not visible`);
12+
await t.expect(onboardingPage.stepTitle.withText(stepName).exists).ok(`${stepName} step is not visible`);
1013
}
1114
/**
1215
click next step
1316
*/
1417
async clickNextStep(): Promise<void> {
15-
await t.click(Selector('[data-testid=next-btn]'));
18+
await t.click(onboardingPage.nextButton);
1619
}
1720
/**
1821
start onboarding process
1922
*/
2023
async startOnboarding(): Promise<void> {
21-
await t.click(Selector('span').withText('Show me around'));
24+
await t.click(onboardingPage.showMeAroundButton);
2225
}
2326
/**
2427
complete onboarding process
2528
*/
26-
async verifyOnbardingCompleted(): Promise<void> {
27-
await t.expect(Selector('span').withText('Show me around').visible).notOk('show me around button still visible');
28-
await t.expect(Selector('[data-testid=search-mode-switcher]').visible).ok('browser page is not opened');
29+
async verifyOnboardingCompleted(): Promise<void> {
30+
await t.expect(onboardingPage.showMeAroundButton.visible).notOk('show me around button still visible');
31+
await t.expect(browserPage.patternModeBtn.visible).ok('browser page is not opened');
2932
}
3033
/**
3134
click back step
3235
*/
3336
async clickBackStep(): Promise<void> {
34-
await t.click(Selector('[data-testid=back-btn]'));
37+
await t.click(onboardingPage.backButton);
3538
}
3639
/**
3740
click skip tour step
3841
*/
3942
async clickSkipTour(): Promise<void> {
40-
await t.click(Selector('[data-testid=skip-tour-btn]'));
43+
await t.click(onboardingPage.skipTourButton);
4144
}
4245
}

tests/e2e/pageObjects/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { OverviewPage } from './overview-page';
1616
import { PubSubPage } from './pub-sub-page';
1717
import { SlowLogPage } from './slow-log-page';
1818
import { NotificationPage } from './notification-page';
19+
import { OnboardingPage} from './onboarding-page';
1920

2021
export {
2122
AddRedisDatabasePage,
@@ -35,5 +36,6 @@ export {
3536
OverviewPage,
3637
PubSubPage,
3738
SlowLogPage,
38-
NotificationPage
39+
NotificationPage,
40+
OnboardingPage
3941
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Selector } from 'testcafe';
2+
3+
export class OnboardingPage {
4+
backButton = Selector('[data-testid=back-btn]');
5+
nextButton = Selector('[data-testid=next-btn]');
6+
showMeAroundButton = Selector('span').withText('Show me around');
7+
skipTourButton = Selector('[data-testid=skip-tour-btn]');
8+
stepTitle = Selector('[data-testid=step-title]');
9+
}

tests/e2e/tests/regression/browser/onboarding.e2e.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ fixture `Onboarding new user tests`
3131
.afterEach(async() => {
3232
await deleteDatabase(ossStandaloneConfig.databaseName);
3333
});
34-
test.skip('verify onboard new user steps', async t => {
35-
// start onboarding process
36-
// Verify that when user agree with the onboarding, can see the steps and logic described in the “Steps” table.
34+
test('Verify onbarding new user steps', async t => {
3735
await onBoardActions.startOnboarding();
3836
// verify browser step is visible
3937
await onBoardActions.verifyStepVisible('Browser');
@@ -87,9 +85,9 @@ test.skip('verify onboard new user steps', async t => {
8785
await onBoardActions.verifyStepVisible('Great job!');
8886
await onBoardActions.clickNextStep();
8987
// verify onboarding step completed successfully
90-
await onBoardActions.verifyOnbardingCompleted();
88+
await onBoardActions.verifyOnboardingCompleted();
9189
});
92-
test.skip('verify onboard new user skip tour', async() => {
90+
test('verify onboard new user skip tour', async() => {
9391
// start onboarding process
9492
await onBoardActions.startOnboarding();
9593
// verify browser step is visible
@@ -101,9 +99,9 @@ test.skip('verify onboard new user skip tour', async() => {
10199
// click skip tour
102100
await onBoardActions.clickSkipTour();
103101
// verify onboarding step completed successfully
104-
await onBoardActions.verifyOnbardingCompleted();
102+
await onBoardActions.verifyOnboardingCompleted();
105103
await common.reloadPage();
106104
// verify onboarding step still not visible after refresh page
107-
await onBoardActions.verifyOnbardingCompleted();
105+
await onBoardActions.verifyOnboardingCompleted();
108106
});
109107

0 commit comments

Comments
 (0)