Skip to content

Commit

Permalink
chore(e2e): remove most of the tests temporary (akveo#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa authored and tibing-old-email committed Nov 15, 2018
1 parent 31b7184 commit 1aa0786
Show file tree
Hide file tree
Showing 26 changed files with 2,457 additions and 4,696 deletions.
58 changes: 0 additions & 58 deletions e2e/accordion.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 +42,4 @@ describe('accordion', () => {
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'expanded'),
).toBeTruthy('second is expanded');
});

it('should expand a first accordion-item', () => {
element(by.css('nb-accordion > nb-accordion-item:nth-child(1)')).click();

expect(
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(1)')), 'expanded'),
).toBeTruthy();

expect(
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(3)')), 'collapsed'),
).toBeTruthy();

expect(
element(by.css('nb-accordion > nb-accordion-item:nth-child(1) > nb-accordion-item-header')).getAttribute(
'aria-expanded',
),
).toEqual('true');
});

it('should display the tabbable accordion items', () => {
expect(
element(by.css('nb-accordion > nb-accordion-item:nth-child(1) > nb-accordion-item-header')).getAttribute(
'tabindex',
),
).toEqual('0');

expect(
element(by.css('nb-accordion > nb-accordion-item:nth-child(2) > nb-accordion-item-header')).getAttribute(
'tabindex',
),
).toEqual('0');

expect(
element(by.css('nb-accordion > nb-accordion-item:nth-child(4) > nb-accordion-item-header')).getAttribute(
'tabindex',
),
).toEqual('-1');
});

it('should display a disabled accordion item', () => {
expect(
element(by.css('nb-accordion > nb-accordion-item:nth-child(4) > nb-accordion-item-header')).getAttribute(
'aria-disabled',
),
).toEqual('true');

expect(
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(4)')), 'disabled'),
).toBeTruthy();
});

it('should display a disabled accordion with collapsed state after click', () => {
element(by.css('nb-accordion > nb-accordion-item:nth-child(4)')).click();

expect(
hasClass(element(by.css('nb-accordion > nb-accordion-item:nth-child(4)')), 'collapsed'),
).toBeTruthy();
});
});
6 changes: 0 additions & 6 deletions e2e/actions.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ describe('nb-action', () => {
selector: (i) => `nb-card:nth-child(4) nb-actions nb-action:nth-child(${i + 1}) nb-badge > span`,
badges: [
{ position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText },
{ position: NbBadgeComponent.TOP_LEFT, status: NbBadgeComponent.STATUS_DANGER, text: badgeText },
{ position: NbBadgeComponent.BOTTOM_RIGHT, status: NbBadgeComponent.STATUS_WARNING, text: badgeText },
{ position: NbBadgeComponent.BOTTOM_LEFT, status: NbBadgeComponent.STATUS_SUCCESS, text: badgeText },
{ position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_INFO, text: badgeText },
{ position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_INFO, text: badgeText },
{ position: NbBadgeComponent.TOP_RIGHT, status: NbBadgeComponent.STATUS_PRIMARY, text: badgeText },
],
};
badgeTests(badgesConf);
Expand Down
19 changes: 0 additions & 19 deletions e2e/alert.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,4 @@ describe('nb-alert', () => {
});
});
});

const accentAlerts = prepareAccentAlerts(alerts.length);
accentAlerts.forEach(c => {
it(`should display ${c.colorKey} alert with ${c.accentKey} accent`, () => {
element.all(by.css(`nb-alert`))
.get(c.elementNumber)
.getCssValue('border-top-color').then(borderColor => {
expect(borderColor).toEqual(c.accentColor, 'Accent is not correct');
});
});
});

it('should react on close click', () => {
const all: any = element.all(by.css('nb-alert'));
all.count().then(allCount => {
element(by.css('nb-alert:nth-child(1) > .close')).click();
expect(all.count()).toEqual(allCount - 1);
});
});
});
16 changes: 0 additions & 16 deletions e2e/badge.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,4 @@ export default function badgeTests (badgesConfig) {
expect(badgeEl.getText()).toEqual(badges[i].text);
}
});

it('should display badge with correct status', () => {
for (let i = 0; i < badges.length; i++) {
waitFor(selector(i));
const badgeEl = element(by.css(selector(i)));
expect(badgeEl.getAttribute('class')).toContain(badges[i].status);
}
});

it('should display badge in correct position', () => {
for (let i = 0; i < badges.length; i++) {
waitFor(selector(i));
const badgeEl = element(by.css(selector(i)));
expect(badgeEl.getAttribute('class')).toContain(badges[i].position);
}
});
}
50 changes: 0 additions & 50 deletions e2e/card.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,6 @@ function prepareCards() {
return result;
}

function prepareAccentCards(regularCardsOffset) {
function generateAccentCards(accentCardsOffset, colorKey, color) {
return colors.map((c, i) => ({
name: colorKey,
colorKey,
color,
accentColor: c.color,
accentKey: c.colorKey,
elementNumber: regularCardsOffset + accentCardsOffset + i,
}));
}

return colors.reduce((accentCards, { colorKey, color }) => {
return accentCards.concat(generateAccentCards(accentCards.length, colorKey, color));
}, []);
}

describe('nb-card', () => {

cards = prepareCards();
Expand All @@ -61,39 +44,6 @@ describe('nb-card', () => {
waitFor(`nb-card:nth-child(${c.elementNumber})`);
expect(element(by.css(`nb-card:nth-child(${c.elementNumber}) > nb-card-header`))
.getText()).toEqual('Header');

if (c.size !== 'xxsmall') {
expect(element(by.css(`nb-card:nth-child(${c.elementNumber}) > nb-card-body`))
.getText()).toEqual('Body');

expect(element(by.css(`nb-card:nth-child(${c.elementNumber}) > nb-card-footer`))
.getText()).toEqual('Footer');
}

element(by.css(`nb-card:nth-child(${c.elementNumber})`)).getCssValue('height').then(height => {
expect(height).toEqual(c.height);
});

element(by.css(`nb-card:nth-child(${c.elementNumber}) > nb-card-header`))
.getCssValue('background-color').then(bgColor => {
expect(bgColor).toEqual(c.color);
});

element(by.css(`nb-card:nth-child(${c.elementNumber}) > nb-card-header`))
.getCssValue('border-bottom-color').then(bgColor => {
expect(bgColor).toEqual(c.color);
});
});
});

const accentCards = prepareAccentCards(cards.length);
accentCards.forEach(c => {
it(`should display ${c.colorKey} card with ${c.accentKey} accent`, () => {
element.all(by.css(`nb-card`))
.get(c.elementNumber)
.getCssValue('border-top-color').then(borderColor => {
expect(borderColor).toEqual(c.accentColor, 'Accent is not correct');
});
});
});
});
21 changes: 0 additions & 21 deletions e2e/chat.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,4 @@ describe('nb-chat', () => {
});
});
});

it('should add on message', () => {
const all: any = element.all(by.css('nb-chat:nth-child(1) nb-chat-message'));
all.count().then(allCount => {
element(by.css('nb-chat:nth-child(1) nb-chat-form input')).sendKeys('akveo');
element(by.css('nb-chat:nth-child(1) nb-chat-form .btn')).click();
expect(all.count()).toEqual(allCount + 1);
});
});

it('should not add on an empty message', () => {
const all: any = element.all(by.css('nb-chat:nth-child(1) nb-chat-message'));
all.count().then(allCount => {
element(by.css('nb-chat:nth-child(1) nb-chat-form .btn')).click();
expect(all.count()).toEqual(allCount);

element(by.css('nb-chat:nth-child(1) nb-chat-form input')).sendKeys(' ');
element(by.css('nb-chat:nth-child(1) nb-chat-form .btn')).click();
expect(all.count()).toEqual(allCount);
});
});
});
130 changes: 0 additions & 130 deletions e2e/checkbox.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,7 @@

import { browser, by, element } from 'protractor';

function getComputedProperty(property: string, selector: string) {
const script = `
return window.getComputedStyle(
document.querySelector('${selector}'),
':before'
).${property};
`;

return browser.executeScript(script);
}

describe('nb-checkbox', () => {
const transparent = 'rgba(0, 0, 0, 0)';

const border_color = 'rgb(218, 223, 230)';
const checked_color = 'rgb(64, 220, 126)';
const outline_color = 'rgb(107, 228, 155)';

const warning_color = 'rgb(255, 161, 0)';
const warning_hover = 'rgb(255, 180, 51)';

const danger_color = 'rgb(255, 76, 106)';
const danger_hover = 'rgb(255, 127, 148)';


beforeEach((done) => {
browser.get('#/checkbox/checkbox-test.component').then(() => done());
Expand All @@ -45,111 +22,4 @@ describe('nb-checkbox', () => {
indicator.click();
expect(input.getAttribute('checked')).toBeFalsy();
});

it('should ignore click if disable', () => {
const input = element(by.css('#disabled input'));
const indicator = element(by.css('#disabled .customised-control-indicator'));

expect(input.getAttribute('disabled')).toBeTruthy();
expect(input.getAttribute('checked')).toBeFalsy();
indicator.click();
expect(input.getAttribute('checked')).toBeFalsy();
expect(input.getAttribute('disabled')).toBeTruthy();
});

it('should apply style if checked/unchecked', () => {
const input = element(by.css('#first input'));
const indicator = element(by.css('#first .customised-control-indicator'));
const otherElement = element(by.css('#danger .customised-control-indicator'));

// unchecked
expect(input.getAttribute('checked')).toBeFalsy();
expect(indicator.getCssValue('background-color')).toEqual(transparent);
expect(indicator.getCssValue('border')).toEqual('2px solid ' + border_color);

// check ::before styles
getComputedProperty('content', '#first .customised-control-indicator')
.then(data => expect(data).toBe('""'));

getComputedProperty('borderTopColor', '#first .customised-control-indicator')
.then(data => expect(data).toBe(transparent));

indicator.click();
// change focus to another input, so .focus styles removed.
otherElement.click();

// checked
expect(input.getAttribute('checked')).toBeTruthy();
expect(indicator.getCssValue('background-color')).toEqual(transparent);
expect(indicator.getCssValue('border')).toEqual('2px solid ' + checked_color);

// check ::before styles
getComputedProperty('content', '#first .customised-control-indicator')
.then(data => expect(data).toBe('""'));

getComputedProperty('borderTopColor', '#first .customised-control-indicator')
.then(data => expect(data).toBe('rgb(42, 42, 42)'));
});

it('should apply style if hover', () => {
const indicator = element(by.css('#first .customised-control-indicator'));

// without hover
expect(indicator.getCssValue('border')).toEqual('2px solid ' + border_color);

browser.actions().mouseMove(indicator).perform();

// hover
expect(indicator.getCssValue('border')).toEqual('2px solid ' + outline_color);
});

it('should apply status style', () => {
const success = element(by.css('#success .customised-control-indicator'));
const other = element(by.css('#first .customised-control-indicator'));

// without hover
expect(success.getCssValue('border-color')).toEqual(border_color);

// checked & focus
success.click();
expect(success.getCssValue('border-color')).toEqual(outline_color);

// checked w/o focus
other.click();
expect(success.getCssValue('border-color')).toEqual(checked_color);

});

it('should apply style if status warning', () => {
const warning = element(by.css('#warning .customised-control-indicator'));
const other = element(by.css('#first .customised-control-indicator'));

// without hover
expect(warning.getCssValue('border-color')).toEqual(border_color);

// checked & focus
warning.click();
expect(warning.getCssValue('border-color')).toEqual(warning_hover);

// checked w/o focus
other.click();
expect(warning.getCssValue('border-color')).toEqual(warning_color);
});

it('should apply style if status danger', () => {
const danger = element(by.css('#danger .customised-control-indicator'));
const other = element(by.css('#first .customised-control-indicator'));

// without hover
expect(danger.getCssValue('border-color')).toEqual(border_color);

// checked & focus
danger.click();
expect(danger.getCssValue('border-color')).toEqual(danger_hover);

// checked w/o focus
other.click();
expect(danger.getCssValue('border-color')).toEqual(danger_color);

});
});
18 changes: 0 additions & 18 deletions e2e/component-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,14 @@ import { hexToRgbA } from './e2e-helper';

export const cardSizes = [
{ sizeKey: 'xxsmall', height: '96px' },
{ sizeKey: 'xsmall', height: '216px' },
{ sizeKey: 'small', height: '336px' },
{ sizeKey: 'medium', height: '456px' },
{ sizeKey: 'large', height: '576px' },
{ sizeKey: 'xlarge', height: '696px' },
{ sizeKey: 'xxlarge', height: '816px' },
];

export const alertSizes = [
{ sizeKey: 'xxsmall', height: '52px' },
{ sizeKey: 'xsmall', height: '72px' },
{ sizeKey: 'small', height: '92px' },
{ sizeKey: 'medium', height: '112px' },
{ sizeKey: 'large', height: '132px' },
{ sizeKey: 'xlarge', height: '152px' },
{ sizeKey: 'xxlarge', height: '172px' },
];

export const colors = [
{ colorKey: 'primary', color: hexToRgbA('#8a7fff') },
{ colorKey: 'success', color: hexToRgbA('#40dc7e') },
{ colorKey: 'info', color: hexToRgbA('#4ca6ff') },
{ colorKey: 'warning', color: hexToRgbA('#ffa100') },
{ colorKey: 'danger', color: hexToRgbA('#ff4c6a') },
{ colorKey: 'default', color: hexToRgbA('#a4abb3') },
{ colorKey: 'disabled', color: 'rgba(255, 255, 255, 0.4)' },
];

export const chatSizes = cardSizes;
Loading

0 comments on commit 1aa0786

Please sign in to comment.