Skip to content

Commit

Permalink
Use manual logins instead of Testcafe Roles
Browse files Browse the repository at this point in the history
  • Loading branch information
jabrah committed Dec 11, 2023
1 parent 604ff84 commit 6ab6132
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 48 deletions.
4 changes: 2 additions & 2 deletions tests/baseCaseTests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { fixture, Selector, test } from 'testcafe';
import { userNih, currLocation, TIMEOUT_LENGTH } from './commonTest';
import { currLocation, TIMEOUT_LENGTH, login } from './commonTest';

fixture`Acceptance Testing`.page`https://pass.local`;

test('can walk through an nih submission workflow and make a submission - base case', async (t) => {
// Log in
await t.useRole(userNih);
login('nih-user');

// Go to Submissions
const submissionsButton = Selector('.nav-link.ember-view').withText(
Expand Down
59 changes: 17 additions & 42 deletions tests/commonTest.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,25 @@
import { Selector, Role, ClientFunction } from 'testcafe';
import { Selector, ClientFunction, t } from 'testcafe';

const LOGIN_URL = 'https://pass.local/login/saml';

export const userNih = Role(
LOGIN_URL,
async (t) => {
await t
.typeText(Selector('#username'), 'nih-user')
.typeText(Selector('#password'), 'moo')
.click(Selector('.form-element.form-button'));
},
{ preserveUrl: true }
);
export const USER = {
NIH_USER: 'nih-user',
ADMIN_SUBMITTER: 'admin-submitter',
};

export const userIncompleteNih = Role(
LOGIN_URL,
async (t) => {
await t
.typeText(Selector('#username'), 'incomplete-nih-user')
.typeText(Selector('#password'), 'moo')
.click(Selector('.form-element.form-button'));
},
{ preserveUrl: true }
);
export async function login(usr) {
return await t
.navigateTo(LOGIN_URL)
.typeText('#username', usr)
.typeText('#password', 'moo')
.click('.form-element.form-button');
}

export const userStaff1 = Role(
LOGIN_URL,
async (t) => {
await t
.typeText(Selector('#username'), 'staff1')
.typeText(Selector('#password'), 'moo')
.click(Selector('.form-element.form-button'));
},
{ preserveUrl: true }
);

export const userAdminSubmitter = Role(
LOGIN_URL,
async (t) => {
await t
.typeText(Selector('#username'), 'admin-submitter')
.typeText(Selector('#password'), 'moo')
.click(Selector('.form-element.form-button'));
},
{ preserveUrl: true }
);
export async function logout() {
return await t
.click('#user-menu-name') // Open the app menu to make logout btn visible
.click(Selector('#user-menu a').withText('Logout'));
}

export const currLocation = ClientFunction(() => window.location.href);

Expand Down
10 changes: 6 additions & 4 deletions tests/proxySubmissionTests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { fixture, Selector, test } from 'testcafe';
import { userAdminSubmitter, currLocation, TIMEOUT_LENGTH } from './commonTest';
import { currLocation, TIMEOUT_LENGTH, login, logout } from './commonTest';

fixture`Acceptance Testing`.page`https://pass.local`;
fixture`Acceptance Testing`.page`https://pass.local`.afterEach(logout);

test('can walk through a proxy submission workflow and make a submission - with pass account', async (t) => {
// use role
await t.useRole(userAdminSubmitter);
// await t.useRole(userAdminSubmitter);
login('admin-submitter');

// Go to Submissions
const submissionsButton = Selector('.nav-link.ember-view').withText(
Expand Down Expand Up @@ -66,7 +67,8 @@ test('can walk through a proxy submission workflow and make a submission - with

test('can walk through a proxy submission workflow and make a submission - without pass account', async (t) => {
// use role
await t.useRole(userAdminSubmitter);
// await t.useRole(userAdminSubmitter);
login('admin-submitter');

// Go to Submissions
const submissionsButton = Selector('.nav-link.ember-view', {
Expand Down

0 comments on commit 6ab6132

Please sign in to comment.