From 47121ee0751128b835b86fcdfeadeb72c4c9d173 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Mon, 1 Oct 2018 13:22:28 -0500 Subject: [PATCH 1/8] This test now successfully navigates to the login page. --- testForMyDataListing.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts index 69d78e1..cdaf70d 100644 --- a/testForMyDataListing.ts +++ b/testForMyDataListing.ts @@ -3,16 +3,23 @@ import { Selector } from 'testcafe'; fixture `My Data Listing` .page`https://designsafeci-dev.tacc.utexas.edu/`; -const dropdown = Selector('.btn-group').withText('Log in'); +const loginButton = Selector('.btn-group').find('a').withText('Log in'); +const dropdown = Selector('.dropdown'); const dropdownMenuDataDepot = dropdown.find('li').withText('Data Depot'); const dataDepotNavBarPublished = Selector('.ng-scope').withAttribute('ng-switch-when','publicData'); const publishedListing = Selector('tr'); test('My Data Listing', async t => { await t - .click(dropdown) + .click(loginButton); + + /* await t + .typeText(#username, 'username') + .typeText(#password, 'password'); */ + + await t .click(dropdownMenuDataDepot) - .click(dataDepotNavBarPublished) + .click(dataDepotNavBarPublished); const tableCount = await publishedListing.count; await t From 9d4ee79fb8f09241a8bcb09fee52059ef74c9479 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Mon, 1 Oct 2018 15:25:50 -0500 Subject: [PATCH 2/8] This test now successfully logins in, if the correct username and password is provided. --- testForMyDataListing.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts index cdaf70d..6d025fe 100644 --- a/testForMyDataListing.ts +++ b/testForMyDataListing.ts @@ -13,11 +13,18 @@ test('My Data Listing', async t => { await t .click(loginButton); - /* await t - .typeText(#username, 'username') - .typeText(#password, 'password'); */ + await t + .typeText('#username', 'XYZ') // Replace XYZ with your test user's username + .typeText('#password', 'XYZ') // Replace XYZ with your test user's 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'); */ + await t + .click(dropdown) .click(dropdownMenuDataDepot) .click(dataDepotNavBarPublished); From 57c7e3a15c52caf3fe11fec62966de3815a38c06 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Mon, 1 Oct 2018 16:16:33 -0500 Subject: [PATCH 3/8] This test now successfully navigates to the Data Depot. The previously used selectors to navigate to the Data Depot didnt work, because Notifications tags use a similar class name: "dropdown" --- testForMyDataListing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts index 6d025fe..a44b7f9 100644 --- a/testForMyDataListing.ts +++ b/testForMyDataListing.ts @@ -4,7 +4,7 @@ fixture `My Data Listing` .page`https://designsafeci-dev.tacc.utexas.edu/`; const loginButton = Selector('.btn-group').find('a').withText('Log in'); -const dropdown = Selector('.dropdown'); +const dropdown = Selector('.dropdown').withText('Research Workbench'); const dropdownMenuDataDepot = dropdown.find('li').withText('Data Depot'); const dataDepotNavBarPublished = Selector('.ng-scope').withAttribute('ng-switch-when','publicData'); const publishedListing = Selector('tr'); From 4d882d984519b06d2cd8b959935f734f6a9d3f08 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Mon, 1 Oct 2018 17:04:02 -0500 Subject: [PATCH 4/8] Test now navigates to My Data and tests to see if listing is between 0-25. The assertion that the listing must be greater than 0 currently fails, but the less than 25 passes. --- testForMyDataListing.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts index a44b7f9..2f6c951 100644 --- a/testForMyDataListing.ts +++ b/testForMyDataListing.ts @@ -6,7 +6,6 @@ fixture `My Data Listing` 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 dataDepotNavBarPublished = Selector('.ng-scope').withAttribute('ng-switch-when','publicData'); const publishedListing = Selector('tr'); test('My Data Listing', async t => { @@ -26,7 +25,6 @@ test('My Data Listing', async t => { await t .click(dropdown) .click(dropdownMenuDataDepot) - .click(dataDepotNavBarPublished); const tableCount = await publishedListing.count; await t From 4cbab12e78e62277b9703af400436893f794e7fa Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Tue, 2 Oct 2018 14:08:39 -0500 Subject: [PATCH 5/8] Re-assessed testing criteria. It should be possible that a file listing in My Data could be 0, but it should also be less than or equal to 25. New assertions reflect that, and pass. --- testForMyDataListing.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts index 2f6c951..6512792 100644 --- a/testForMyDataListing.ts +++ b/testForMyDataListing.ts @@ -6,7 +6,7 @@ fixture `My Data Listing` 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 publishedListing = Selector('tr'); +const myDataListing = Selector('tr'); test('My Data Listing', async t => { await t @@ -26,8 +26,6 @@ test('My Data Listing', async t => { .click(dropdown) .click(dropdownMenuDataDepot) - const tableCount = await publishedListing.count; - await t - .expect(tableCount).gt(0, 'No items in My Data listing') - .expect(tableCount).lt(25, 'More than 25 items in My Data listing'); + const tableCount = await myDataListing.count; + await t.expect(tableCount).lte(25, 'More than 25 items in My Data listing'); }); \ No newline at end of file From 482e58c5cfe1dd7c90dd08b9b51197839be23e79 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Tue, 2 Oct 2018 15:55:32 -0500 Subject: [PATCH 6/8] Improved in-line documentation on test. Added a config.js file that will allow users to set environment variables. Specifically, this now allows users to set a test user's username and password. --- config.js | 4 ++++ testForMyDataListing.ts | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 config.js diff --git a/config.js b/config.js new file mode 100644 index 0000000..ad1e9ad --- /dev/null +++ b/config.js @@ -0,0 +1,4 @@ +export default { + username: "", // Set with your test user's username + password: "" // Set with your test user's password +}; \ No newline at end of file diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts index 6512792..d6ecb08 100644 --- a/testForMyDataListing.ts +++ b/testForMyDataListing.ts @@ -1,20 +1,26 @@ import { Selector } from 'testcafe'; +import config from './config'; // Loads variables from config.js +// Loads DesignSafe staging page fixture `My Data Listing` .page`https://designsafeci-dev.tacc.utexas.edu/`; +// 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); + .click(loginButton); + // Enters username and password set in config.js and clicks login button await t - .typeText('#username', 'XYZ') // Replace XYZ with your test user's username - .typeText('#password', 'XYZ') // Replace XYZ with your test user's password + .typeText('#username', `${config.username}`) + .typeText('#password', `${config.password}`) .click('#login-btn'); // If the user account needs approval, uncomment the line of code below. @@ -22,10 +28,13 @@ test('My Data Listing', async t => { /* 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'); }); \ No newline at end of file From 17fce8709b3c432ac4c8b7f8ebfd858bfe8c6d94 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Thu, 4 Oct 2018 10:17:50 -0500 Subject: [PATCH 7/8] Moved testForMyDataListing.ts to reflect new file structure. --- tests/data-depot/testForMyDataListing.ts | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/data-depot/testForMyDataListing.ts diff --git a/tests/data-depot/testForMyDataListing.ts b/tests/data-depot/testForMyDataListing.ts new file mode 100644 index 0000000..d6ecb08 --- /dev/null +++ b/tests/data-depot/testForMyDataListing.ts @@ -0,0 +1,40 @@ +import { Selector } from 'testcafe'; +import config from './config'; // Loads variables from config.js + +// Loads DesignSafe staging page +fixture `My Data Listing` + .page`https://designsafeci-dev.tacc.utexas.edu/`; + +// 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', `${config.username}`) + .typeText('#password', `${config.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'); +}); \ No newline at end of file From f357c4f9a5ba94b749367cfa87075393a7f1ad67 Mon Sep 17 00:00:00 2001 From: Frank Netscher Date: Fri, 26 Oct 2018 16:09:52 -0500 Subject: [PATCH 8/8] Updated env variables to run in Jenkins. Removed old config and testForMyDataListing.ts --- config.js | 4 --- testForMyDataListing.ts | 40 ------------------------ tests/config.ts | 4 ++- tests/data-depot/testForMyDataListing.ts | 10 +++--- 4 files changed, 8 insertions(+), 50 deletions(-) delete mode 100644 config.js delete mode 100644 testForMyDataListing.ts diff --git a/config.js b/config.js deleted file mode 100644 index ad1e9ad..0000000 --- a/config.js +++ /dev/null @@ -1,4 +0,0 @@ -export default { - username: "", // Set with your test user's username - password: "" // Set with your test user's password -}; \ No newline at end of file diff --git a/testForMyDataListing.ts b/testForMyDataListing.ts deleted file mode 100644 index d6ecb08..0000000 --- a/testForMyDataListing.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Selector } from 'testcafe'; -import config from './config'; // Loads variables from config.js - -// Loads DesignSafe staging page -fixture `My Data Listing` - .page`https://designsafeci-dev.tacc.utexas.edu/`; - -// 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', `${config.username}`) - .typeText('#password', `${config.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'); -}); \ No newline at end of file diff --git a/tests/config.ts b/tests/config.ts index 73d548d..630a8ed 100644 --- a/tests/config.ts +++ b/tests/config.ts @@ -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 } diff --git a/tests/data-depot/testForMyDataListing.ts b/tests/data-depot/testForMyDataListing.ts index d6ecb08..734b661 100644 --- a/tests/data-depot/testForMyDataListing.ts +++ b/tests/data-depot/testForMyDataListing.ts @@ -1,9 +1,9 @@ import { Selector } from 'testcafe'; -import config from './config'; // Loads variables from config.js +import { BASE_URL, USERNAME, PASSWORD } from '../config'; // Loads variables from config.ts // Loads DesignSafe staging page -fixture `My Data Listing` - .page`https://designsafeci-dev.tacc.utexas.edu/`; +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'); @@ -19,8 +19,8 @@ test('My Data Listing', async t => { // Enters username and password set in config.js and clicks login button await t - .typeText('#username', `${config.username}`) - .typeText('#password', `${config.password}`) + .typeText('#username', USERNAME) + .typeText('#password', PASSWORD) .click('#login-btn'); // If the user account needs approval, uncomment the line of code below.