-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(Button): Implementa i test e2e per i bottoni
ref #44
- Loading branch information
Mario Traetta
committed
Jul 30, 2018
1 parent
8d00e44
commit 5201bf8
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { browser } from 'protractor'; | ||
import { ButtonPage } from './button.po'; | ||
|
||
const BUTTON_TEXT = 'Numero click eseguiti: '; | ||
describe('Button', () => { | ||
let page: ButtonPage; | ||
|
||
beforeEach(async() => { | ||
page = new ButtonPage(); | ||
await page.go(); | ||
}); | ||
|
||
it('dovrebbe poter essere cliccato', async () => { | ||
let actualValue = await page.getButtonText(); | ||
expect(actualValue).toBe(BUTTON_TEXT + 0); | ||
|
||
await page.clickButton(); | ||
|
||
actualValue = await page.getButtonText(); | ||
expect(actualValue).toBe(BUTTON_TEXT + 1); | ||
}); | ||
|
||
it('dovrebbe poter essere disabilitato', async () => { | ||
let actualValue = await page.getButtonText(); | ||
let buttonClasses = await page.getButtonClasses(); | ||
let isDisabled = buttonClasses.indexOf('disabled') > -1; | ||
expect(actualValue).toBe(BUTTON_TEXT + 0); | ||
expect(isDisabled).toBeFalsy(); | ||
|
||
await page.clickDisabledCheckbox(); | ||
await page.clickButton(); | ||
|
||
actualValue = await page.getButtonText(); | ||
buttonClasses = await page.getButtonClasses(); | ||
isDisabled = buttonClasses.indexOf('disabled') > -1; | ||
expect(actualValue).toBe(BUTTON_TEXT + 0); | ||
expect(isDisabled).toBeTruthy(); | ||
}); | ||
|
||
it('dovrebbe poter essere un elemento a blocco', async () => { | ||
let actualValue = await page.getButtonText(); | ||
let buttonClasses = await page.getButtonClasses(); | ||
let isDisabled = buttonClasses.indexOf('btn-block') > -1; | ||
expect(actualValue).toBe(BUTTON_TEXT + 0); | ||
expect(isDisabled).toBeFalsy(); | ||
|
||
await page.clickBlockCheckbox(); | ||
await page.clickButton(); | ||
|
||
actualValue = await page.getButtonText(); | ||
buttonClasses = await page.getButtonClasses(); | ||
isDisabled = buttonClasses.indexOf('btn-block') > -1; | ||
expect(actualValue).toBe(BUTTON_TEXT + 1); | ||
expect(isDisabled).toBeTruthy(); | ||
}); | ||
|
||
/* it('dovrebbe poter aver un colore diverso e poi avere un colore a contorno', async () => { | ||
}); */ | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { browser, by, element, ExpectedConditions } from 'protractor'; | ||
|
||
export class ButtonPage { | ||
private readonly BUTTON_URL = '/#/componenti/button'; | ||
private readonly ID_EXAMPLE_TAB = 'button-examples-tab'; | ||
|
||
private readonly ID_BUTTON = 'button-21'; | ||
private readonly ID_CHECKBOX_DISABLE = 'disabled-checkbox'; | ||
private readonly ID_CHECKBOX_BLOCK = 'block-checkbox'; | ||
|
||
async go() { | ||
await browser.get(this.BUTTON_URL); | ||
await element(by.id(this.ID_EXAMPLE_TAB)).click(); | ||
return await browser.sleep(500); | ||
} | ||
|
||
async clickButton() { | ||
await element(by.id(this.ID_BUTTON)).click(); | ||
} | ||
|
||
async clickElement(id: string) { | ||
await element(by.id(id)).click(); | ||
} | ||
|
||
async clickDisabledCheckbox() { | ||
await this.clickElement(this.ID_CHECKBOX_DISABLE); | ||
} | ||
|
||
async clickBlockCheckbox() { | ||
await this.clickElement(this.ID_CHECKBOX_BLOCK); | ||
} | ||
|
||
async getButtonText() { | ||
return await element(by.id(this.ID_BUTTON)).getText(); | ||
} | ||
|
||
async getButtonClasses() { | ||
const classAttribute = await element(by.id(this.ID_BUTTON)).getAttribute('class'); | ||
return classAttribute.split(' '); | ||
} | ||
} |