Skip to content

Commit

Permalink
Merge pull request #16 from YangKaiting/v0.0.2
Browse files Browse the repository at this point in the history
release for v0.0.2
  • Loading branch information
bernicecpz authored Oct 20, 2020
2 parents 31f42dd + fea5e89 commit 8cff521
Show file tree
Hide file tree
Showing 12 changed files with 9,309 additions and 1,700 deletions.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The crawler will then generate the results based on the links found **within the
**Required inputs**
- URL linking to the sitemap file
- Examples of valid sitemap format
- XML (Recommended): https://www.sitemaps.org/sitemap.xml
- XML (Recommended): https://www.sitemaps.org/sitemap.xml
- RSS: https://itunes.apple.com/gb/rss/customerreviews/id=317212648/xml
- Text: https://www.xml-sitemaps.com/urllist.txt
- For more information on sitemap: https://www.sitemaps.org/protocol.html
Expand Down Expand Up @@ -140,4 +140,53 @@ Scanning website...
#Console results

user@user-MacBook-Pro purple-hats %
```
```

### 3. Crawling login page
The crawler will automated the login and recursively visit the links to generate the results from **all the pages found from the input domain**.

**Required inputs**
- A website URL
- User's login credential
- Selectors of the username field, password field and submit button field

**Sample Output - Public Domain with Login Page**
```console
user@user-MacBook-Pro Desktop % cd purple-hats
user@user-MacBook-Pro purple-hats % bash run.sh
Welcome to HAT's Accessibility Testing Tool!
We recommend using Chrome browser for the best experience.

What would you like to scan today?
1) sitemap.xml file containing links
2) public domain URL
#? 2
Please enter domain URL: https://fontawesome.com/sessions/sign-in
Do you need to login to your domain? Y/N: y
Please enter your login ID: [email protected]
Please enter your password:

Now, go to your browser and right-click on these 3 elements,
1. Username field
2. Login password field
3. Submit button

Select 'inspect' and 'copy selector'
Next, navigate back here and paste the selector one by one.

Please enter “username field” selector: #email_address
Please enter “login password field” selector: #password
Please enter “submit button” selector: #page-top > div.view.flex.flex-column.min-vh-100.db-pr > div.flex-grow-1.flex-shrink-0.flex-basis-auto.flex.flex-column > main > div.relative.z-1.mw6-l.center-l > div > form > button
Scanning website...

#The crawler will then start scraping from the file link provided above.
#Console results

user@user-MacBook-Pro purple-hats %
```






2 changes: 2 additions & 0 deletions combine.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { crawlSitemap } = require('./crawlers/crawlSitemap');
const { crawlDomain } = require('./crawlers/crawlDomain');

const { mergeFiles } = require('./mergeAxeResults');
const { getHostnameFromRegex, createAndUpdateFolders } = require('./utils');
const { a11yStorage } = require('./constants/constants');
Expand All @@ -14,6 +15,7 @@ exports.combineRun = async details => {
envDetails = {
type: process.env.TYPE,
url: process.env.URL,

randomToken: process.env.RANDOMTOKEN,
};
}
Expand Down
63 changes: 63 additions & 0 deletions crawlers/__tests__/commonCrawlerFunc.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const rewire = require("rewire");
const { gotoFunction } = require('../commonCrawlerFunc');

describe('test filter axe results', () => {
test('it works', () => {
const privateFuncs = rewire('../commonCrawlerFunc');
const filterAxeResults = privateFuncs.__get__('filterAxeResults');

const host = "http://test.com/";
const results = {
violations: [{
id: "1",
nodes: [{ html: "1-html1" }, { html: "1-html2" }],
help: "help1",
impact: "impact1",
helpUrl: "helpurl1"
},
{
id: "2",
nodes: [{ html: "2-html1" }, { html: "2-html2" }],
help: "help2",
impact: "impact2",
helpUrl: "helpurl2"
}],
url: `${host}api/path`
}

const { url, page, errors } = filterAxeResults(results, host);

expect(url).toEqual(results.url)
expect(page).toEqual('api/path');
expect(errors).toEqual([
{
id: "1",
description: "help1",
impact: "impact1",
helpUrl: "helpurl1",
fixes: [{ htmlElement: "1-html1" }, { htmlElement: "1-html2" }]
},
{
id: "2",
description: "help2",
impact: "impact2",
helpUrl: "helpurl2",
fixes: [{ htmlElement: "2-html1" }, { htmlElement: "2-html2" }]
}
]);
});
});

describe('test goto function', () => {
test('it works', async () => {
const goToResponse = "response";
const request = { url: "url" };
const page = { goto: jest.fn(() => goToResponse) };

const result = await gotoFunction({ request, page });

expect(result).toEqual(goToResponse);
expect(page.goto.mock.calls.length).toEqual(1);
expect(page.goto.mock.calls[0]).toEqual([request.url, { waitUntil: 'networkidle2' }, { timeout: 30000 }]);
});
});
2 changes: 0 additions & 2 deletions installers/linux-installer.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

#Linux in general

# Removing previous installation of /.nvm directory and node_modules
if [ -d "node_modules" ]; then
rm -r node_modules
Expand Down
200 changes: 200 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/rf/fq1pl5kj1278tskrsgv4hrt00000gn/T/jest_dx",

// Automatically clear mock calls and instances between every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
"**/*.{js,jsx}",
"!**/node_modules/**"
],

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: [
"text",
"text-summary"
],

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
"global": {
"branches": 1,
"functions": 1,
"lines": 1,
"statements": 1
},
},

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "ts",
// "tsx",
// "node"
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: undefined,

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state between every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state between every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jasmine2",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
Loading

0 comments on commit 8cff521

Please sign in to comment.