hubl/cypress/integration/list-users.spec.js

120 lines
4.9 KiB
JavaScript

/// <reference types="Cypress" />
/* globals cy, expect */
context('List Users Browser Testing', () => {
let listQuery = 'solid-display#members-list__content',
filtersQuery = [
listQuery,
'solid-form',
'input'
],
listingCountQuery = [
listQuery,
'div:first-child',
'span'
],
firstListingQuery = [
listQuery,
'solid-display:first-child',
'solid-display-value'
];
before(() => {
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
beforeEach(() => cy.restoreLocalStorage());
afterEach(() => cy.saveLocalStorage());
it('should visit user login screen', () => cy.userLogin());
it('should login', () => cy.login());
describe('User Listing process', () => {
let listingFirstName,
listingLastName,
listingJob,
listingCity,
listingCount;
it('should visit the users listing screen', () => cy.naviagte('/members'));
it('should get the listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => listingCount = text);
});
it('should get the first user listing data', () => {
cy.get(firstListingQuery.join(' ') + '[name="first_name"]').invoke('text').then(text => listingFirstName = text);
cy.get(firstListingQuery.join(' ') + '[name="last_name"]').invoke('text').then(text => listingLastName = text);
cy.get(firstListingQuery.join(' ') + '[name="profile.job"]').invoke('text').then(text => listingJob = text);
cy.get(firstListingQuery.join(' ') + '[name="profile.city"]').invoke('text').then(text => listingCity = text);
});
it('should filter the listing by first name', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear().type(listingFirstName);
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', listingFirstName);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the first name filter', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear();
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
it('should filter the listing by last name', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear().type(listingLastName);
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', listingLastName);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the last name filter', () => {
cy.get(filtersQuery.join(' ') + '[name="name"]').clear();
cy.get(filtersQuery.join(' ') + '[name="name"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
it('should filter the listing by job description', () => {
cy.get(filtersQuery.join(' ') + '[name="member-job"]').clear().type(listingJob);
cy.get(filtersQuery.join(' ') + '[name="member-job"]').should('have.value', listingJob);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the job description filter', () => {
cy.get(filtersQuery.join(' ') + '[name="member-job"]').clear();
cy.get(filtersQuery.join(' ') + '[name="member-job"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
it('should filter the listing by city', () => {
cy.get(filtersQuery.join(' ') + '[name="member-city"]').clear().type(listingCity);
cy.get(filtersQuery.join(' ') + '[name="member-city"]').should('have.value', listingCity);
});
it('should get filtered listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq('1 membres');
});
});
it('should clear the city filter', () => {
cy.get(filtersQuery.join(' ') + '[name="member-city"]').clear();
cy.get(filtersQuery.join(' ') + '[name="member-city"]').should('have.value', '');
});
it('should get previous listing count', () => {
cy.get(listingCountQuery.join(' ')).invoke('text').then(text => {
expect(text).to.eq(listingCount);
});
});
});
});