Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
}
.status-info {
background: #e8f0fe;
color: #1a73e8;
color: #1765cc;
}
.status-ok {
background: #e6f4ea;
Expand Down
31 changes: 31 additions & 0 deletions deploy/tests/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
}) => {
await signIn(page)
// Default mock returns empty files array
await page.waitForTimeout(500)

Check warning on line 277 in deploy/tests/ui.spec.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this fixed wait with a synchronization on an observable condition.

See more on https://sonarcloud.io/project/issues?id=petry-projects_google-app-scripts&issues=AZ8-CoCqNz9eHDgJ82yM&open=AZ8-CoCqNz9eHDgJ82yM&pullRequest=430
await expect(page.locator('#step3-card')).toBeHidden()
})

Expand Down Expand Up @@ -1290,6 +1290,37 @@
await expect(page.locator('#status-msg.status-error')).toBeVisible()
})

test('status-info banner meets WCAG AA contrast (>= 4.5:1)', async ({
page,
}) => {
const contrast = await page.evaluate(() => {
const el = document.createElement('div')
el.className = 'status-msg status-info'
el.textContent = 'sample'
document.body.appendChild(el)
const cs = getComputedStyle(el)
const fg = cs.color
const bg = cs.backgroundColor
el.remove()

const channels = (s) =>
((s || '').match(/\d+(\.\d+)?/g) || []).map(Number)
const luminance = ([r, g, b]) => {
const lin = [r, g, b].map((v) => {
v /= 255
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4)
})
return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2]
}
const l1 = luminance(channels(fg))
const l2 = luminance(channels(bg))
const lighter = Math.max(l1, l2)
const darker = Math.min(l1, l2)
return (lighter + 0.05) / (darker + 0.05)
})
expect(contrast).toBeGreaterThanOrEqual(4.5)
})

test('successful deploy shows status-ok class', async ({ page }) => {
await mockSuccessfulDeploy(page)
await signIn(page)
Expand Down
2 changes: 1 addition & 1 deletion gas-installer/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
}
.status-info {
background: #e8f0fe;
color: #1a73e8;
color: #1765cc;
}
.status-ok {
background: #e6f4ea;
Expand Down
31 changes: 31 additions & 0 deletions gas-installer/tests/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,37 @@ test.describe('gas-installer Index.html', () => {
await expect(page.locator('#status-msg.status-info')).toBeVisible()
})

test('status-info banner meets WCAG AA contrast (>= 4.5:1)', async ({
page,
}) => {
const contrast = await page.evaluate(() => {
const el = document.createElement('div')
el.className = 'status-msg status-info'
el.textContent = 'sample'
document.body.appendChild(el)
const cs = getComputedStyle(el)
const fg = cs.color
const bg = cs.backgroundColor
el.remove()

const channels = (s) =>
((s || '').match(/\d+(\.\d+)?/g) || []).map(Number)
const luminance = ([r, g, b]) => {
const lin = [r, g, b].map((v) => {
v /= 255
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4)
})
return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2]
}
const l1 = luminance(channels(fg))
const l2 = luminance(channels(bg))
const lighter = Math.max(l1, l2)
const darker = Math.min(l1, l2)
return (lighter + 0.05) / (darker + 0.05)
})
expect(contrast).toBeGreaterThanOrEqual(4.5)
})

test('showStatus ok applies status-ok class', async ({ page }) => {
await page.locator('#script-gmail').click()
await page.fill('#project-title', 'My Project')
Expand Down
Loading