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(add): add tests for settings profile status and reveal recovery #607

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions tests/screenobjects/settings/SettingsProfileScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const SELECTORS_WINDOWS = {
PROFILE_PICTURE_CLEAR: '[name="clear-avatar"]',
RECOVERY_SEED_SECTION: "[name='recovery-seed-section']",
REVEAL_RECOVERY_SEED_BUTTON: "[name='reveal-recovery-seed-button']",
SEED_WORD_VALUE_TEXT: "<Text>",
SEED_WORDS_SECTION: "[name='seed-words-section']",
SELECTOR: "<ComboBox>",
SELECTOR_CURRENT_VALUE: "//Group/Text",
SELECTOR_OPTION: '[name="selector-option"]',
SELECTOR_OPTION_INDICATOR_DO_NOT_DISTURB: "[name='indicator-do-not-disturb']",
SELECTOR_OPTION_INDICATOR_IDLE: "[name='indicator-idle']",
Expand Down Expand Up @@ -91,8 +93,11 @@ const SELECTORS_MACOS = {
PROFILE_PICTURE_CLEAR: "~clear-avatar",
RECOVERY_SEED_SECTION: "~recovery-seed-section",
REVEAL_RECOVERY_SEED_BUTTON: "~reveal-recovery-seed-button",
SEED_WORD_VALUE_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
SEED_WORDS_SECTION: "~seed-words-section",
SELECTOR: "~Selector",
SELECTOR_CURRENT_VALUE:
"-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText",
SELECTOR_OPTION: "~selector-option",
SELECTOR_OPTION_INDICATOR_DO_NOT_DISTURB: "~indicator-do-not-disturb",
SELECTOR_OPTION_INDICATOR_IDLE: "~indicator-idle",
Expand Down Expand Up @@ -269,6 +274,44 @@ export default class SettingsProfileScreen extends SettingsBaseScreen {
return $$(SELECTORS.SETTINGS_CONTROL)[3].$(SELECTORS.SETTINGS_INFO_HEADER);
}

get selector() {
return this.settingsProfile.$(SELECTORS.SELECTOR);
}

get selectorCurrentValue() {
return this.selector.$(SELECTORS.SELECTOR_CURRENT_VALUE);
}

get selectorOption() {
return this.selector.$(SELECTORS.SELECTOR_OPTION);
}

get selectorOptionIndicatorDoNotDisturb() {
return this.selectorOptionsList.$(
SELECTORS.SELECTOR_OPTION_INDICATOR_DO_NOT_DISTURB,
);
}

get selectorOptionIndicatorIdle() {
return this.selectorOptionsList.$(SELECTORS.SELECTOR_OPTION_INDICATOR_IDLE);
}

get selectorOptionIndicatorOffline() {
return this.selectorOptionsList.$(
SELECTORS.SELECTOR_OPTION_INDICATOR_OFFLINE,
);
}

get selectorOptionIndicatorOnline() {
return this.selectorOptionsList.$(
SELECTORS.SELECTOR_OPTION_INDICATOR_ONLINE,
);
}

get selectorOptionsList() {
return this.selector.$(SELECTORS.SELECTOR_OPTIONS_LIST);
}

get settingsProfile() {
return $(SELECTORS.SETTINGS_PROFILE);
}
Expand Down Expand Up @@ -534,4 +577,91 @@ export default class SettingsProfileScreen extends SettingsBaseScreen {
const contextMenu = await this.contextMenu;
await contextMenu.waitForExist();
}

// Online Status Selector Methods
async clickOnSelector() {
const statusSelector = await this.selector;
await statusSelector.click();
}

async selectDoNotDisturbStatus() {
// Open selector
await this.clickOnSelector();

// Select the correct option
const doNotDisturbStatusOption =
await this.selectorOptionIndicatorDoNotDisturb;
await doNotDisturbStatusOption.click();

// Close selector and wait until toast notification is closed
await this.clickOnSelector();
await this.waitUntilNotificationIsClosed();
}

async selectIdleStatus() {
// Open selector
await this.clickOnSelector();

// Select the correct option
const idleStatusOption = await this.selectorOptionIndicatorIdle;
await idleStatusOption.click();

// Close selector and wait until toast notification is closed
await this.clickOnSelector();
await this.waitUntilNotificationIsClosed();
}

async selectOfflineStatus() {
// Open selector
await this.clickOnSelector();

// Select the correct option
const offlineStatusOption = await this.selectorOptionIndicatorOffline;
await offlineStatusOption.click();

// Close selector and wait until toast notification is closed
await this.clickOnSelector();
await this.waitUntilNotificationIsClosed();
}

async selectOnlineStatus() {
// Open selector
await this.clickOnSelector();

// Select the correct option
const onlineStatusOption = await this.selectorOptionIndicatorOnline;
await onlineStatusOption.click();

// Close selector and wait until toast notification is closed
await this.clickOnSelector();
await this.waitUntilNotificationIsClosed();
}

// Recovery Seed Methods

async clickOnRevealRecoverySeed() {
const revealRecoverySeedButton = await this.revealRecoverySeedButton;
await revealRecoverySeedButton.click();
}

async getSeedWord(numberOfWord: string) {
const currentDriver = await this.getCurrentDriver();
let locatorOfWord: string = "";
let word: string = "";
if (currentDriver === WINDOWS_DRIVER) {
locatorOfWord = '[name="seed-word-value-' + numberOfWord + '"]';
} else {
locatorOfWord = "~seed-word-value-" + numberOfWord;
}
word = await $(locatorOfWord).$(SELECTORS.SEED_WORD_VALUE_TEXT).getText();
return word;
}

async getSeedWords() {
let seedWords: string[] = [];
for (let i = 1; i <= 12; i++) {
seedWords.push(await this.getSeedWord(i.toString()));
}
return seedWords;
}
}
59 changes: 59 additions & 0 deletions tests/specs/05-settings-profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CropImageProfileModal from "@screenobjects/settings/CropToolProfileModal"
import FilesScreen from "@screenobjects/files/FilesScreen";
import SettingsProfileScreen from "@screenobjects/settings/SettingsProfileScreen";
import { MACOS_DRIVER } from "@helpers/constants";
import { scrollDown } from "@helpers/commands";
const cropProfile = new CropImageProfileModal();
const filesScreen = new FilesScreen();
const settingsProfile = new SettingsProfileScreen();
Expand Down Expand Up @@ -364,4 +365,62 @@ export default async function settingsProfileTests() {
// Wait for toast notification to be closed before starting next tests
await settingsProfile.waitUntilNotificationIsClosed();
});

it("Settings Profile - Assert contents from Online Status and Recovery Seed", async () => {
// Scroll to bottom of the screen
await scrollDown(1000);

// Validate contents of Online Status section on Settings Profile
const onlineStatusHeader = await settingsProfile.onlineStatusHeader;
const onlineStatusDescription =
await settingsProfile.onlineStatusDescription;
await expect(onlineStatusHeader).toHaveText("ONLINE STATUS");
await expect(onlineStatusDescription).toHaveText(
"Set the appereance of your online status",
luisecm marked this conversation as resolved.
Show resolved Hide resolved
);

// Validate contents of Recovery Seed section on Settings Profile
const recoverySeedHeader = await settingsProfile.recoverySeedHeader;
const recoverySeedDescription =
await settingsProfile.recoverySeedDescription;

await expect(recoverySeedHeader).toHaveText("RECOVERY SEED");
await expect(recoverySeedDescription).toHaveText(
'This seed represents the "master key" to your account. Keep this safe and secure somewhere in order to maintain proper control and security over your Uplink account.',
);
});

it("Settings Profile - Online Status - Default status is Online", async () => {
// Default Online Status is set to "Online"
const currentOnlineStatus = await settingsProfile.selectorCurrentValue;
await expect(currentOnlineStatus).toHaveText("Online");
});

it("Settings Profile - Online Status - Status can be changed", async () => {
// Change Status to Idle
await settingsProfile.selectIdleStatus();

// Validate status is Idle now
const currentOnlineStatus = await settingsProfile.selectorCurrentValue;
await expect(currentOnlineStatus).toHaveText("Idle");
});

it("Settings Profile - Online Status - Status value remains when changing screen", async () => {
// Go to a different screen, return to Settings Profile and validate status is still Idle
await settingsProfile.goToFiles();
await filesScreen.goToSettings();

// Validate status is still Idle
const onlineStatus = await settingsProfile.selectorCurrentValue;
await expect(onlineStatus).toHaveText("Idle");
});

it("Settings Profile - Recovery Seed - User can reveal seed words", async () => {
// Reveal Recovery Seed
await settingsProfile.clickOnRevealRecoverySeed();

// Validate seed words displayed are the same as the ones previously stored
const seedWords = await settingsProfile.getSeedWords();
await expect(seedWords.length).toEqual(12);
});
}
Loading