Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test my data listing #4

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 3 additions & 1 deletion tests/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as process from 'process';

const BASE_URL = process.env.BASE_URL;
const USERNAME = process.env.USERNAME; // Set with your test user's username
const PASSWORD = process.env.PASSWORD; // Set with your test user's password

export {BASE_URL}
export { BASE_URL, USERNAME, PASSWORD }
40 changes: 40 additions & 0 deletions tests/data-depot/testForMyDataListing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Selector } from 'testcafe';
import { BASE_URL, USERNAME, PASSWORD } from '../config'; // Loads variables from config.ts

// Loads DesignSafe staging page
let f = fixture`My Data Listing`;
f.page(BASE_URL);

// Sets elements that will be used during test execution
const loginButton = Selector('.btn-group').find('a').withText('Log in');
const dropdown = Selector('.dropdown').withText('Research Workbench');
const dropdownMenuDataDepot = dropdown.find('li').withText('Data Depot');
const myDataListing = Selector('tr');

// test begins
test('My Data Listing', async t => {
// Clicks login button on home page
await t
.click(loginButton);

// Enters username and password set in config.js and clicks login button
await t
.typeText('#username', USERNAME)
.typeText('#password', PASSWORD)
.click('#login-btn');

// If the user account needs approval, uncomment the line of code below.
// This will usually only need to be used the first login.
/* await t
.click('#approveAlways'); */

//Navigates through navbar ribbon and selects Data Depot
await t
.click(dropdown)
.click(dropdownMenuDataDepot)

// Counts entries on My Data file listing and checks that there are
// less the count is less than or equal to 25 rows
const tableCount = await myDataListing.count;
await t.expect(tableCount).lte(25, 'More than 25 items in My Data listing');
});