Skip to content

Commit

Permalink
fix: Include the latest w3c/aria-at data imports in tests and update …
Browse files Browse the repository at this point in the history
…sample data (#1111)

* Process multiple commits at once with import script

* Formatting

* wip: Update dataManagement.test.js to not depend on a "known" state of the test db so the latest commits from w3c/aria-at can be supported

* Update docs

* Populate test data with modal-dialog content that should have testable TestPlanVersion.tests[] that have presentationNumber being a float number
  • Loading branch information
howard-e committed May 29, 2024
1 parent 79c59fc commit ae90bce
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 134 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/runtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ jobs:
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ${PGDATABASE} to ${PGUSER};"
yarn sequelize:test db:migrate
yarn sequelize:test db:seed:all
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_1}
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_2}
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_3}
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_4}
yarn workspace server db-import-tests:test -c "${IMPORT_ARIA_AT_TESTS_COMMIT_1} ${IMPORT_ARIA_AT_TESTS_COMMIT_2} ${IMPORT_ARIA_AT_TESTS_COMMIT_3} ${IMPORT_ARIA_AT_TESTS_COMMIT_4}"
yarn workspace server db-import-tests:test
yarn workspace server db-populate-sample-data:test
# yarn test would run all of these in serial, however we split this up to allow it continue
# yarn test would run all of these in serial, however we split this up to allow it to continue
# in case of errors - all tests will still run even if lint fails for instance.
- run: yarn workspace shared prettier
if: always()
Expand Down
16 changes: 4 additions & 12 deletions docs/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ The database migrations are managed by [Sequelize](https://sequelize.org/). The
```
4. Import the most recent tests from the [aria-at repository](https://github.com/w3c/aria-at):
```
yarn db-import-tests:dev -c 5fe7afd82fe51c185b8661276105190a59d47322;
yarn db-import-tests:dev -c 1aa3b74d24d340362e9f511eae33788d55487d12;
yarn db-import-tests:dev -c ab77d47ab19db71c635c9bb459ba5c34182e1400;
yarn db-import-tests:dev -c d34eddbb8e751f07bd28d952de15fa7fe5f07353;
yarn db-import-tests:dev -c "5fe7afd82fe51c185b8661276105190a59d47322 1aa3b74d24d340362e9f511eae33788d55487d12 ab77d47ab19db71c635c9bb459ba5c34182e1400 d34eddbb8e751f07bd28d952de15fa7fe5f07353";
yarn db-import-tests:dev;
```

Expand All @@ -54,10 +51,7 @@ fi;
yarn sequelize db:migrate;
yarn sequelize db:seed:all;
yarn db-import-tests:dev -c 5fe7afd82fe51c185b8661276105190a59d47322;
yarn db-import-tests:dev -c 1aa3b74d24d340362e9f511eae33788d55487d12;
yarn db-import-tests:dev -c ab77d47ab19db71c635c9bb459ba5c34182e1400;
yarn db-import-tests:dev -c d34eddbb8e751f07bd28d952de15fa7fe5f07353;
yarn db-import-tests:dev -c "5fe7afd82fe51c185b8661276105190a59d47322 1aa3b74d24d340362e9f511eae33788d55487d12 ab77d47ab19db71c635c9bb459ba5c34182e1400 d34eddbb8e751f07bd28d952de15fa7fe5f07353";
yarn db-import-tests:dev;
```

Expand Down Expand Up @@ -100,10 +94,8 @@ The instructions are similar for the test database, with one extra step:
yarn db-init:test;
yarn sequelize:test db:migrate;
yarn sequelize:test db:seed:all;
yarn workspace server db-import-tests:test -c 5fe7afd82fe51c185b8661276105190a59d47322;
yarn workspace server db-import-tests:test -c 1aa3b74d24d340362e9f511eae33788d55487d12;
yarn workspace server db-import-tests:test -c ab77d47ab19db71c635c9bb459ba5c34182e1400;
yarn workspace server db-import-tests:test -c d34eddbb8e751f07bd28d952de15fa7fe5f07353;
yarn workspace server db-import-tests:test -c "5fe7afd82fe51c185b8661276105190a59d47322 1aa3b74d24d340362e9f511eae33788d55487d12 ab77d47ab19db71c635c9bb459ba5c34182e1400 d34eddbb8e751f07bd28d952de15fa7fe5f07353";
yarn workspace server db-import-tests:test;
yarn workspace server db-populate-sample-data:test;
```

Expand Down
4 changes: 1 addition & 3 deletions server/controllers/AutomationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ const getTestByRowNumber = async ({ testPlanRun, testRowNumber, context }) => {
null,
context
);
return tests.find(
test => String(test.rowNumber) === String(testRowNumber)
);
return tests.find(test => String(test.rowNumber) === String(testRowNumber));
};

const updateOrCreateTestResultWithResponses = async ({
Expand Down
38 changes: 19 additions & 19 deletions server/handlebars/embed/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ details summary::after {
}

details > summary.recommended::after {
background-color: #115b11;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='6.861' viewBox='0 0 12 6.861'%3E%3Cpath id='Icon_ionic-ios-arrow-down' data-name='Icon ionic-ios-arrow-down' d='M12.19,16.039,16.727,11.5a.854.854,0,0,1,1.211,0,.865.865,0,0,1,0,1.215L12.8,17.858a.856.856,0,0,1-1.183.025L6.438,12.717A.858.858,0,1,1,7.649,11.5Z' transform='translate(18.188 18.108) rotate(180)' fill='rgb(233, 251, 233)'/%3E%3C/svg%3E%0A");
background-color: #115b11;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='6.861' viewBox='0 0 12 6.861'%3E%3Cpath id='Icon_ionic-ios-arrow-down' data-name='Icon ionic-ios-arrow-down' d='M12.19,16.039,16.727,11.5a.854.854,0,0,1,1.211,0,.865.865,0,0,1,0,1.215L12.8,17.858a.856.856,0,0,1-1.183.025L6.438,12.717A.858.858,0,1,1,7.649,11.5Z' transform='translate(18.188 18.108) rotate(180)' fill='rgb(233, 251, 233)'/%3E%3C/svg%3E%0A");
}

details[open] summary::after {
Expand All @@ -73,8 +73,8 @@ details > summary {
}

details > summary.recommended {
border: 1.5px solid #7ac498;
background-color: #e9fbe9;
border: 1.5px solid #7ac498;
background-color: #e9fbe9;
}

details > summary > ::before {
Expand All @@ -90,26 +90,26 @@ details > summary > ::before {
}

details > summary.recommended ::before {
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4KICA8IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNS4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+CiAgPHBhdGgKICBmaWxsPSIjMTE1YjExIgogICAgZD0iTTI1NiA1MTJBMjU2IDI1NiAwIDEgMCAyNTYgMGEyNTYgMjU2IDAgMSAwIDAgNTEyek0yMTYgMzM2aDI0VjI3MkgyMTZjLTEzLjMgMC0yNC0xMC43LTI0LTI0czEwLjctMjQgMjQtMjRoNDhjMTMuMyAwIDI0IDEwLjcgMjQgMjR2ODhoOGMxMy4zIDAgMjQgMTAuNyAyNCAyNHMtMTAuNyAyNC0yNCAyNEgyMTZjLTEzLjMgMC0yNC0xMC43LTI0LTI0czEwLjctMjQgMjQtMjR6bTQwLTIwOGEzMiAzMiAwIDEgMSAwIDY0IDMyIDMyIDAgMSAxIDAtNjR6IgogIC8+Cjwvc3ZnPgo=');
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4KICA8IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNS4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+CiAgPHBhdGgKICBmaWxsPSIjMTE1YjExIgogICAgZD0iTTI1NiA1MTJBMjU2IDI1NiAwIDEgMCAyNTYgMGEyNTYgMjU2IDAgMSAwIDAgNTEyek0yMTYgMzM2aDI0VjI3MkgyMTZjLTEzLjMgMC0yNC0xMC43LTI0LTI0czEwLjctMjQgMjQtMjRoNDhjMTMuMyAwIDI0IDEwLjcgMjQgMjR2ODhoOGMxMy4zIDAgMjQgMTAuNyAyNCAyNHMtMTAuNyAyNC0yNCAyNEgyMTZjLTEzLjMgMC0yNC0xMC43LTI0LTI0czEwLjctMjQgMjQtMjR6bTQwLTIwOGEzMiAzMiAwIDEgMSAwIDY0IDMyIDMyIDAgMSAxIDAtNjR6IgogIC8+Cjwvc3ZnPgo=');
}

details > summary > h4 {
position: relative;
padding-left: var(--left-right-padding);
padding-right: var(--left-right-padding);
position: relative;
padding-left: var(--left-right-padding);
padding-right: var(--left-right-padding);

font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
color: #60470c;
display: inline-block;
font-family: Arial, Helvetica, sans-serif;
font-size: 1em;
color: #60470c;
display: inline-block;
}

details > summary.recommended > h4 {
color: #384338;
color: #384338;
}

details summary::-webkit-details-marker {
display: none;
display: none;
}

.content-container {
Expand All @@ -130,11 +130,11 @@ details summary::-webkit-details-marker {
}

div.recommended {
border-bottom: 1.5px solid #7ac498;
border-left: 1.5px solid #7ac498;
border-right: 1.5px solid #7ac498;
background-color: #e9fbe9;
color: #384338;
border-bottom: 1.5px solid #7ac498;
border-left: 1.5px solid #7ac498;
border-right: 1.5px solid #7ac498;
background-color: #e9fbe9;
color: #384338;
}

.no-data-cell {
Expand Down
36 changes: 32 additions & 4 deletions server/scripts/import-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,26 @@ const gitRun = (args, cwd = gitCloneDirectory) => {
};

const importTestPlanVersions = async transaction => {
const { gitCommitDate } = await readRepo();
await cloneRepo();

// Get list of commits when multiple passed in as
// `<import_cmd> -c "commit1 commit2 commitN ..."`
const commits = args.commit
? args.commit
.trim()
.split(' ')
.filter(el => !!el)
: [];

if (commits.length) {
for (const commit of commits) {
await buildTestsAndCreateTestPlanVersions(commit, { transaction });
}
} else await buildTestsAndCreateTestPlanVersions(null, { transaction });
};

const buildTestsAndCreateTestPlanVersions = async (commit, { transaction }) => {
const { gitCommitDate } = await readCommit(commit);

console.log('Running `npm install` ...\n');
const installOutput = spawn.sync('npm', ['install'], {
Expand Down Expand Up @@ -227,17 +246,26 @@ const importTestPlanVersions = async transaction => {
transaction
});
}

// To ensure build folder is clean when multiple commits are being processed
// to prevent `EPERM` errors
console.log('Running `npm run cleanup` ...\n');
const cleanupOutput = spawn.sync('npm', ['run', 'cleanup'], {
cwd: gitCloneDirectory
});
console.log('`npm run cleanup` output', cleanupOutput.stdout.toString());
};

const readRepo = async () => {
const cloneRepo = async () => {
fse.ensureDirSync(gitCloneDirectory);

console.info('Cloning aria-at repo ...');
spawn.sync('git', ['clone', ariaAtRepo, gitCloneDirectory]);
console.info('Cloning aria-at repo complete.');
};

gitRun(`checkout ${args.commit ?? ariaAtDefaultBranch}`);

const readCommit = async commit => {
gitRun(`checkout ${commit ?? ariaAtDefaultBranch}`);
const gitCommitDate = new Date(gitRun(`log --format=%aI -n 1`));

return { gitCommitDate };
Expand Down
8 changes: 8 additions & 0 deletions server/scripts/populate-test-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ const populateTestDatabase = async transaction => {
transaction
});

await populateFakeTestResults(
19,
new Array(12).fill('completeAndPassing'),
{
transaction
}
);

console.info(
'Successfully populated. Please wait a moment for the process to close.'
);
Expand Down
3 changes: 3 additions & 0 deletions server/scripts/populate-test-data/pg_dump_test_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ INSERT INTO "TestPlanReport" (id, "testPlanVersionId", "createdAt", "markedFinal
INSERT INTO "TestPlanReport" (id, "testPlanVersionId", "createdAt", "markedFinalAt", "atId", "browserId", "vendorReviewStatus") VALUES (16, get_test_plan_version_id(text 'Command Button Example', '2'), '2023-12-13 14:18:23.602-05', '2023-12-14', 1, 2, 'READY');
INSERT INTO "TestPlanReport" (id, "testPlanVersionId", "createdAt", "markedFinalAt", "atId", "browserId", "vendorReviewStatus") VALUES (17, get_test_plan_version_id(text 'Command Button Example', '2'), '2023-12-13 14:18:23.602-05', '2023-12-14', 2, 2, 'READY');
INSERT INTO "TestPlanReport" (id, "testPlanVersionId", "createdAt", "markedFinalAt", "atId", "browserId", "vendorReviewStatus") VALUES (18, get_test_plan_version_id(text 'Command Button Example', '2'), '2023-12-13 14:18:23.602-05', '2023-12-14', 3, 3, 'READY');
INSERT INTO "TestPlanReport" (id, "testPlanVersionId", "createdAt", "atId", "browserId", "vendorReviewStatus") VALUES (19, get_test_plan_version_id(text 'Modal Dialog Example', '2'), '2024-05-14 14:18:23.602-05', 2, 2, 'READY');

--
-- Data for Name: TestPlanVersion; Type: TABLE DATA; Schema: public; Owner: atr
Expand All @@ -89,6 +90,7 @@ UPDATE "TestPlanVersion" SET "phase" = 'CANDIDATE', "draftPhaseReachedAt" = '202
UPDATE "TestPlanVersion" SET "phase" = 'RECOMMENDED', "candidatePhaseReachedAt" = '2022-07-06', "recommendedPhaseTargetDate" = '2023-01-02', "recommendedPhaseReachedAt" = '2023-01-03' WHERE id = get_test_plan_version_id(text 'Checkbox Example (Mixed-State)', '1');
UPDATE "TestPlanVersion" SET "phase" = 'DRAFT', "draftPhaseReachedAt" = '2022-07-06' WHERE id = get_test_plan_version_id(text 'Alert Example', '1');
UPDATE "TestPlanVersion" SET "phase" = 'DRAFT', "draftPhaseReachedAt" = '2023-12-14' WHERE id = get_test_plan_version_id(text 'Command Button Example', '2');
UPDATE "TestPlanVersion" SET "phase" = 'DRAFT', "draftPhaseReachedAt" = '2024-05-14' WHERE id = get_test_plan_version_id(text 'Modal Dialog Example', '2');

--
-- Data for Name: User; Type: TABLE DATA; Schema: public; Owner: atr
Expand Down Expand Up @@ -126,6 +128,7 @@ INSERT INTO "TestPlanRun" (id, "testerUserId", "testPlanReportId", "testResults"
INSERT INTO "TestPlanRun" (id, "testerUserId", "testPlanReportId", "testResults") VALUES (16, 1, 16, '[]');
INSERT INTO "TestPlanRun" (id, "testerUserId", "testPlanReportId", "testResults") VALUES (17, 1, 17, '[]');
INSERT INTO "TestPlanRun" (id, "testerUserId", "testPlanReportId", "testResults") VALUES (18, 1, 18, '[]');
INSERT INTO "TestPlanRun" (id, "testerUserId", "testPlanReportId", "testResults") VALUES (19, 1, 19, '[]');

--
-- Data for Name: CollectionJob; Type: TABLE DATA; Schema: public; Owner: atr
Expand Down
Loading

0 comments on commit ae90bce

Please sign in to comment.