Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Fix e2e tests #2674

Merged
merged 34 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9857bae
Fix e2e tests
mxstbr Mar 30, 2018
cba3720
Replace all before(s with beforeEach(s
mxstbr Mar 30, 2018
9c32e42
Skip private invite link spec
mxstbr Mar 30, 2018
34a39ed
Disable toobusy handling while testing
mxstbr Mar 30, 2018
e4209dc
Actually dont run toobusy in tests
mxstbr Mar 30, 2018
9ad201a
Dont record video from cypress
mxstbr Mar 30, 2018
221f810
Merge branch 'alpha' into fix-tests
mxstbr Mar 30, 2018
639e5fe
Attempt to fix a few abstractions
brianlovin Mar 30, 2018
f97c407
Use nodemon to restart the API if it crashes
mxstbr Apr 3, 2018
c117f42
nodemon: command not found fixes
mxstbr Apr 3, 2018
891241c
Start nodemon from package.json instead
mxstbr Apr 3, 2018
296126e
Keep nodemon from restarting the API endlessly
mxstbr Apr 3, 2018
5e27c09
Merge branch 'alpha' into fix-tests
mxstbr Apr 3, 2018
b8b5507
Merge branch 'alpha' of https://github.com/withspectrum/spectrum into…
brianlovin Apr 3, 2018
2c740cf
Attempt to simplify a few tests
brianlovin Apr 3, 2018
3ff6381
Merge branch 'fix-tests' of https://github.com/withspectrum/spectrum …
brianlovin Apr 3, 2018
28237ee
Merge branch 'alpha' of github.com:withspectrum/spectrum into fix-tests
brianlovin Apr 5, 2018
c81c762
Split e2e tests from unit tests on CircleCI
mxstbr Apr 5, 2018
540e21c
Fix indentation
mxstbr Apr 5, 2018
6789328
Also run RDB for unit tests
mxstbr Apr 5, 2018
98334e4
Merge branch 'refactor-circleci' into fix-tests
mxstbr Apr 6, 2018
fa1c713
Further refactor circle config
mxstbr Apr 9, 2018
ad3540e
Move setup step
mxstbr Apr 9, 2018
586b041
Merge branch 'alpha' into fix-tests
mxstbr Apr 9, 2018
5d7adf9
Fixed logged-out view
mxstbr Apr 9, 2018
4e07bb0
Fix blocked users returning null
mxstbr Apr 9, 2018
349faf5
Fix a bunch of errors during e2e tests
mxstbr Apr 9, 2018
a2460d7
delete empty spec
mxstbr Apr 9, 2018
862f89b
Increase timeout
mxstbr Apr 9, 2018
f810914
Merge branch 'alpha' into fix-tests
mxstbr Apr 10, 2018
d6ba676
Fix some more bugs
mxstbr Apr 10, 2018
aa124cc
Further fixes
mxstbr Apr 10, 2018
4e81509
exit process on unhealthy db in test env
mxstbr Apr 10, 2018
d229431
Fix top communities pure
mxstbr Apr 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ aliases:
name: Setup and build
command:
|
node -e "const setup = require('./shared/testing/setup.js')().then(() => process.exit())"
yarn run build:web
yarn run build:api

- &start-api
name: Start the API in the background
command: TEST_DB=true yarn run dev:api
command: yarn run dev:api:test
background: true

- &start-web
Expand Down Expand Up @@ -83,6 +82,13 @@ jobs:
root: .
paths: .

build_web:
<<: *js_defaults
steps:
- attach_workspace:
at: ~/spectrum
- run: *setup-and-build-web

# Start db and servers, then run e2e and unit tests
test_web:
<<: *defaults
Expand All @@ -98,20 +104,20 @@ jobs:
- run: *install-rethinkdb
- run: *start-rethinkdb
- run: sleep 10
- run: *setup-and-build-web
- run: node -e "const setup = require('./shared/testing/setup.js')().then(() => process.exit())"
- run: *start-api
- run: *start-web
- run: sleep 60
- run:
name: Run Unit Tests
command: yarn run test:ci
- run:
name: Run E2E Tests
command: yarn run test:e2e
- run:
name: Danger
when: always
command: yarn run danger ci
- run:
name: Run E2E Tests
command: yarn run test:e2e

# Run eslint, flow etc.
test_static_js:
Expand Down Expand Up @@ -167,16 +173,21 @@ workflows:
test:
jobs:
- checkout_environment
- build_web:
requires:
- checkout_environment
- test_mobile_js:
requires:
- checkout_environment

# Disabled as Expo is fixing their critical issue with Detox
# - test_mobile_native:
# requires:
# - checkout_environment
- test_web:
requires:
- checkout_environment
- build_web
- test_static_js:
requires:
- checkout_environment
9 changes: 9 additions & 0 deletions api/models/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ const config = IS_PROD

var r = require('rethinkdbdash')(config);

// Exit the process on unhealthy db in test env
if (process.env.TEST_DB) {
r.getPoolMaster().on('healthy', healthy => {
if (!healthy) {
process.exit(1);
}
});
}

if (process.env.NODE_ENV === 'development') {
const fs = require('fs');
const inspect = require('rethinkdb-inspector');
Expand Down
16 changes: 11 additions & 5 deletions api/queries/channel/rootChannel.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// @flow
import type { GraphQLContext } from '../../';
import type { GetChannelArgs } from '../../models/channel';
import UserError from '../../utils/UserError';
import { getChannelBySlug } from '../../models/channel';

export default (_: any, args: GetChannelArgs, { loaders }: GraphQLContext) => {
if (args.id) return loaders.channel.load(args.id);
if (args.channelSlug && args.communitySlug)
return getChannelBySlug(args.channelSlug, args.communitySlug);
return null;
export default async (
_: any,
args: GetChannelArgs,
{ loaders }: GraphQLContext
) => {
if (args.id) return await loaders.channel.load(args.id);
if (args.channelSlug && args.communitySlug) {
return await getChannelBySlug(args.channelSlug, args.communitySlug);
}
return new UserError('We couldn’t find this channel');
};
2 changes: 1 addition & 1 deletion api/queries/community/hasChargeableSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default async (
_: any,
{ user, loaders }: GraphQLContext
) => {
if (!stripeCustomerId) return false;
if (!stripeCustomerId || !user) return false;

const {
isOwner,
Expand Down
1 change: 0 additions & 1 deletion api/routes/api/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import schema from '../../schema';
export default graphqlExpress(req => ({
schema,
formatError: createErrorFormatter(req),
tracing: true,
context: {
user: req.user ? (req.user.bannedAt ? null : req.user) : null,
loaders: createLoaders(),
Expand Down
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"baseUrl": "http://localhost:3000",
"viewportWidth": 1300,
"defaultCommandTimeout": 10000,
"defaultCommandTimeout": 20000,
"blacklistHosts": ["*.google-analytics.com"],
"videoRecording": false,
"env": {
"DEBUG": "src*,testing*,build*"
}
Expand Down
10 changes: 2 additions & 8 deletions cypress/integration/channel/settings/create_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,13 @@ const { userId: ownerInChannelId } = data.usersChannels.find(
// NOTE @brian: I will finish this after payments-api-v2 merges

describe('create a channel', () => {
before(() => {
beforeEach(() => {
cy.auth(ownerInChannelId);
// NOTE @brian: I can not get this to auth directly into /settings, having to work around for now
cy.visit(`/${community.slug}`);
cy.visit(`/${community.slug}/settings`);
});

it('should go through create a channel flow', () => {
cy
.get('[data-cy="community-settings-button"]')
.scrollIntoView()
.should('be.visible')
.click();

cy
.get('[data-cy="create-channel-button"]')
.scrollIntoView()
Expand Down
14 changes: 2 additions & 12 deletions cypress/integration/channel/settings/delete_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ const { userId: ownerInPrivateChannelId } = data.usersChannels.find(
describe('deleting general channel', () => {
before(() => {
cy.auth(ownerInChannelId);
cy.visit(`/${community.slug}/${channel.slug}`);
cy.visit(`/${community.slug}/${channel.slug}/settings`);
});

it('should not allow general channel to be deleted', () => {
cy
.get('[data-cy="channel-settings-button"]')
.should('be.visible')
.click();

cy.get('[data-cy="channel-overview"]').should('be.visible');

cy.get('[data-cy="delete-channel-button"]').should('not.be.visible');
Expand All @@ -40,15 +35,10 @@ describe('deleting general channel', () => {
describe('deleting a channel', () => {
before(() => {
cy.auth(ownerInPrivateChannelId);
cy.visit(`/${privateCommunity.slug}/${privateChannel.slug}`);
cy.visit(`/${privateCommunity.slug}/${privateChannel.slug}/settings`);
});

it('should delete a channel', () => {
cy
.get('[data-cy="channel-settings-button"]')
.should('be.visible')
.click();

cy.get('[data-cy="channel-overview"]').should('be.visible');

cy
Expand Down
50 changes: 2 additions & 48 deletions cypress/integration/channel/settings/edit_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,14 @@ const { userId: ownerInChannelId } = data.usersChannels.find(

const NEW_NAME = 'General Update';
const NEW_DESCRIPTION = 'New description';
const ORIGINAL_NAME = ' General';
const ORIGINAL_DESCRIPTION = 'General chatter';

describe('edit a channel', () => {
before(() => {
beforeEach(() => {
cy.auth(ownerInChannelId);
cy.visit(`/${community.slug}/${channel.slug}`);
cy.visit(`/${community.slug}/${channel.slug}/settings`);
});

it('should edit a channel', () => {
cy
.get('[data-cy="channel-settings-button"]')
.should('be.visible')
.click();

cy.get('[data-cy="channel-overview"]').should('be.visible');

cy
Expand Down Expand Up @@ -58,42 +51,3 @@ describe('edit a channel', () => {
cy.get('[data-cy="channel-profile-full"]').contains(NEW_DESCRIPTION);
});
});

describe('undo editing a channel', () => {
before(() => {
cy.auth(ownerInChannelId);
cy.visit(`/${community.slug}/${channel.slug}`);
});

it('should revert the edit', () => {
cy
.get('[data-cy="channel-settings-button"]')
.should('be.visible')
.click();

cy.get('[data-cy="channel-overview"]').should('be.visible');

cy
.get('[data-cy="channel-name-input"]')
.should('be.visible')
.click()
.clear()
.type(ORIGINAL_NAME);

cy
.get('[data-cy="channel-description-input"]')
.should('be.visible')
.click()
.clear()
.type(ORIGINAL_DESCRIPTION);

cy
.get('[data-cy="save-button"]')
.should('be.visible')
.click();

cy.get('[data-cy="save-button"]').should('be.disabled');

cy.get('[data-cy="save-button"]').should('not.be.disabled');
});
});
40 changes: 18 additions & 22 deletions cypress/integration/channel/settings/private_invite_link_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,31 @@ const { userId: ownerInChannelId } = data.usersChannels.find(
({ channelId, isOwner }) => channelId === channel.id && isOwner
);

describe('private channel invite link settings', () => {
beforeEach(() => {
cy.auth(ownerInChannelId);
cy.visit(`/${community.slug}/${channel.slug}/settings`);
});
const enable = () => {
cy.get('[data-cy="channel-overview"]').should('be.visible');

it('should enable private invite link', () => {
cy.get('[data-cy="channel-overview"]').should('be.visible');
cy.get('[data-cy="login-with-token-settings"]').scrollIntoView();

cy.get('[data-cy="login-with-token-settings"]').scrollIntoView();
cy
.get('[data-cy="toggle-token-link-invites-unchecked"]')
.should('be.visible')
.click();

cy
.get('[data-cy="toggle-token-link-invites-unchecked"]')
.should('be.visible')
.click();
cy.get('[data-cy="join-link-input"]').should('be.visible');
};

cy.get('[data-cy="join-link-input"]').should('be.visible');
describe('private channel invite link settings', () => {
beforeEach(() => {
cy.auth(ownerInChannelId);
cy.visit(`/${community.slug}/${channel.slug}/settings`);
});

it('should refresh invite link token', () => {
cy.get('[data-cy="channel-overview"]').should('be.visible');
it('should handle enable, reset, and disable', () => {
// enable
enable();

// reset token
cy.get('[data-cy="login-with-token-settings"]').scrollIntoView();

cy
.get('[data-cy="join-link-input"]')
.invoke('val')
Expand All @@ -55,13 +56,8 @@ describe('private channel invite link settings', () => {
expect(val1).not.to.eq(val2);
});
});
});

it('should disable private invite link', () => {
cy.get('[data-cy="channel-overview"]').should('be.visible');

cy.get('[data-cy="login-with-token-settings"]').scrollIntoView();

// disable
cy
.get('[data-cy="toggle-token-link-invites-checked"]')
.should('be.visible')
Expand Down
8 changes: 4 additions & 4 deletions cypress/integration/channel/view/composer_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { userId: memberInArchivedChannelId } = data.usersChannels.find(
const QUIET_USER_ID = constants.QUIET_USER_ID;

describe('renders composer for logged in members', () => {
before(() => {
beforeEach(() => {
cy.auth(memberInChannelId);
cy.visit(`/${community.slug}/${channel.slug}`);
});
Expand All @@ -37,7 +37,7 @@ describe('renders composer for logged in members', () => {
});

describe('does not render composer for non members', () => {
before(() => {
beforeEach(() => {
cy.auth(QUIET_USER_ID);
cy.visit(`/${community.slug}/${channel.slug}`);
});
Expand All @@ -50,7 +50,7 @@ describe('does not render composer for non members', () => {
});

describe('does not render composer for logged out users', () => {
before(() => {
beforeEach(() => {
cy.visit(`/${community.slug}/${channel.slug}`);
});

Expand All @@ -62,7 +62,7 @@ describe('does not render composer for logged out users', () => {
});

describe('does not render composer for archived channel', () => {
before(() => {
beforeEach(() => {
cy.auth(memberInArchivedChannelId);
cy.visit(`/${community.slug}/${archivedChannel.slug}`);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/channel/view/members_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const usersChannels = data.usersChannels
const members = data.users.filter(user => usersChannels.indexOf(user.id) >= 0);

describe('renders members list on channel view', () => {
before(() => {
beforeEach(() => {
cy.visit(`/${community.slug}/${channel.slug}`);
});

Expand Down
Loading