Skip to content
Merged
1 change: 1 addition & 0 deletions .github/actions/file/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type Finding = {
category?: FindingCategory
ruleId?: string
url: string
originalUrl: string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this is true, the originalUrl field of findings is not used anywhere in the file action, so it should be ok if it has an undefined value. Also, parsing json shouldn't fail if there are missing or extra fields in the json vs the actual type.

html?: string
nodes?: FindingNode[]
problemShort: string
Expand Down
17 changes: 12 additions & 5 deletions .github/actions/find/src/findForUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type {ColorSchemePreference, Finding, FindingCategory, ReducedMotionPreference, UrlConfig} from './types.d.js'
import type {
ColorSchemePreference,
Finding,
FindingCategory,
FindingInput,
ReducedMotionPreference,
UrlConfig,
} from './types.d.js'
import {AxeBuilder} from '@axe-core/playwright'
import {accesslintAudit} from '@accesslint/playwright'
import playwright from 'playwright'
Expand Down Expand Up @@ -39,12 +46,12 @@ export async function findForUrl(
)

const findings: Finding[] = []
const addFinding = async (findingData: Finding) => {
const addFinding = async (findingData: FindingInput) => {
let screenshotId
if (includeScreenshots) {
screenshotId = await generateScreenshots(page)
}
findings.push({...findingData, screenshotId})
findings.push({...findingData, screenshotId, originalUrl: url})
}

try {
Expand Down Expand Up @@ -92,7 +99,7 @@ async function runAxeScan({
excludeSelectors,
}: {
page: playwright.Page
addFinding: (findingData: Finding, options?: {includeScreenshots?: boolean}) => Promise<void>
addFinding: (findingData: FindingInput, options?: {includeScreenshots?: boolean}) => Promise<void>
excludeSelectors?: string[]
}) {
const url = page.url()
Expand Down Expand Up @@ -129,7 +136,7 @@ async function runAccesslintScan({
addFinding,
}: {
page: playwright.Page
addFinding: (findingData: Finding, options?: {includeScreenshots?: boolean}) => Promise<void>
addFinding: (findingData: FindingInput, options?: {includeScreenshots?: boolean}) => Promise<void>
}) {
const url = page.url()
core.info(`Scanning ${url} with AccessLint`)
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/find/src/pluginManager/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {Finding} from '../types.d.js'
import type {FindingInput} from '../types.d.js'
import playwright from 'playwright'

export type PluginDefaultParams = {
page: playwright.Page
addFinding: (findingData: Finding) => Promise<void>
addFinding: (findingData: FindingInput) => Promise<void>
}

export type Plugin = {
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/find/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export type Finding = {
solutionLong?: string
screenshotId?: string
ruleId?: string
originalUrl: string
}

export type FindingInput = Omit<Finding, 'originalUrl'>

export type Cookie = {
name: string
value: string
Expand Down
22 changes: 22 additions & 0 deletions .github/actions/find/tests/findForUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,28 @@ describe('findForUrl', () => {
])
})

it('adds the original url to each finding', async () => {
actionInput = ''
clearAll()
vi.mocked(AxeBuilder.prototype.analyze).mockResolvedValueOnce({
violations: [
{
id: 'r',
help: 'h',
helpUrl: 'https://example.com',
description: 'd',
tags: [],
nodes: [{html: '<a></a>', target: ['a']}],
},
],
} as unknown as axe.AxeResults)

const findings = await findForUrl({url: 'https://original.example/page'})

expect(findings).toHaveLength(1)
expect(findings[0].originalUrl).toBe('https://original.example/page')
})

describe('axe finding categorization', () => {
function axeViolation(tags: string[]) {
return {
Expand Down
2 changes: 1 addition & 1 deletion sites/site-with-errors/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem "minima", "~> 2.5"
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
gem "jekyll-feed", "~> 0.18"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
120 changes: 61 additions & 59 deletions sites/site-with-errors/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@ GEM
addressable (2.9.0)
public_suffix (>= 2.0.2, < 8.0)
base64 (0.3.0)
bigdecimal (3.2.2)
bigdecimal (4.1.3)
colorator (1.1.0)
concurrent-ruby (1.3.7)
csv (3.3.5)
concurrent-ruby (1.3.8)
csv (3.3.6)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.17.2)
ffi (1.17.2-aarch64-linux-gnu)
ffi (1.17.2-aarch64-linux-musl)
ffi (1.17.2-arm-linux-gnu)
ffi (1.17.2-arm-linux-musl)
ffi (1.17.2-arm64-darwin)
ffi (1.17.2-x86-linux-gnu)
ffi (1.17.2-x86-linux-musl)
ffi (1.17.2-x86_64-darwin)
ffi (1.17.2-x86_64-linux-gnu)
ffi (1.17.2-x86_64-linux-musl)
ffi (1.17.4)
ffi (1.17.4-aarch64-linux-gnu)
ffi (1.17.4-aarch64-linux-musl)
ffi (1.17.4-arm-linux-gnu)
ffi (1.17.4-arm-linux-musl)
ffi (1.17.4-arm64-darwin)
ffi (1.17.4-x86-linux-gnu)
ffi (1.17.4-x86-linux-musl)
ffi (1.17.4-x86_64-darwin)
ffi (1.17.4-x86_64-linux-gnu)
ffi (1.17.4-x86_64-linux-musl)
forwardable-extended (2.6.0)
google-protobuf (4.32.0)
google-protobuf (4.36.2)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-aarch64-linux-gnu)
rake (~> 13.3)
google-protobuf (4.36.2-aarch64-linux-gnu)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-aarch64-linux-musl)
rake (~> 13.3)
google-protobuf (4.36.2-aarch64-linux-musl)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-arm64-darwin)
rake (~> 13.3)
google-protobuf (4.36.2-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-x86-linux-gnu)
rake (~> 13.3)
google-protobuf (4.36.2-x86-linux-gnu)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-x86-linux-musl)
rake (~> 13.3)
google-protobuf (4.36.2-x86-linux-musl)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-x86_64-darwin)
rake (~> 13.3)
google-protobuf (4.36.2-x86_64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-x86_64-linux-gnu)
rake (~> 13.3)
google-protobuf (4.36.2-x86_64-linux-gnu)
bigdecimal
rake (>= 13)
google-protobuf (4.32.0-x86_64-linux-musl)
rake (~> 13.3)
google-protobuf (4.36.2-x86_64-linux-musl)
bigdecimal
rake (>= 13)
rake (~> 13.3)
http_parser.rb (0.8.0)
i18n (1.14.7)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
jekyll (4.4.1)
addressable (~> 2.4)
Expand All @@ -73,23 +73,25 @@ GEM
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-feed (0.17.0)
jekyll-feed (0.18.0)
jekyll (>= 3.7, < 5.0)
jekyll-sass-converter (3.1.0)
sass-embedded (~> 1.75)
jekyll-seo-tag (2.8.0)
jekyll (>= 3.8, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
json (2.13.2)
kramdown (2.5.1)
rexml (>= 3.3.9)
json (2.21.2)
kramdown (2.5.2)
rexml (>= 3.4.4)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.4)
listen (3.9.0)
listen (3.10.1)
logger
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.7.0)
mercenary (0.4.0)
minima (2.5.2)
jekyll (>= 3.5, < 5.0)
Expand All @@ -102,48 +104,48 @@ GEM
puma (8.0.2)
nio4r (~> 2.0)
rack (3.2.7)
rake (13.3.0)
rake (13.4.2)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.4.2)
rouge (4.6.0)
rexml (3.4.4)
rouge (4.7.0)
safe_yaml (1.0.5)
sass-embedded (1.90.0)
sass-embedded (1.105.1)
google-protobuf (~> 4.31)
rake (>= 13)
sass-embedded (1.90.0-aarch64-linux-android)
rake (~> 13.3)
sass-embedded (1.105.1-aarch64-linux-android)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-aarch64-linux-gnu)
sass-embedded (1.105.1-aarch64-linux-gnu)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-aarch64-linux-musl)
sass-embedded (1.105.1-aarch64-linux-musl)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-arm-linux-androideabi)
sass-embedded (1.105.1-arm-linux-androideabi)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-arm-linux-gnueabihf)
sass-embedded (1.105.1-arm-linux-gnueabihf)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-arm-linux-musleabihf)
sass-embedded (1.105.1-arm-linux-musleabihf)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-arm64-darwin)
sass-embedded (1.105.1-arm64-darwin)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-riscv64-linux-android)
sass-embedded (1.105.1-riscv64-linux-android)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-riscv64-linux-gnu)
sass-embedded (1.105.1-riscv64-linux-gnu)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-riscv64-linux-musl)
sass-embedded (1.105.1-riscv64-linux-musl)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-x86_64-darwin)
sass-embedded (1.105.1-x86_64-darwin)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-x86_64-linux-android)
sass-embedded (1.105.1-x86_64-linux-android)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-x86_64-linux-gnu)
sass-embedded (1.105.1-x86_64-linux-gnu)
google-protobuf (~> 4.31)
sass-embedded (1.90.0-x86_64-linux-musl)
sass-embedded (1.105.1-x86_64-linux-musl)
google-protobuf (~> 4.31)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.6.0)
webrick (1.9.1)
webrick (1.9.2)

PLATFORMS
aarch64-linux-android
Expand All @@ -169,7 +171,7 @@ PLATFORMS
DEPENDENCIES
http_parser.rb (~> 0.6.0)
jekyll (~> 4.4.1)
jekyll-feed (~> 0.12)
jekyll-feed (~> 0.18)
minima (~> 2.5)
puma (~> 8.0)
rack (~> 3.2)
Expand Down
3 changes: 2 additions & 1 deletion tests/site-with-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ describe('site-with-errors', () => {

it('cache has expected results', () => {
const actual = results.map(({issue: {url: issueUrl}, findings}) => {
const {problemUrl, solutionLong, screenshotId, nodes, ...finding} = findings[0]
const {problemUrl, solutionLong, screenshotId, nodes, originalUrl, ...finding} = findings[0]
// Check volatile fields for existence only
expect(issueUrl).toBeDefined()
expect(problemUrl).toBeDefined()
expect(originalUrl).toBeDefined()
// Axe-specific assertions
if (finding.scannerType === 'axe') {
expect(solutionLong).toBeDefined()
Expand Down
1 change: 1 addition & 0 deletions tests/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Finding = {
scannerType: string
ruleId?: string
url: string
originalUrl: string
html?: string
nodes?: FindingNode[]
problemShort: string
Expand Down
Loading