I have a component which is displayed only after the user is logged in...
<div data-e2e="profile-dd" class="profile-dropdown" [ngClass]="{'white-text': router.url.search('profile') === -1, 'black-text': router.url.search('profile') !== -1}" (click)="showProfile = !showProfile">
<img data-e2e="profile-img" class="circular-photo" alt="person_dp" [src]="person.profile_photo" />
<i class="cm" [ngClass]="{'cm-arrow-down': !showProfile, 'cm-arrow-up': showProfile}"></i>
</div>
I want to check this element to exist when the user is logged. In my .po.ts
the file I have a function to get this element as:
export class AppPage {
...
...
async checkIfUserLoggedIn() {
return await element(by.css('[data-e2e="profile-dd"]')).isPresent();
}
}
In my .e2e-spec.ts
the file I wrote a test, which is failing, which logs Expected false to be true.
describe('YOP Login page tests', function () {
let loginPage: LoginPage;
let appPage: AppPage;
beforeEach(() => {
loginPage = new LoginPage();
appPage = new AppPage();
});
...
...
it('User should be logged in successfully', () => {
appPage.checkIfUserLoggedIn().then(res => {
expect<any>(res).toBe(true);
});
});
});
Can anybody help me where I'm going wrong?
PS- I've written one more random test just below it. It is working, that means the browser is not crashing.