Skip to content

Commit

Permalink
Do not clear localstorage on logout
Browse files Browse the repository at this point in the history
Deleting identity numbers on logout is unexpected and
destructive. A change was requested to no longer do that.

Instead, we should give users a different way of managing the
numbers shown on the landing page (to be solved as a separate PR).

Note: 3 lines were changed in the production code. The rest is adapting
the e2e tests to use the pick identity flow instead of entering it new.
  • Loading branch information
Frederik Rothenberger committed Sep 25, 2023
1 parent 0a038b1 commit 46bb9bc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 43 deletions.
1 change: 0 additions & 1 deletion src/frontend/src/components/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const logoutSection = (
</div>`;

const logout = () => {
localStorage.clear();
clearHash();
window.location.reload();
};
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/src/flows/manage/deviceSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ export const deleteDevice = async ({
});

if (sameDevice) {
// clear anchor and reload the page.
// reload the page.
// do not call "reload", otherwise the management page will try to reload the list of devices which will cause an error
localStorage.clear();
location.reload();
return;
} else {
Expand Down
23 changes: 8 additions & 15 deletions src/frontend/src/test-e2e/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ export const FLOWS = {
deviceName: string,
browser: WebdriverIO.Browser
): Promise<void> => {
const welcomeView = new WelcomeView(browser);
await welcomeView.waitForDisplay();
await welcomeView.login();
await welcomeView.typeUserNumber(userNumber);
await browser.$("button[data-action='continue']").click();
const authenticateView = new AuthenticateView(browser);
await authenticateView.waitForDisplay();
await authenticateView.pickAnchor(userNumber);
// This flow assumes no recovery phrase, so we explicitly skip the recovery nag here
await FLOWS.skipRecoveryNag(browser);
const mainView = new MainView(browser);
Expand All @@ -101,21 +99,16 @@ export const FLOWS = {
loginPin: async (
userNumber: string,
pin: string,
deviceName: string,
browser: WebdriverIO.Browser
): Promise<void> => {
const welcomeView = new WelcomeView(browser);
await welcomeView.waitForDisplay();
await welcomeView.login();
await welcomeView.typeUserNumber(userNumber);
await browser.$("button[data-action='continue']").click();
const authenticateView = new AuthenticateView(browser);
await authenticateView.waitForDisplay();
await authenticateView.pickAnchor(userNumber);
const pinAuthView = new PinAuthView(browser);
await pinAuthView.waitForDisplay();
await pinAuthView.enterPin(pin);
// This flow assumes no recovery phrase, so we explicitly skip the recovery nag here
await FLOWS.skipRecoveryNag(browser);
const mainView = new MainView(browser);
await mainView.waitForTempKeyDisplay(deviceName);
},
addRecoveryMechanismSeedPhrase: async (
browser: WebdriverIO.Browser
Expand Down Expand Up @@ -172,8 +165,8 @@ export const FLOWS = {
browser: WebdriverIO.Browser,
recoveryPhrase: string
): Promise<void> => {
const welcomeView = new WelcomeView(browser);
await welcomeView.recover();
const authenticateView = new AuthenticateView(browser);
await authenticateView.recover();
const recoveryView = new RecoverView(browser);
await recoveryView.waitForSeedInputDisplay();
await recoveryView.enterSeedPhrase(recoveryPhrase);
Expand Down
22 changes: 7 additions & 15 deletions src/frontend/src/test-e2e/pinAuth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ test("Register and Log in with PIN identity", async () => {
await mainView.waitForDisplay(); // we should be logged in
await mainView.waitForTempKeyDisplay(DEFAULT_PIN_DEVICE_NAME);
await mainView.logout();
await FLOWS.loginPin(userNumber, pin, DEFAULT_PIN_DEVICE_NAME, browser);
await FLOWS.loginPin(userNumber, pin, browser);
await mainView.waitForTempKeyDisplay(DEFAULT_PIN_DEVICE_NAME);
}, APPLE_USER_AGENT);
}, 300_000);

Expand All @@ -69,11 +70,10 @@ test("Register and log in with PIN identity, retry on wrong PIN", async () => {
await mainView.waitForDisplay(); // we should be logged in
await mainView.logout();

const welcomeView = new WelcomeView(browser);
await welcomeView.waitForDisplay();
await welcomeView.login();
await welcomeView.typeUserNumber(userNumber);
await browser.$("button[data-action='continue']").click();
const authenticateView = new AuthenticateView(browser);
await authenticateView.waitForDisplay();
await authenticateView.pickAnchor(userNumber);

const pinAuthView = new PinAuthView(browser);
await pinAuthView.waitForDisplay();
await pinAuthView.enterPin(wrongPin);
Expand Down Expand Up @@ -155,15 +155,7 @@ test("Register with PIN then log into client application", async () => {

await switchToPopup(browser);

const authenticateView = new AuthenticateView(browser);
await authenticateView.waitForDisplay();
await authenticateView.pickAnchor(userNumber);

const pinAuthView = new PinAuthView(browser);
await pinAuthView.waitForDisplay();
await pinAuthView.enterPin(pin);

await FLOWS.skipRecoveryNag(browser);
await FLOWS.loginPin(userNumber, pin, browser);
await waitToClose(browser);

await demoAppView.waitForDisplay();
Expand Down
21 changes: 11 additions & 10 deletions src/frontend/src/test-e2e/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ export class WelcomeView extends View {
await this.browser.$("#loginButton").click();
await this.browser.$("#addNewDeviceButton").click();
}

async recover(): Promise<void> {
await this.browser.$("#loginButton").waitForDisplayed();
await this.browser.$("#loginButton").scrollIntoView();
await this.browser.$("#loginButton").click();
await this.browser.$("#recoverButton").waitForDisplayed();
await this.browser.$("#recoverButton").scrollIntoView();
await this.browser.$("#recoverButton").click();
await this.browser.$('[data-action="recover-with-phrase"]').click();
}
}

export class RenameView extends View {
Expand Down Expand Up @@ -537,6 +527,17 @@ export class AuthenticateView extends View {
async switchToAnchorInput(): Promise<void> {
await this.browser.$('[data-role="anchor-input"]').click();
}

async recover(): Promise<void> {
await await this.browser.$('[data-role="more-options"]').click();
await this.browser.$("#recoverButton").waitForDisplayed();
await this.browser.$("#recoverButton").scrollIntoView();
await this.browser.$("#recoverButton").click();
await this.browser
.$('[data-action="recover-with-phrase"]')
.waitForDisplayed();
await this.browser.$('[data-action="recover-with-phrase"]').click();
}
}

export class WelcomeBackView extends View {
Expand Down

0 comments on commit 46bb9bc

Please sign in to comment.