Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dependencies
- const assert = require('assert');
- const {
- Dashboard,
- DashboardUser,
- User,
- Organisation,
- OrganisationUser,
- ForgotPassword
- } = require('api/models');
- const { validUsers, validUser } = require('api/test/data/userData.test');
- const { interactsWithMail } = require('api/test/helpers/emailStub');
- const pages = require('./pages');
- const selectors = require('./selectors');
- const scope = require('./scope');
- // Defines whether puppeteer runs Chrome in headless mode.
- let headless = true;
- let slowMo = 5;
- // Chrome is set to run headlessly and with no slowdown in CircleCI
- if (process.env.CIRCLECI) headless = true;
- if (process.env.CIRCLECI) slowMo = 0;
- const assertUserHasPassword = async (identifier, password) => {
- const authenticated = await User.authenticate({ identifier, password });
- assert(authenticated);
- };
- const assertUserHasEmail = async (username, email) => {
- const user = await User.findOne({ username });
- assert.equal(user.email, email);
- };
- const userExists = async username => {
- const userDetails = validUsers.find(v => v.username === username);
- await new User(userDetails).save();
- };
- const dashboardForUserExists = async (username, name) => {
- const user = await User.findOne({ username });
- await new Dashboard({ name, createdBy: user._id }).save();
- };
- const closeAccount = async username => {
- const user = await User.findOne({ username });
- await user.deactivate(validUser.password);
- };
- const pending = callback => {
- callback(null, 'pending');
- };
- const visitHomepage = async () => {
- if (!scope.browser)
- scope.browser = await scope.driver.launch({ headless, slowMo });
- scope.context.currentPage = await scope.browser.newPage();
- scope.context.currentPage.setViewport({ width: 1280, height: 1024 });
- const url = scope.host + pages.home;
- const visit = await scope.context.currentPage.goto(url, {
- waitUntil: 'networkidle2'
- });
- return visit;
- };
Add Comment
Please, Sign In to add comment