mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: remove screenshot testing (#12155)
Removes the screenshot test tool since Angular Material is visually being tested inside of Google.
This commit is contained in:
committed by
Jeremy Elbourn
parent
dc0732bc2c
commit
afb0ee37eb
@@ -1,5 +1,4 @@
|
||||
import {browser, Key, element, by} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
import {getScrollPosition} from '../util/index';
|
||||
|
||||
|
||||
@@ -18,8 +17,6 @@ describe('scroll blocking', () => {
|
||||
clickOn('disable');
|
||||
scrollPage(0, 300);
|
||||
expect((await getScrollPosition()).y).toBe(300, 'Exected page to be scrollable again.');
|
||||
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should not be able to scroll programmatically along the y axis', async () => {
|
||||
@@ -33,8 +30,6 @@ describe('scroll blocking', () => {
|
||||
clickOn('disable');
|
||||
scrollPage(300, 0);
|
||||
expect((await getScrollPosition()).x).toBe(300, 'Exected page to be scrollable again.');
|
||||
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should not be able to scroll via the keyboard along the y axis', async () => {
|
||||
@@ -55,8 +50,6 @@ describe('scroll blocking', () => {
|
||||
await body.sendKeys(Key.ARROW_DOWN);
|
||||
expect((await getScrollPosition()).y)
|
||||
.toBeGreaterThan(100, 'Expected the page to be scrollable again.');
|
||||
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should not be able to scroll via the keyboard along the x axis', async () => {
|
||||
@@ -77,8 +70,6 @@ describe('scroll blocking', () => {
|
||||
await body.sendKeys(Key.ARROW_RIGHT);
|
||||
expect((await getScrollPosition()).x)
|
||||
.toBeGreaterThan(100, 'Expected the page to be scrollable again.');
|
||||
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should not be able to scroll the page after reaching the end of an element along the y axis',
|
||||
@@ -94,8 +85,6 @@ describe('scroll blocking', () => {
|
||||
scroller.sendKeys(Key.ARROW_DOWN);
|
||||
scroller.sendKeys(Key.ARROW_DOWN);
|
||||
expect((await getScrollPosition()).y).toBe(100, 'Expected the page not to have scrolled.');
|
||||
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should not be able to scroll the page after reaching the end of an element along the x axis',
|
||||
@@ -111,8 +100,6 @@ describe('scroll blocking', () => {
|
||||
scroller.sendKeys(Key.ARROW_RIGHT);
|
||||
scroller.sendKeys(Key.ARROW_RIGHT);
|
||||
expect((await getScrollPosition()).x).toBe(100, 'Expected the page not to have scrolled.');
|
||||
|
||||
screenshot();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {browser, by, element, ExpectedConditions} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
describe('button', () => {
|
||||
describe('disabling behavior', () => {
|
||||
@@ -12,7 +10,6 @@ describe('button', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('clicked once');
|
||||
|
||||
element(by.id('disable-toggle')).click();
|
||||
element(by.id('test-button')).click();
|
||||
@@ -20,7 +17,6 @@ describe('button', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('click disabled');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {browser, by, element} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('button-toggle', () => {
|
||||
|
||||
@@ -7,7 +6,6 @@ describe('button-toggle', () => {
|
||||
|
||||
it('should show a button-toggle', async () => {
|
||||
expect(element(by.tagName('mat-button-toggle'))).toBeDefined();
|
||||
screenshot();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {browser, by, element} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('mat-card', () => {
|
||||
|
||||
@@ -8,8 +7,6 @@ describe('mat-card', () => {
|
||||
it('should show a card', async () => {
|
||||
const card = element(by.tagName('mat-card'));
|
||||
expect(card).toBeDefined();
|
||||
|
||||
screenshot('fancy card example');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {browser, by, element, Key, ExpectedConditions} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
describe('checkbox', () => {
|
||||
|
||||
@@ -11,7 +9,6 @@ describe('checkbox', () => {
|
||||
let checkboxEl = element(by.id('test-checkbox'));
|
||||
let inputEl = element(by.css('input[id=test-checkbox-input]'));
|
||||
|
||||
screenshot('start');
|
||||
checkboxEl.click();
|
||||
|
||||
expect(inputEl.getAttribute('checked'))
|
||||
@@ -19,7 +16,6 @@ describe('checkbox', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('checked');
|
||||
|
||||
checkboxEl.click();
|
||||
|
||||
@@ -28,7 +24,6 @@ describe('checkbox', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('unchecked');
|
||||
});
|
||||
|
||||
it('should toggle the checkbox when pressing space', () => {
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
clickElementAtPoint,
|
||||
waitForElement,
|
||||
} from '../util/index';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
describe('dialog', () => {
|
||||
beforeEach(() => browser.get('/dialog'));
|
||||
@@ -15,7 +13,6 @@ describe('dialog', () => {
|
||||
it('should open a dialog', () => {
|
||||
element(by.id('default')).click();
|
||||
expectToExist('mat-dialog-container');
|
||||
screenshot('simple dialog opened');
|
||||
});
|
||||
|
||||
it('should open a template dialog', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {browser, by, element} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('expansion', () => {
|
||||
|
||||
@@ -7,12 +6,10 @@ describe('expansion', () => {
|
||||
|
||||
it('should show an accordion', async () => {
|
||||
expect(element(by.css('.mat-accordion'))).toBeDefined();
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should show two panels', async () => {
|
||||
expect(await element.all(by.css('.mat-expansion-panel')).count()).toBe(2);
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should hide contents of the expansion panel on click', async () => {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import {browser} from 'protractor';
|
||||
import {expectToExist} from '../util/index';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('grid-list', () => {
|
||||
beforeEach(() => browser.get('/grid-list'));
|
||||
|
||||
it('should render a grid list container', () => {
|
||||
expectToExist('mat-grid-list');
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should render list items inside the grid list container', () => {
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
import {browser, by, element} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
function blurAndScreenshot(msg: string) {
|
||||
browser.executeScript(`document.activeElement && document.activeElement.blur();`);
|
||||
screenshot(msg);
|
||||
}
|
||||
|
||||
|
||||
describe('input', () => {
|
||||
describe('text input', () => {
|
||||
@@ -67,7 +59,6 @@ describe('input', () => {
|
||||
it('should resize correctly', () => {
|
||||
let input = element(by.id('autosize-text-area'));
|
||||
input.sendKeys('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
||||
blurAndScreenshot('autosize multiple rows');
|
||||
});
|
||||
|
||||
it('should enfore max rows', () => {
|
||||
@@ -77,7 +68,6 @@ describe('input', () => {
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
|
||||
blurAndScreenshot('autosize more than max rows');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import {browser} from 'protractor';
|
||||
import {expectToExist} from '../util/index';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('list', () => {
|
||||
beforeEach(() => browser.get('/list'));
|
||||
|
||||
it('should render a list container', () => {
|
||||
expectToExist('mat-list');
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should render list items inside the list container', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {Key, protractor, browser, by, element, ExpectedConditions} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
import {
|
||||
expectToExist,
|
||||
expectAlignedWith,
|
||||
@@ -24,33 +23,28 @@ describe('menu', () => {
|
||||
|
||||
expectToExist(menuSelector);
|
||||
expect(await page.menu().getText()).toEqual('One\nTwo\nThree\nFour');
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should close menu when menu item is clicked', () => {
|
||||
page.trigger().click();
|
||||
page.items(0).click();
|
||||
expectToExist(menuSelector, false);
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should run click handlers on regular menu items', async () => {
|
||||
page.trigger().click();
|
||||
page.items(0).click();
|
||||
expect(await page.getResultText()).toEqual('one');
|
||||
screenshot('one');
|
||||
|
||||
page.trigger().click();
|
||||
page.items(1).click();
|
||||
expect(await page.getResultText()).toEqual('two');
|
||||
screenshot('two');
|
||||
});
|
||||
|
||||
it('should run not run click handlers on disabled menu items', async () => {
|
||||
page.trigger().click();
|
||||
page.items(2).click();
|
||||
expect(await page.getResultText()).toEqual('');
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should support multiple triggers opening the same menu', async () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {browser, by, element, ExpectedConditions} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
describe('radio', () => {
|
||||
@@ -12,7 +11,6 @@ describe('radio', () => {
|
||||
expect(element(by.id('water')).getAttribute('class')).toContain('mat-radio-checked');
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('water');
|
||||
|
||||
expect(element(by.css('input[id=water-input]')).getAttribute('checked')).toBeTruthy();
|
||||
expect(element(by.css('input[id=leaf-input]')).getAttribute('checked')).toBeFalsy();
|
||||
@@ -22,7 +20,6 @@ describe('radio', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('leaf');
|
||||
|
||||
expect(element(by.css('input[id=leaf-input]')).getAttribute('checked')).toBeTruthy();
|
||||
expect(element(by.css('input[id=water-input]')).getAttribute('checked')).toBeFalsy();
|
||||
@@ -35,7 +32,6 @@ describe('radio', () => {
|
||||
expect(element(by.id('water')).getAttribute('class')).toContain('mat-radio-disabled');
|
||||
|
||||
await browser.wait(ExpectedConditions.presenceOf(element(by.css('.mat-radio-disabled'))));
|
||||
screenshot('water');
|
||||
|
||||
expect(element(by.css('input[id=water-input]')).getAttribute('disabled')).toBeTruthy();
|
||||
|
||||
@@ -44,7 +40,6 @@ describe('radio', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('leaf');
|
||||
|
||||
expect(element(by.css('input[id=leaf-input]')).getAttribute('disabled')).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {browser, element, by, Key, ExpectedConditions} from 'protractor';
|
||||
import {expectToExist} from '../util/index';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
describe('slide-toggle', () => {
|
||||
@@ -11,7 +10,6 @@ describe('slide-toggle', () => {
|
||||
|
||||
it('should render a slide-toggle', () => {
|
||||
expectToExist('mat-slide-toggle');
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should change the checked state on click', async () => {
|
||||
@@ -25,7 +23,6 @@ describe('slide-toggle', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should change the checked state on click', async () => {
|
||||
@@ -38,7 +35,6 @@ describe('slide-toggle', () => {
|
||||
expect(inputEl.getAttribute('checked')).toBeTruthy('Expect slide-toggle to be checked');
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should not change the checked state on click when disabled', async () => {
|
||||
@@ -51,7 +47,6 @@ describe('slide-toggle', () => {
|
||||
expect(inputEl.getAttribute('checked')).toBeFalsy('Expect slide-toggle to be unchecked');
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should move the thumb on state change', async () => {
|
||||
@@ -67,7 +62,6 @@ describe('slide-toggle', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot();
|
||||
});
|
||||
|
||||
it('should toggle the slide-toggle on space key', () => {
|
||||
|
||||
@@ -4,14 +4,12 @@ import {
|
||||
import {expectFocusOn, expectToExist} from '../util/asserts';
|
||||
import {pressKeys} from '../util/actions';
|
||||
import {Key} from 'selenium-webdriver';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('stepper', () => {
|
||||
beforeEach(() => browser.get('/stepper'));
|
||||
|
||||
it('should render a stepper', () => {
|
||||
expectToExist('mat-horizontal-stepper');
|
||||
screenshot('mat-horizontal-stepper');
|
||||
});
|
||||
|
||||
describe('basic behavior', () => {
|
||||
@@ -22,7 +20,6 @@ describe('stepper', () => {
|
||||
expect(await element(by.css('mat-step-header[aria-selected="true"]')).getText())
|
||||
.toBe('1\nFill out your name');
|
||||
|
||||
screenshot('start');
|
||||
nextButton.get(0).click();
|
||||
|
||||
expect(await element(by.css('mat-step-header[aria-selected="true"]')).getText())
|
||||
@@ -30,7 +27,6 @@ describe('stepper', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('click next');
|
||||
|
||||
previousButton.get(0).click();
|
||||
|
||||
@@ -39,7 +35,6 @@ describe('stepper', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('click back');
|
||||
});
|
||||
|
||||
it('should change focus with keyboard interaction', () => {
|
||||
|
||||
@@ -8,8 +8,6 @@ import {
|
||||
ExpectedConditions
|
||||
} from 'protractor';
|
||||
import {pressKeys} from '../util/index';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
|
||||
describe('tabs', () => {
|
||||
describe('basic behavior', () => {
|
||||
@@ -31,7 +29,6 @@ describe('tabs', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('click1');
|
||||
|
||||
tabLabels.get(0).click();
|
||||
expect(await getLabelActiveStates(tabLabels)).toEqual([true, false, false]);
|
||||
@@ -39,7 +36,6 @@ describe('tabs', () => {
|
||||
|
||||
await browser.wait(ExpectedConditions.not(
|
||||
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
|
||||
screenshot('click0');
|
||||
});
|
||||
|
||||
it('should change focus with keyboard interaction', async () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {browser, by, element} from 'protractor';
|
||||
import {screenshot} from '../screenshot';
|
||||
|
||||
describe('mat-toolbar', () => {
|
||||
|
||||
@@ -7,8 +6,6 @@ describe('mat-toolbar', () => {
|
||||
|
||||
it('should show a toolbar', async () => {
|
||||
expect(element(by.tagName('mat-toolbar'))).toBeDefined();
|
||||
|
||||
screenshot('multiple toolbar components');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import {browser} from 'protractor';
|
||||
|
||||
const OUTPUT_DIR = './screenshots/';
|
||||
const HEIGHT = 768;
|
||||
const WIDTH = 1024;
|
||||
|
||||
let currentJasmineSpecName = '';
|
||||
|
||||
/** Adds a custom jasmine reporter that simply keeps track of the current test name. */
|
||||
function initializeEnvironment(jasmine: any) {
|
||||
browser.manage().window().setSize(WIDTH, HEIGHT);
|
||||
let reporter = new jasmine.JsApiReporter({});
|
||||
reporter.specStarted = function(result: any) {
|
||||
currentJasmineSpecName = result.fullName;
|
||||
};
|
||||
jasmine.getEnv().addReporter(reporter);
|
||||
}
|
||||
|
||||
initializeEnvironment(jasmine);
|
||||
|
||||
export class Screenshot {
|
||||
id: string;
|
||||
|
||||
/** The filename used to store the screenshot. */
|
||||
get filename(): string {
|
||||
return this.id
|
||||
.toLowerCase()
|
||||
.replace(/\s/g, '_')
|
||||
.replace(/[^/a-z0-9_]+/g, '')
|
||||
+ '.screenshot.png';
|
||||
}
|
||||
|
||||
/** The full path to the screenshot */
|
||||
get fullPath(): string {
|
||||
return path.resolve(OUTPUT_DIR, this.filename);
|
||||
}
|
||||
|
||||
constructor(id?: string) {
|
||||
this.id = id ? `${currentJasmineSpecName} ${id}` : currentJasmineSpecName;
|
||||
browser.takeScreenshot().then(png => this.storeScreenshot(png));
|
||||
}
|
||||
|
||||
/** Replaces the existing screenshot with the newly generated one. */
|
||||
storeScreenshot(png: any) {
|
||||
if (!fs.existsSync(OUTPUT_DIR)) {
|
||||
fs.mkdirSync(OUTPUT_DIR, '744');
|
||||
}
|
||||
|
||||
if (fs.existsSync(OUTPUT_DIR)) {
|
||||
fs.writeFileSync(this.fullPath, png, {encoding: 'base64' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function screenshot(id?: string) {
|
||||
if (process.env['TRAVIS']) {
|
||||
return new Screenshot(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user