Skip to content

Commit

Permalink
Add screenshot tests for reset session page (elastic#148443)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomheymann authored Jan 9, 2023
1 parent 2dfa17c commit 58ac314
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('security app - login selector', function () {
loadTestFile(require.resolve('./basic_functionality'));
loadTestFile(require.resolve('./auth_provider_hint'));
loadTestFile(require.resolve('./reset_session_page'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects, updateBaselines }: FtrProviderContext) {
const screenshots = getService('screenshots');
const browser = getService('browser');
const security = getService('security');
const PageObjects = getPageObjects(['security', 'common']);

describe('reset session page', function () {
const userWithoutPermissions = { username: 'user_without_permissions', password: 'changeme' };

before(async () => {
// We use a really small window to minimize differences across os's and browsers.
await browser.setScreenshotSize(1000, 500);

await security.user.create(userWithoutPermissions.username, {
password: userWithoutPermissions.password,
roles: [],
});
});

beforeEach(async () => {
// Logout needs to happen before anything else to avoid flaky behavior
await PageObjects.security.forceLogout();
});

after(async () => {
// Clean up after ourselves
await security.user.delete(userWithoutPermissions.username);
await PageObjects.security.forceLogout();
});

it('compare screenshot', async () => {
await PageObjects.security.loginSelector.login('basic', 'basic1', {
username: userWithoutPermissions.username,
password: userWithoutPermissions.password,
expectedLoginResult: 'error',
});

const percentDifference = await screenshots.compareAgainstBaseline(
'reset_session_page',
updateBaselines
);
expect(percentDifference).to.be.lessThan(0.022);
});
});
}

0 comments on commit 58ac314

Please sign in to comment.