|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0; you may not use this file except in compliance with the Elastic License |
| 5 | + * 2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +import { expect } from '@kbn/scout/ui'; |
| 9 | +import { tags } from '@kbn/scout'; |
| 10 | + |
| 11 | +import { test } from '../fixtures'; |
| 12 | + |
| 13 | +// Modals, flyouts, and context menus render in EUI portals outside .kbnAppWrapper. |
| 14 | +const A11Y_SELECTORS = ['.kbnAppWrapper', '[data-euiportal="true"]']; |
| 15 | + |
| 16 | +test.describe('Snapshot & Restore — accessibility', { tag: tags.stateful.classic }, () => { |
| 17 | + test.afterAll(async ({ kbnClient }) => { |
| 18 | + await kbnClient.savedObjects.cleanStandardList(); |
| 19 | + }); |
| 20 | + |
| 21 | + test('empty state: all tabs have no a11y violations', async ({ |
| 22 | + page, |
| 23 | + browserAuth, |
| 24 | + pageObjects, |
| 25 | + }) => { |
| 26 | + const { snapshotRestore } = pageObjects; |
| 27 | + |
| 28 | + await browserAuth.loginAsAdmin(); |
| 29 | + await page.gotoApp('management/data/snapshot_restore'); |
| 30 | + await snapshotRestore.waitForSnapshotsTab(); |
| 31 | + |
| 32 | + await test.step('snapshots tab (empty)', async () => { |
| 33 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 34 | + expect(violations).toHaveLength(0); |
| 35 | + }); |
| 36 | + |
| 37 | + await test.step('repositories tab (empty)', async () => { |
| 38 | + await snapshotRestore.navToRepositories(); |
| 39 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 40 | + expect(violations).toHaveLength(0); |
| 41 | + }); |
| 42 | + |
| 43 | + await test.step('policies tab (empty)', async () => { |
| 44 | + await snapshotRestore.navToPolicies(); |
| 45 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 46 | + expect(violations).toHaveLength(0); |
| 47 | + }); |
| 48 | + |
| 49 | + await test.step('restore status tab (empty)', async () => { |
| 50 | + await snapshotRestore.navToRestoreStatus(); |
| 51 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 52 | + expect(violations).toHaveLength(0); |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | + test('table views with data: snapshots and repositories have no a11y violations', async ({ |
| 57 | + page, |
| 58 | + browserAuth, |
| 59 | + pageObjects, |
| 60 | + esClient, |
| 61 | + }) => { |
| 62 | + const { snapshotRestore } = pageObjects; |
| 63 | + const repoName = 'testrepo'; |
| 64 | + const snapshotName = `testsnapshot${Date.now()}`; |
| 65 | + |
| 66 | + await esClient.snapshot.createRepository({ |
| 67 | + name: repoName, |
| 68 | + verify: true, |
| 69 | + repository: { type: 'fs', settings: { location: 'temp' } }, |
| 70 | + }); |
| 71 | + await esClient.snapshot.create({ |
| 72 | + repository: repoName, |
| 73 | + snapshot: snapshotName, |
| 74 | + wait_for_completion: true, |
| 75 | + }); |
| 76 | + |
| 77 | + try { |
| 78 | + await browserAuth.loginAsAdmin(); |
| 79 | + await page.gotoApp('management/data/snapshot_restore'); |
| 80 | + await snapshotRestore.waitForSnapshotsTab({ state: 'hasSnapshots' }); |
| 81 | + |
| 82 | + await test.step('snapshots table with data', async () => { |
| 83 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 84 | + expect(violations).toHaveLength(0); |
| 85 | + }); |
| 86 | + |
| 87 | + await test.step('repositories table with data', async () => { |
| 88 | + await snapshotRestore.navToRepositories(); |
| 89 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 90 | + expect(violations).toHaveLength(0); |
| 91 | + }); |
| 92 | + } finally { |
| 93 | + await esClient.snapshot |
| 94 | + .delete({ snapshot: snapshotName, repository: repoName }) |
| 95 | + .catch(() => {}); |
| 96 | + await esClient.snapshot.deleteRepository({ name: [repoName] }).catch(() => {}); |
| 97 | + } |
| 98 | + }); |
| 99 | + |
| 100 | + test('create policy wizard: all steps have no a11y violations', async ({ |
| 101 | + page, |
| 102 | + browserAuth, |
| 103 | + pageObjects, |
| 104 | + esClient, |
| 105 | + }) => { |
| 106 | + const { snapshotRestore } = pageObjects; |
| 107 | + const repoName = 'policyrepo'; |
| 108 | + |
| 109 | + await esClient.snapshot.createRepository({ |
| 110 | + name: repoName, |
| 111 | + verify: true, |
| 112 | + repository: { type: 'fs', settings: { location: 'temp' } }, |
| 113 | + }); |
| 114 | + |
| 115 | + try { |
| 116 | + await browserAuth.loginAsAdmin(); |
| 117 | + await page.gotoApp('management/data/snapshot_restore'); |
| 118 | + await snapshotRestore.waitForSnapshotsTab({ state: 'noSnapshots' }); |
| 119 | + await snapshotRestore.navToPolicies(); |
| 120 | + |
| 121 | + await test.step('page one', async () => { |
| 122 | + await snapshotRestore.fillCreateNewPolicyPageOne( |
| 123 | + 'testpolicy', |
| 124 | + '<daily-snap-{now/d}>', |
| 125 | + repoName |
| 126 | + ); |
| 127 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 128 | + expect(violations).toHaveLength(0); |
| 129 | + }); |
| 130 | + |
| 131 | + await test.step('page two', async () => { |
| 132 | + await snapshotRestore.fillCreateNewPolicyPageTwo(); |
| 133 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 134 | + expect(violations).toHaveLength(0); |
| 135 | + }); |
| 136 | + |
| 137 | + await test.step('page three', async () => { |
| 138 | + await snapshotRestore.fillCreateNewPolicyPageThree(); |
| 139 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 140 | + expect(violations).toHaveLength(0); |
| 141 | + }); |
| 142 | + |
| 143 | + await test.step('submit and view flyout', async () => { |
| 144 | + await snapshotRestore.submitNewPolicy(); |
| 145 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 146 | + expect(violations).toHaveLength(0); |
| 147 | + }); |
| 148 | + |
| 149 | + await test.step('policy table with data', async () => { |
| 150 | + await snapshotRestore.closeFlyout(); |
| 151 | + const { violations } = await page.checkA11y({ include: A11Y_SELECTORS }); |
| 152 | + expect(violations).toHaveLength(0); |
| 153 | + }); |
| 154 | + } finally { |
| 155 | + await esClient.snapshot.deleteRepository({ name: [repoName] }).catch(() => {}); |
| 156 | + await esClient.slm.deleteLifecycle({ policy_id: 'testpolicy' }).catch(() => {}); |
| 157 | + } |
| 158 | + }); |
| 159 | +}); |
0 commit comments