Merge branch 'main' into fix-storybook-components-unmet-dep
This commit is contained in:
4 files changed
+80
-73
No files matched your search
@@ -1,7 +1,19 @@
|
||||
import { makeEvaluator } from 'js-bexpr';
|
||||
import SessionSerializer from '../serializers/session';
|
||||
import { underscore } from '@ember/string';
|
||||
|
||||
const serializer = new SessionSerializer();
|
||||
/**
|
||||
* Because Mirage, a record cannot be serialized outside of a route handler
|
||||
* context. Here is a quick and dirty attempt to serialize attribute names
|
||||
* to underscore format. This is not entirely realistic, but may suffice.
|
||||
*/
|
||||
const quickSerialize = (item) => {
|
||||
const json = item.toJSON();
|
||||
Object.keys(json).forEach((key) => {
|
||||
const newKey = underscore(key);
|
||||
json[newKey] = json[key];
|
||||
});
|
||||
return json;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a filter function that operates on a single object, which itself
|
||||
@@ -11,9 +23,9 @@ export default (expression) => {
|
||||
if (expression) {
|
||||
const evaluator = makeEvaluator(expression);
|
||||
// Since API query selectors begin with `/item`, the instance is wrapped.
|
||||
return (item) => {
|
||||
const json = serializer.serialize(item);
|
||||
return evaluator({ item: json });
|
||||
return (record) => {
|
||||
const item = quickSerialize(record);
|
||||
return evaluator({ item });
|
||||
};
|
||||
} else {
|
||||
// If no expression was passed, always return true,
|
||||
|
||||
@@ -4,12 +4,19 @@ const { _electron: electron } = require('playwright');
|
||||
const helpers = require('./test-helpers');
|
||||
|
||||
let electronApp = null;
|
||||
// Subdirectory within tests/end2end/screenshots where the screenshots of this test suite will be stored.
|
||||
const screenshotsDirectory = 'authentication/';
|
||||
// Path where the Boundary Desktop client binary is generated
|
||||
const executablePath = helpers.returnExecutablePath(
|
||||
process.platform,
|
||||
process.arch
|
||||
);
|
||||
|
||||
// Set login variables
|
||||
const originValue = 'http://localhost:9200';
|
||||
const loginUsername = 'admin';
|
||||
const loginPassword = 'password';
|
||||
|
||||
test.beforeEach(async () => {
|
||||
electronApp = await electron.launch({
|
||||
executablePath: executablePath,
|
||||
@@ -34,29 +41,15 @@ test.describe('Authentication end to end test suite', async () => {
|
||||
await boundaryWindow.evaluate(() =>
|
||||
window.localStorage.setItem('desktop:origin', null)
|
||||
);
|
||||
const originValue = 'http://localhost:9200';
|
||||
const authLoginNameValue = 'admin';
|
||||
const authLoginPasswordValue = 'password';
|
||||
|
||||
// Fill the origin input
|
||||
await boundaryWindow.waitForSelector('[name=host]');
|
||||
await boundaryWindow.fill('[name=host]', originValue);
|
||||
// Take screenshot
|
||||
await boundaryWindow.screenshot({
|
||||
path: helpers.generateScreenshotPath(
|
||||
screenshotsDirectory,
|
||||
'fillOrigin'
|
||||
),
|
||||
fullPage: true,
|
||||
});
|
||||
// Perform login
|
||||
await helpers.login(
|
||||
boundaryWindow,
|
||||
originValue,
|
||||
loginUsername,
|
||||
loginPassword
|
||||
);
|
||||
|
||||
// Click the submit button
|
||||
await boundaryWindow.waitForSelector('button[type="submit"]');
|
||||
await helpers.click(boundaryWindow, 'button[type="submit"]');
|
||||
|
||||
// Fill user & password
|
||||
await boundaryWindow.fill('[name="identification"]', authLoginNameValue);
|
||||
await boundaryWindow.fill('[name="password"]', authLoginPasswordValue);
|
||||
// Take screenshot
|
||||
await boundaryWindow.screenshot({
|
||||
path: helpers.generateScreenshotPath(
|
||||
@@ -126,32 +119,13 @@ test.describe('Authentication end to end test suite', async () => {
|
||||
await boundaryWindow.evaluate(() =>
|
||||
window.localStorage.setItem('desktop:origin', null)
|
||||
);
|
||||
const originValue = 'http://localhost:9200';
|
||||
const authLoginNameValue = 'admin';
|
||||
const authLoginPasswordValue = '123456';
|
||||
|
||||
// Fill the origin input
|
||||
await boundaryWindow.fill('[name=host]', originValue);
|
||||
// Take screenshot
|
||||
await boundaryWindow.screenshot({
|
||||
path: helpers.generateScreenshotPath(
|
||||
screenshotsDirectory,
|
||||
'fillOrigin'
|
||||
),
|
||||
fullPage: true,
|
||||
});
|
||||
|
||||
// Click the submit button
|
||||
await boundaryWindow.waitForSelector('button[type="submit"]');
|
||||
await helpers.click(boundaryWindow, 'button[type="submit"]');
|
||||
|
||||
// Fill user & password
|
||||
await boundaryWindow.fill('[name="identification"]', authLoginNameValue);
|
||||
await boundaryWindow.fill('[name="password"]', authLoginPasswordValue);
|
||||
|
||||
// Click submit
|
||||
await boundaryWindow.waitForSelector('button[type="submit"]');
|
||||
await helpers.click(boundaryWindow, 'button[type="submit"]');
|
||||
// Perform login
|
||||
await helpers.login(
|
||||
boundaryWindow,
|
||||
originValue,
|
||||
loginUsername,
|
||||
'123456789'
|
||||
);
|
||||
|
||||
// Wait for the notification
|
||||
await boundaryWindow.waitForSelector('.rose-notification-body');
|
||||
|
||||
@@ -4,12 +4,19 @@ const { _electron: electron } = require('playwright');
|
||||
const helpers = require('./test-helpers');
|
||||
|
||||
let electronApp = null;
|
||||
// Subdirectory within tests/end2end/screenshots where the screenshots of this test suite will be stored.
|
||||
const screenshotsDirectory = 'targets/';
|
||||
// Path where the Boundary Desktop client binary is generated
|
||||
const executablePath = helpers.returnExecutablePath(
|
||||
process.platform,
|
||||
process.arch
|
||||
);
|
||||
|
||||
// Set login variables
|
||||
const originValue = 'http://localhost:9200';
|
||||
const loginUsername = 'admin';
|
||||
const loginPassword = 'password';
|
||||
|
||||
test.beforeEach(async () => {
|
||||
electronApp = await electron.launch({
|
||||
executablePath: executablePath,
|
||||
@@ -28,30 +35,19 @@ test.afterEach(async () => {
|
||||
test.describe('Targets end to end test suite', async () => {
|
||||
test('Connects to a target', async () => {
|
||||
const boundaryWindow = await electronApp.firstWindow(); // The window that contains the app.
|
||||
|
||||
// Override local storage origin
|
||||
await boundaryWindow.evaluate(() =>
|
||||
window.localStorage.setItem('desktop:origin', null)
|
||||
);
|
||||
|
||||
const originValue = 'http://localhost:9200';
|
||||
const authLoginNameValue = 'admin';
|
||||
const authLoginPasswordValue = 'password';
|
||||
|
||||
// Fill the origin input
|
||||
await boundaryWindow.waitForSelector('[name=host]');
|
||||
await boundaryWindow.fill('[name=host]', originValue);
|
||||
|
||||
// Click the submit button
|
||||
await boundaryWindow.waitForSelector('button[type="submit"]');
|
||||
await helpers.click(boundaryWindow, 'button[type="submit"]');
|
||||
|
||||
// Fill user & password
|
||||
await boundaryWindow.fill('[name="identification"]', authLoginNameValue);
|
||||
await boundaryWindow.fill('[name="password"]', authLoginPasswordValue);
|
||||
|
||||
// Click submit
|
||||
await boundaryWindow.waitForSelector('button[type="submit"]');
|
||||
await helpers.click(boundaryWindow, 'button[type="submit"]');
|
||||
// Perform the login
|
||||
await helpers.login(
|
||||
boundaryWindow,
|
||||
originValue,
|
||||
loginUsername,
|
||||
loginPassword
|
||||
);
|
||||
|
||||
// Check we are in Targets
|
||||
await boundaryWindow.waitForURL('**/#/scopes/global/projects/targets');
|
||||
|
||||
@@ -46,9 +46,34 @@ exports.returnExecutablePath = (platform, arch) => {
|
||||
/**
|
||||
* Performs a click with a workarouind due to an error with plain playwright click.
|
||||
* More info about the issue here: https://github.com/microsoft/playwright/issues/1808
|
||||
* @param {*} appWindow The current electron window.
|
||||
* @param {*} selector The DOM element selector.
|
||||
* @param {object} appWindow The electron window to perform the action.
|
||||
* @param {string} selector The DOM element selector.
|
||||
*/
|
||||
exports.click = async (appWindow, selector) => {
|
||||
await appWindow.$eval(selector, (element) => element.click());
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs login on the app window provided with the credentials provided.
|
||||
* @param {object} appWindow The electron window to perform the action.
|
||||
* @param {string} origin URL origin to set.
|
||||
* @param {string} username Username to login.
|
||||
* @param {string} password Password to login.
|
||||
*/
|
||||
exports.login = async (appWindow, origin, username, password) => {
|
||||
// Fill the origin input
|
||||
await appWindow.waitForSelector('[name=host]');
|
||||
await appWindow.fill('[name=host]', origin);
|
||||
|
||||
// Click the set origin submit button
|
||||
await appWindow.waitForSelector('button[type="submit"]');
|
||||
await this.click(appWindow, 'button[type="submit"]');
|
||||
|
||||
// Fill user & password
|
||||
await appWindow.fill('[name="identification"]', username);
|
||||
await appWindow.fill('[name="password"]', password);
|
||||
|
||||
// Click submit
|
||||
await appWindow.waitForSelector('button[type="submit"]');
|
||||
await this.click(appWindow, 'button[type="submit"]');
|
||||
};
|
||||
Reference in new issue
Block a user