Skip to content

Commit

Permalink
final stage
Browse files Browse the repository at this point in the history
  • Loading branch information
tttt24 committed Nov 15, 2023
1 parent 1cac2bd commit 70a2413
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 52 deletions.
2 changes: 2 additions & 0 deletions e2e/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ WATCH_ONLY_PUBLIC_KEY_HASH_SHORT_FORM=

CUSTOM_NETWORK_RPC_URL=
CUSTOM_NETWORK_SECOND_RPC_URL=

NOTIFICATION_AUTHORIZATION=
36 changes: 35 additions & 1 deletion e2e/src/features/notifications.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,38 @@ Feature: Notifications
And I have imported an existing account
And I press Notification Icon Button on the Home page

And I am on the page
And I am on the NotificationsList page
And I check that a notification with 'Test Title' title and 'Test description' description is displayed
And I click on the notification with 'Test Title' title and 'Test description' description

And I am on the NotificationContent page
And The Notification Title Text on the Notification Content page has correct Test Title value
And The Notification Description Text on the Notification Content page has correct Test content value

And I press Got it Button on the Notification Content page
And I am on the NotificationsList page

And I press Account Icon on the Header page
And I am on the AccountsDropdown page

And I press Settings Button on the Account Drop-down page
And I am on the Settings page

And I press General Button on the Settings page
And I am on the GeneralSettings page
# turning off notifications
And I scroll 900 pixels on the GeneralSettings page
And I press Notification Check Box on the Setting General page

And I scroll -900 pixels on the GeneralSettings page
And I press Temple Logo Icon on the Header page
And I am on the Home page

And I press Notification Icon Button on the Home page
And I am on the NotificationsList page

Then I check that a notification with 'Test Title' title and 'Test description' description is NOT displayed




5 changes: 4 additions & 1 deletion e2e/src/page-objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AddAssetPage } from 'e2e/src/page-objects/pages/add-asset.page';
import { AddressBookPage } from 'e2e/src/page-objects/pages/address-book.page';
import { ConfirmationModalPage } from 'e2e/src/page-objects/pages/confirmation-modal.page';
import { NetworksDropDown } from 'e2e/src/page-objects/pages/drop-down-lists/networks.drop-down';
// eslint-disable-next-line import/namespace
import { GeneralSettingsPage } from 'e2e/src/page-objects/pages/general-settings.page';
import { ManageAssetsCollectiblesPage } from 'e2e/src/page-objects/pages/manage-assets-collectibles.page';
import { ManageAssetsTokensPage } from 'e2e/src/page-objects/pages/manage-assets-tokens.page';
import { NetworksPage } from 'e2e/src/page-objects/pages/networks.page';
Expand Down Expand Up @@ -83,5 +85,6 @@ export const Pages = {
OnboardingFourthStep: new OnboardingFourthStepPage(),
OnboardingCongrats: new OnboardingCongratsPage(),
NotificationsList: new NotificationsListPage(),
NotificationContent: new NotificationContentPage()
NotificationContent: new NotificationContentPage(),
GeneralSettings: new GeneralSettingsPage()
};
29 changes: 29 additions & 0 deletions e2e/src/page-objects/pages/general-settings.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SettingsGeneralSelectors } from 'src/app/templates/SettingsGeneral/selectors';

import { Page } from '../../classes/page.class';
import { createPageElement } from '../../utils/search.utils';

export class GeneralSettingsPage extends Page {
languageitem = createPageElement(SettingsGeneralSelectors.languageitem);
languageDropDown = createPageElement(SettingsGeneralSelectors.languageDropDown);
currencyItem = createPageElement(SettingsGeneralSelectors.currencyItem);
currenctyDropDown = createPageElement(SettingsGeneralSelectors.currenctyDropDown);
blockExplorerItem = createPageElement(SettingsGeneralSelectors.blockExplorerItem);
blockExplorerDropDown = createPageElement(SettingsGeneralSelectors.blockExplorerDropDown);
popUpCheckBox = createPageElement(SettingsGeneralSelectors.popUpCheckBox);
extensionLockUpCheckBox = createPageElement(SettingsGeneralSelectors.extensionLockUpCheckBox);
anonymousAnalyticsCheckBox = createPageElement(SettingsGeneralSelectors.anonymousAnalyticsCheckBox);
notificationCheckBox = createPageElement(SettingsGeneralSelectors.notificationCheckBox);
partnersPromotion = createPageElement(SettingsGeneralSelectors.partnersPromotion);

async isVisible() {
await this.languageDropDown.waitForDisplayed();
await this.currenctyDropDown.waitForDisplayed();
await this.blockExplorerDropDown.waitForDisplayed();
await this.popUpCheckBox.waitForDisplayed();
await this.extensionLockUpCheckBox.waitForDisplayed();
await this.anonymousAnalyticsCheckBox.waitForDisplayed();
await this.notificationCheckBox.waitForDisplayed();
await this.partnersPromotion.waitForDisplayed();
}
}
43 changes: 30 additions & 13 deletions e2e/src/page-objects/pages/notifications-list.page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import retry from 'async-retry';
import { PreviewItemSelectors } from 'src/lib/notifications/components/notifications/preview-item.selectors';

import { RETRY_OPTIONS } from 'e2e/src/utils/timing.utils';
import { VERY_SHORT_TIMEOUT } from 'e2e/src/utils/timing.utils';

import { Page } from '../../classes/page.class';
import { createPageElement, findElement } from '../../utils/search.utils';
Expand All @@ -17,17 +16,35 @@ export class NotificationsListPage extends Page {
await this.notificationItemDescriptionText.waitForDisplayed();
}

async isNotificationNotDisplayed(title: string, shortDescription: string) {
await retry(
async () =>
(await findElement(PreviewItemSelectors.notificationItemTitleText, { title })) &&
findElement(PreviewItemSelectors.notificationItemDescriptionText, { shortDescription }).then(
() => {
throw new Error(`The notification '${title}' is displayed after turning off 'news' checkbox in settings`);
},
() => undefined
),
RETRY_OPTIONS
async isNotificationDisplayed(title: string, description: string) {
const notificationText = await findElement(
PreviewItemSelectors.notificationItemTitleText,
{ title },
VERY_SHORT_TIMEOUT,
`Notification with ${title} title is not displayed`
);

await findElement(
PreviewItemSelectors.notificationItemDescriptionText,
{ description },
VERY_SHORT_TIMEOUT,
`Notification with ${description} description is not displayed`
);

return notificationText;
}

async clickOnTheNotification(title: string, description: string) {
const selectedNotification = await this.isNotificationDisplayed(title, description);
await selectedNotification.click();
}

async isNotificationNotDisplayed(title: string, description: string) {
await this.isNotificationDisplayed(title, description).then(
() => {
throw new Error(`The notification '${title}' is displayed after turning off 'news' checkbox in settings`);
},
() => undefined
);
}
}
35 changes: 0 additions & 35 deletions e2e/src/step-definitions/common.steps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Given } from '@cucumber/cucumber';
import axios from 'axios';

import { envVars } from 'e2e/src/utils/env.utils';

import { BrowserContext } from '../classes/browser-context.class';
import { Pages } from '../page-objects';
Expand Down Expand Up @@ -65,35 +62,3 @@ Given(
await Pages[page].scrollTo(countOfScroll);
}
);

Given(/I make request for creating a notification/, { timeout: MEDIUM_TIMEOUT }, async () => {
const currentDate = new Date();
const currentDateISO = new Date().toISOString();
const expirationDateISO = new Date(currentDate.getTime() + 240000).toISOString(); // Notification will be deleted in 4 minutes

const requestBody = {
mobile: 'off',
extension: 'on',
type: 'News',
title: 'Test Title',
description: 'Test description',
extensionImageUrl:
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRtIvsRFAUjlUKqlsLnrrJnWtcx98vOncHTXQ&usqp=CAU',
mobileImageUrl: '',
content: 'Test content',
date: currentDateISO,
expirationDate: expirationDateISO
};

const response = await axios.post('https://temple-api-mainnet.stage.madfish.xyz/api/notifications', requestBody, {
headers: {
'Content-Type': 'application/json',
Authorization: envVars.NOTIFICATION_AUTHORIZATION
}
});

if (response.status !== 200)
throw new Error(
`Some problems with backend server. Server returns ${response.statusText} with ${response.status} status code`
);
});
52 changes: 51 additions & 1 deletion e2e/src/step-definitions/notifications.steps.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,63 @@
import { Given } from '@cucumber/cucumber';
import axios from 'axios';

import { envVars } from 'e2e/src/utils/env.utils';
import { MEDIUM_TIMEOUT } from 'e2e/src/utils/timing.utils';

import { Pages } from '../page-objects';

Given(
/I check that a notification with (.*) title and (.*) description is not displayed/,
/I check that a notification with '(.*)' title and '(.*)' description is displayed/,
{ timeout: MEDIUM_TIMEOUT },
async (title: string, shortDescription: string) => {
await Pages.NotificationsList.isNotificationDisplayed(title, shortDescription);
}
);

Given(
/I check that a notification with '(.*)' title and '(.*)' description is NOT displayed/,
{ timeout: MEDIUM_TIMEOUT },
async (title: string, shortDescription: string) => {
await Pages.NotificationsList.isNotificationNotDisplayed(title, shortDescription);
}
);

Given(
/I click on the notification with '(.*)' title and '(.*)' description/,
{ timeout: MEDIUM_TIMEOUT },
async (title: string, shortDescription: string) => {
await Pages.NotificationsList.clickOnTheNotification(title, shortDescription);
}
);

Given(/I make request for creating a notification/, { timeout: MEDIUM_TIMEOUT }, async () => {
const currentDate = new Date();
const currentDateISO = new Date().toISOString();
const expirationDateISO = new Date(currentDate.getTime() + 60000).toISOString(); // Notification will be deleted in 4 minutes

const requestBody = {
mobile: 'off',
extension: 'on',
type: 'News',
title: 'Test Title',
description: 'Test description',
extensionImageUrl:
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRtIvsRFAUjlUKqlsLnrrJnWtcx98vOncHTXQ&usqp=CAU',
mobileImageUrl: '',
content: 'Test content',
date: currentDateISO,
expirationDate: expirationDateISO
};

const response = await axios.post('https://temple-api-mainnet.stage.madfish.xyz/api/notifications', requestBody, {
headers: {
'Content-Type': 'application/json',
Authorization: envVars.NOTIFICATION_AUTHORIZATION
}
});

if (response.status !== 200)
throw new Error(
`Some problems with backend server. Server returns ${response.statusText} with ${response.status} status code`
);
});
3 changes: 2 additions & 1 deletion e2e/src/utils/browser.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const initBrowser = () =>
`--disable-extensions-except=${EXTENSION_PATH}`,
`--load-extension=${EXTENSION_PATH}`,
'--user-agent=E2EPipeline/0.0.1',
'--start-fullscreen'
'--start-fullscreen',
'--disable-notifications'
],
slowMo: 10
});
Expand Down

0 comments on commit 70a2413

Please sign in to comment.