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

chore: lint header #3660

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
import Header from '@frontend/shared/browser-tests/page-models/Header';
import { DEFAULT_LANGUAGE } from '@frontend/shared/src/i18n/i18n';
import User from '@frontend/shared/src/types/user';
import TestController from 'testcafe';

import getEmployerTranslationsApi from '../../src/__tests__/utils/i18n/get-employer-translations-api';

Expand All @@ -18,6 +17,6 @@ export const doEmployerLogin = async (
await header.userIsLoggedOut();
await header.clickLoginButton();
const suomiFiData = await doLogin(t, lang, cachedUser);
await header.userIsLoggedIn(suomiFiData.user ?? cachedUser);
await header.userIsLoggedIn();
return suomiFiData;
};
14 changes: 4 additions & 10 deletions frontend/shared/browser-tests/page-models/Header.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Selector, t } from 'testcafe';

import TranslationsApi from '../../src/__tests__/types/translations';
import isRealIntegrationsEnabled from '../../src/flags/is-real-integrations-enabled';
import { Language } from '../../src/i18n/i18n';
import User from '../../src/types/user';
import TranslatedComponent, { CommonTranslations } from './TranslatedComponent';

class Header<
Expand All @@ -15,15 +13,10 @@ class Header<
}

private withinNavigationActions = this.within(
// eslint-disable-next-line no-secrets/no-secrets
Selector('div[class*="HeaderActionBar-module_headerActions"]')
);

private getUserInfo(user?: User): string {
return `${
isRealIntegrationsEnabled() ? 'Mika Hietanen' : user?.name ?? ''
}`;
}

private headerTitle(): Selector {
return this.within(this.component.findByRole('banner'))
.findAllByText(this.translations.appName)
Expand All @@ -47,6 +40,7 @@ class Header<
});
}

// eslint-disable-next-line class-methods-use-this
private userInfoDropdown(): Selector {
return Selector('button').withAttribute(
'aria-controls',
Expand All @@ -60,7 +54,7 @@ class Header<
});
}

public userIsLoggedIn(user?: User): Promise<void> {
public userIsLoggedIn(): Promise<void> {
return this.expect(this.userInfoDropdown());
}

Expand All @@ -76,7 +70,7 @@ class Header<
return t.click(this.loginButton());
}

public async clickLogoutButton(user?: User): Promise<void> {
public async clickLogoutButton(): Promise<void> {
return t.click(this.userInfoDropdown()).click(this.logoutButton());
}
}
Expand Down
Loading