Skip to content

Commit

Permalink
fix: lighthouse test for dashboard needs local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
gulfaraz committed Mar 4, 2021
1 parent 413f2e2 commit 280e7d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ion-button
buttonType="button"
type="submit"
class="login-button"
expand="block"
[disabled]="!loginForm.form.valid"
>
Expand Down
6 changes: 3 additions & 3 deletions interfaces/IBF-dashboard/src/app/services/jwt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export class JwtService {
private jwtHelper = new JwtHelperService();

public getToken(): string | undefined {
return window.sessionStorage[this.tokenKey];
return window.localStorage[this.tokenKey];
}

public saveToken(token: string): void {
window.sessionStorage[this.tokenKey] = token;
window.localStorage[this.tokenKey] = token;
}

public destroyToken(): void {
window.sessionStorage.removeItem(this.tokenKey);
window.localStorage.removeItem(this.tokenKey);
}

public decodeToken(rawToken: string): any {
Expand Down
6 changes: 5 additions & 1 deletion tests/lighthouse/lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ module.exports = {
puppeteerScript: "./tests/lighthouse/login-script.js",
puppeteerLaunchOptions: {
defaultViewport: null,
args: ["--disable-gpu --window-size=1280,720", "--no-sandbox"],
args: [
"--disable-gpu",
"--window-size=1280,720",
"--no-sandbox",
],
headless: true,
},
headful: false,
Expand Down
4 changes: 2 additions & 2 deletions tests/lighthouse/login-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const LOGIN_PASSWORD = process.env.LOGIN_PASSWORD;
const locators = {
inputLoginEmail: 'input[type="email"]',
inputLoginPassword: 'input[type="password"]',
loginForm: ".login-form",
loginButton: ".login-button",
};

module.exports = async (browser, context) => {
Expand All @@ -25,7 +25,7 @@ module.exports = async (browser, context) => {
const passwordInput = await page.$(locators.inputLoginPassword);
await passwordInput.type(LOGIN_PASSWORD);
await Promise.all([
page.$eval(locators.loginForm, form => form.submit()),
page.$eval(locators.loginButton, button => button.click()),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]).catch(function (err) {
console.log("Login Failed");
Expand Down

0 comments on commit 280e7d8

Please sign in to comment.