Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg committed Dec 5, 2020
2 parents c8448d2 + 9ce66b6 commit 08ec42e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 24 deletions.
13 changes: 6 additions & 7 deletions common/project.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module.exports = global.Project = {
api: 'https://api-dev.bullet-train.io/api/v1/',
flagsmithClientAPI: 'https://api.bullet-train.io/api/v1/',
flagsmith: '8KzETdDeMY7xkqkSkY3Gsg', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
debug: false,
delighted: true, // determines whether to shw delighted feedback widget
env: 'dev', // This is used for Sentry tracking
ga: 'UA-120237963-3', // This is our Google Analytics key
api: 'https://api-staging.flagsmith.com/api/v1/',
flagsmithClientAPI: 'https://api.flagsmith.com/api/v1/',
flagsmith: 'ENktaJnfLVbLifybz34JmX', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
env: 'staging', // This is used for Sentry tracking
ga: 'UA-120237963-7', // This is our Google Analytics key
maintenance: false, // trigger maintenance mode
delighted: true, // determines whether to shw delighted feedback widget
demoAccount: {
email: '[email protected]',
password: 'demo_account',
Expand Down
5 changes: 3 additions & 2 deletions tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const testHelpers = {
.waitForElementVisible(byId(`feature-item-${index}`));
},
saveFeature(browser) {
browser.pause(500);
browser.pause(200);
browser.click('#update-feature-btn')
.waitForElementNotPresent('#create-feature-modal');
},
Expand All @@ -128,6 +128,7 @@ const testHelpers = {
gotoFeature(browser, index) {
browser.click(byId(`feature-item-${index}`))
.waitForElementPresent('#create-feature-modal');
browser.pause(200)
},
createTrait(browser, index, id, value) {
browser
Expand Down Expand Up @@ -163,7 +164,7 @@ const testHelpers = {
},
setSegmentOverrideIndex: (browser, index, newIndex) => {
browser.setValue(byId(`sort-${index}`), `${newIndex}`);
browser.pause(100);
browser.pause(500);
},
createSegment: (browser, index, id, rules) => {
const setSegmentRule = testHelpers.setSegmentRule;
Expand Down
12 changes: 5 additions & 7 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path');

const SLACK_TOKEN = process.env.SLACK_TOKEN;
const slackUpload = SLACK_TOKEN && require('./slack-upload.test');
const slackMessage = SLACK_TOKEN && require('../server/slack-client');
const slackMessage = false && require('../server/slack-client'); // to enable e2e slack messages change to SLACK_TOKEN && require
const fork = require('child_process').fork;

process.env.PORT = 8081;
Expand All @@ -27,7 +27,7 @@ const formatCommit = function () {
};

const sendSuccess = function () {
if (SLACK_TOKEN) {
if (slackMessage) {
console.log('SENDING SLACK MESSAGE');
return slackMessage(`Tests Passed!${formatCommit()}`, E2E_SLACK_CHANNEL_NAME);
}
Expand Down Expand Up @@ -73,7 +73,7 @@ const sendFailure = (browser, done, request, error) => {
const lastError = error && error.value ? JSON.parse(error.value) : 'No last error';
console.log('Last request:', lastRequest);
console.log('Last error:', lastError);
if (SLACK_TOKEN && E2E_SLACK_CHANNEL) {
if (SLACK_TOKEN && E2E_SLACK_CHANNEL && slackMessage) {
const uri = path.join(__dirname, 'screenshot.png');
browser.saveScreenshot(uri, () => {
slackUpload(uri, `E2E for Bullet Train Failed. ${formatCommit()}\n\`\`\`${JSON.stringify({
Expand All @@ -90,8 +90,7 @@ const sendFailure = (browser, done, request, error) => {
let testsFailed;

const exitTests = (browser, done) => {
if (process.env.BRK)
return
if (process.env.BRK) return;
browser.end();
done();
server.kill('SIGINT');
Expand All @@ -107,7 +106,7 @@ process.on('SIGINT', () => {
module.exports = Object.assign(
{
before: (browser, done) => {
if (SLACK_TOKEN) {
if (slackMessage) {
slackMessage(`Running tests.${formatCommit()}`, E2E_SLACK_CHANNEL_NAME);
}
server = fork('./server');
Expand Down Expand Up @@ -163,4 +162,3 @@ module.exports = Object.assign(
require('./register-fail.test'), // Registration failure tests
require('./login-fail.test'), // Login failure tests
);

9 changes: 7 additions & 2 deletions tests/segement-priorities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
browser.expect.element(byId('user-feature-value-1')).text.to.equal('1');
},
'[Segments Priority Tests] - Prioritise segment 2': function (browser) {
testHelpers.gotoFeatures(browser, 0);
testHelpers.gotoFeatures(browser);
testHelpers.gotoFeature(browser, 0);
testHelpers.setSegmentOverrideIndex(browser, 1, 0);
testHelpers.saveFeature(browser);
Expand All @@ -73,7 +73,7 @@ module.exports = {
browser.waitForElementVisible(byId('user-feature-switch-0-off'));
},
'[Segments Priority Tests] - Prioritise segment 3': function (browser) {
testHelpers.gotoFeatures(browser, 0);
testHelpers.gotoFeatures(browser);
testHelpers.gotoFeature(browser, 0);
testHelpers.setSegmentOverrideIndex(browser, 2, 0);
testHelpers.saveFeature(browser);
Expand All @@ -84,4 +84,9 @@ module.exports = {
browser.expect.element(byId('user-feature-value-1')).text.to.equal('3');
browser.waitForElementVisible(byId('user-feature-switch-0-on'));
},
'[Segments Priority Tests] - Clear down features': function (browser) {
testHelpers.gotoFeatures(browser);
testHelpers.deleteFeature(browser, 1, 'flag');
testHelpers.deleteFeature(browser, 0, 'config');
},
};
17 changes: 12 additions & 5 deletions tests/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ const expect = require('chai').expect;
const { byTestID: byId, setSegmentRule } = require('./helpers');

module.exports = {
'[Users Tests] - Create features': function (browser) {
testHelpers.gotoFeatures(browser);
testHelpers.createFeature(browser, 0, 'flag', true);
testHelpers.createRemoteConfig(browser, 0, 'config', 0);
},
'[Users Tests] - Toggle flag for user': function (browser) {
testHelpers.goToUser(browser, 0);

browser
.pause(200) // Additional wait here as it seems rc-switch can be unresponsive for a while
.click(byId('user-feature-switch-0-on'))
.waitAndClick(byId('user-feature-switch-0-on'))
.waitAndClick('#confirm-toggle-feature-btn')
.waitForElementNotPresent('#confirm-toggle-feature-modal')
.waitForElementVisible(byId('user-feature-switch-0-on'));
.waitForElementVisible(byId('user-feature-switch-0-off'));
},
'[Users Tests] - Edit flag for user': function (browser) {
browser
.pause(200)
.waitAndClick(byId('user-feature-1'))
.waitForElementPresent('#create-feature-modal')
.waitForElementVisible('[name="featureValue"]')
Expand All @@ -26,9 +33,9 @@ module.exports = {
'[Users Tests] - Toggle flag for user again': function (browser) {
browser
.pause(200) // Additional wait here as it seems rc-switch can be unresponsive for a while
.click(byId('user-feature-switch-0-on'))
.click(byId('user-feature-switch-0-off'))
.waitAndClick('#confirm-toggle-feature-btn')
.waitForElementNotPresent('#confirm-toggle-feature-modal')
.waitForElementVisible(byId('user-feature-switch-0-off'));
.waitForElementVisible(byId('user-feature-switch-0-on'));
},
};
17 changes: 17 additions & 0 deletions web/components/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ export default class Switch extends PureComponent {

render() {
// const { props } = this;

if (E2E) {
return (
<div style={{ height: '28px', display: 'inline-block' }}>
<button
role="switch"
type="button"
style={{ color: 'black', position: 'relative', pointerEvents: 'all' }}
className={this.props.checked ? 'switch-checked' : 'switch-unchecked'} {...this.props} onClick={() => {
this.props.onChange(!this.props.checked);
}}
>
{this.props.checked ? 'On' : 'Off'}
</button>
</div>
);
}
return (
<div style={{ height: '28px', display: 'inline-block', position: 'relative' }}>
<RCSwitch {...this.props}/>
Expand Down
2 changes: 1 addition & 1 deletion web/project/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Modal = class extends React.Component {
return (
<Provider ref="modal">
<div
tabIndex="-1" className={`modal ${this.props.className ? this.props.className : E2E ? '' : 'alert fade expand'}`} role="dialog"
tabIndex="-1" className={`modal ${E2E ? 'transition-none ' : ''}${this.props.className ? this.props.className : 'alert fade expand'}`} role="dialog"
aria-hidden="true"
>
<div className={`modal-dialog ${this.props.large ? 'modal-lg' : ''}`}>
Expand Down
7 changes: 7 additions & 0 deletions web/styles/project/_utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@
.align-start {
align-items: flex-start;
}

.transition-none {
transition: none !important;
.modal-content {
transition: none !important;
}
}

0 comments on commit 08ec42e

Please sign in to comment.