Skip to content

Commit

Permalink
first working tests
Browse files Browse the repository at this point in the history
  • Loading branch information
step21 committed Apr 9, 2024
1 parent f5410dc commit 20ff7bc
Show file tree
Hide file tree
Showing 11 changed files with 2,110 additions and 182 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>Contributor License Agreement Chooser</h1>
data-toggle="tab">1. General</a></li>
<li id="copyrightBullet" class="bullets"><a href="#copyright"
data-toggle="tab">2. Copyright</a></li>
<li is="patentsBullet" class="bullets"><a href="#patents"
<li id="patentsBullet" class="bullets"><a href="#patents"
data-toggle="tab">3. Patents</a></li>
<li id="reviewBullet" class="bullets"><a href="#review"
data-toggle="tab">4. Review</a></li>
Expand Down
209 changes: 146 additions & 63 deletions js/chooser.js

Large diffs are not rendered by default.

1,925 changes: 1,850 additions & 75 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
"@wdio/spec-reporter": "^8.31.1",
"chai": "^4.3.4",
"chai-http": "^4.3.0",
"cheerio": "^1.0.0-rc.12",
"concurrently": "^6.0.0",
"mocha": "^8.3.2",
"nyc": "^15.1.0",
"wdio-wait-for": "^3.0.11",
"webdriverio": "^8.32.1"
}
Expand Down
40 changes: 40 additions & 0 deletions tests/agreementTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//const Page = require('./pageobjects/page');
//const ApplyPage = require('./pageobjects/apply.page')
const AgreementPage = require('./pageobjects/agreement.page')
const { expect } = require('chai');
const agreementPage = new AgreementPage()


describe('The length of each document version should be correct', function() {
it('the fla version with default values should have the right length', async function() {
// FIXME add other generation steps
await agreementPage.open();
await expect(agreementPage.applyResultHtmlFlaText).to.exist;
await expect(agreementPage.htmlFlaTextLength).to.exist;
await expect(agreementPage.htmlFlaTextLength).toEqual(17071);
})
it('the fla entity version of the text with default version should have the right length', async function() {
await agreementPage.open();
await expect(agreementPage.htmlFlaTextEntityLength).to.exist;
})
});

describe('Basic Page load testing', function() {

it('should show the right agreement title', async function() {
await agreementPage.open();
const title = await agreementPage.pageTitle;
expect(title).to.include('Contributor License Agreement Chooser')
});
it('should get and log the url', async function() {
const url = agreementPage.pageUrl;
await console.log(url);
// await expect(browser).toHaveUrlContaining('localhost')
await expect(url).to.exist;
});

});




19 changes: 19 additions & 0 deletions tests/applyTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//applyTests.js

const ApplyPage = require('./pageobjects/apply.page')
const { expect } = require('chai');
const applyPage = new ApplyPage()

describe('texts should exist', function() {

it('all the tabs should function', async function() {
// FIXME add other generation steps
await applyPage.open();
await applyPage.goThroughAll();
expect(applyPage.applyResultHtmlFlaText).to.exist;
console.log(await applyPage.applyResultHtmlFlaText.getValue());
})
});



31 changes: 1 addition & 30 deletions tests/basicTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,18 @@ const page = new Page();


describe('Basic Page load testing', function() {
// maybe change to beforeEach?
//before(async function() {
// await browser.url('http://localhost:4000/');
//});

//it('should load the page correctly', async function() {
it('should show the right title', async function() {
it('should show the right page title', async function() {
await page.open();
const title = await page.pageTitle;
// expect... ?
//await expect(title).toBeExisting();
expect(title).to.include('Contributor License Agreement Chooser')
// await expect(title).toHaveTextContaining('Contributor License Agreement Chooser')
});
it('should get and log the url', async function() {
const url = page.pageUrl;
await console.log(url);
await expect(url).to.exist;
//expect(url).
});

// });
});

// chai does not allow for arrow functions because of some binding of the test
Expand All @@ -45,24 +35,5 @@ describe('Contributoragreements.org tests', function() {

});

/*describe('DuckDuckGo search', function() {
before(async function() {
await browser.url('https://duckduckgo.com');
});
it('Searches for WebdriverIO', async () => {
await browser.url('https://duckduckgo.com/?t=h_&q=WebdriverIO&ia=web')
// await driver.findElement(By.id("search_form_input")).sendKeys('WebdriverIO'); //, Key.RETURN);
//await driver.findElement(By.id("searchbox_input")).sendKeys(Keys.ENTER);
await $('#search_button').click();
let title = await browser.getTitle()
expect(title).to.equal('WebdriverIO at DuckDuckGo')
// or just
//await expect(driver).toHaveTitle('WebdriverIO at DuckDuckGo')
});
})*/


33 changes: 29 additions & 4 deletions tests/pageobjects/agreement.page.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
// apply.page.js
import ApplyPage from './apply.page'
const ApplyPage = require('./apply.page');

// cheerio is used to parse the html in the textarea, as this cannot be parsed normally via webdriverio or jquery I think
const cheerio = require('cheerio');

class AgreementPage extends ApplyPage {

get agreementFlaTitle () { this.applyResultHtmlFlaText() }

get htmlFlaTextLength () { return this.applyResultHtmlFlaText.getValue().length }
get htmlFlaEntityTextLength () { return this.applyResultHtmlFlaEntityText.getValue().length }

get htmlClaTextLength () { return this.applyResulthtmlClaText.getValue().length }
get htmlClaEntityTextLength () {}
//$$$fla = cheerio.load(this.applyResultHtmlFlaText);
// get agreementFlaTitle () { $$$fla('#tmp-title')
//get agreementFlaSubtitle

//get applyResultHtmFlaText () { return $('#embed-agreement-fla') }
Expand All @@ -12,7 +22,22 @@ class AgreementPage extends ApplyPage {
//get applyResultHtmlFlaEntityText () { return $('#embed-agreement-fla-entity') }
//get applyResultMkdnFlaEntityText () { return $('#embed-agreement-fla-entity-mkdn') }

/*
* get applyResultLinkFla () { return $('#btn-link-fla-indv') }
19 get applyResultLinkFlaText () { return this.applyResultLinkFla.getAttribute('href') }
20 get applyResultLinkFlaEntity () { return $('#btn-link-fla-entity') }
21 get applyResultLinkFlaEntityText () { return this.applyResultLinkFlaEntity.getAttribute('href') }
22 get applyResultHtmlFlaBtn () { return $('[href="#myHTML-fla"]') }
23 // inconsistency: html version does not have the format (html) in the id
24 get applyResultHtmlFlaText () { return $('#embed-agreement-fla') }
25 get applyResultMkdnFlaBtn () { return $('[href="#myMKDN-fla"]') }
26 get applyResultMkdnFlaText () { return $('#embed-agreement-fla-mkdn') }
27 get applyResultHtmlFlaEntityBtn () { return $('[href="#myHTML-fla-entity"]') }
28 get applyResultHtmlFlaEntityText () { return $('#embed-agreement-fla-entity') }
29 get applyResultMkdnFlaEntityBtn () { return $('[href="#myMKDN-fla-entity"]') }
30 get applyResultMkdnFlaEntityText () { return $('#embed-agreement-fla-entity-mkdn') }
31 // TODO / Not really sure if accessing the correct text needs to have the button clicked
*/

}
module.exports = new AgreementPage()
//export default new AgreementPage()
module.exports = AgreementPage;
5 changes: 2 additions & 3 deletions tests/pageobjects/apply.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// apply.page.js
import Page from './page'
const Page = require('./page');

class ApplyPage extends Page {

Expand Down Expand Up @@ -61,5 +61,4 @@ class ApplyPage extends Page {
async openMkdnClaEntity () { await this.applyResultMkdnClaEntityBtn.click() }
}

module.exports = new ApplyPage()
//export default new ApplyPage()
module.exports = ApplyPage;
15 changes: 12 additions & 3 deletions tests/pageobjects/page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { browser } = require('@wdio/globals')
// Page.js

module.exports = class Page {
//export default class Page {
class Page {

get pageTitle () { return browser.getTitle() }
get pageUrl () { return browser.getUrl() }
Expand All @@ -22,11 +21,14 @@ module.exports = class Page {
}
async next () {
await this.nextBtn.click()
//(await this.
}
async previous () {
await this.previousBtn.click()
}
async gotoGeneral () {
await browser.isElementDisplayed(await this.generalBullet.selector);
//await browser.waitUntil(this.generalBullet.isVisibleWithinViewport(), 20000, 'link not visible')
await this.generalBullet.click()
}
async gotoCopyright () {
Expand All @@ -41,6 +43,13 @@ module.exports = class Page {
async gotoApply () {
await this.applyBullet.click()
}
async goThroughAll () {
await this.gotoGeneral()
await this.gotoCopyright()
await this.gotoPatents()
await this.gotoReview()
await this.gotoApply()
}
}


module.exports = Page;
11 changes: 8 additions & 3 deletions wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ exports.config = {
// Runner Configuration
// ====================
// WebdriverIO supports running e2e tests as well as unit and component tests.
runner: 'local',
runner: ['local', {
preset: process.env.WDIO_PRESET,
coverage: {
enabled: true
}
}],
//
// ==================
// Specify Test Files
Expand All @@ -22,7 +27,7 @@ exports.config = {
//
specs: [
'./tests/specs/**/*.js',
'./tests/basicTests.js'
'./tests/*Tests.js'
],
// Patterns to exclude.
exclude: [
Expand Down Expand Up @@ -66,7 +71,7 @@ exports.config = {
// Define all options that are relevant for the WebdriverIO instance here
//
// Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'info',
logLevel: 'warn',
//
// Set specific log levels per logger
// loggers:
Expand Down

0 comments on commit 20ff7bc

Please sign in to comment.