Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QC testing trigger #262

Merged
merged 8 commits into from
Feb 4, 2025
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
72 changes: 72 additions & 0 deletions .github/workflows/gsheet_qc_trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Google Sheets Quality Control Trigger

on:
schedule:
- cron: "0 5 * * *"

workflow_dispatch:

jobs:
fetch-and-process-gsheet:
runs-on: ubuntu-latest
outputs:
qc-entry: ${{ steps.get_input.outputs.result }}
steps:
- uses: actions/github-script@v7
id: "get_input"
env:
SPREADSHEET_ID: ${{ secrets.SPREADSHEET_ID }}
with:
result-encoding: string
script: |
const { SPREADSHEET_ID } = process.env;
const keywords = ['Date', 'Datasets', 'Keywords', 'Facets']
const GID = '0';
const response = await fetch(`https://docs.google.com/spreadsheets/d/${SPREADSHEET_ID}/gviz/tq?tqx=out:json&tq&gid=${GID}`);
const txt = await response.text();
const jsonString = txt.match(/(?<="table":).*(?=}\);)/g)[0];
const json = JSON.parse(jsonString);
let rawTable = [];
let tableData = [];
json.rows.forEach((r) => {
let row = [];
r.c.forEach((cel) => {
let value = '';
try {
value = cel.f ? cel.f : cel.v;
} catch (e) {
value = '';
}
row.push(value);
});
rawTable.push(row);
});
rawTable.forEach((row) => {
let mappedData = {};
keywords.forEach((keyword, index) => {
mappedData[keyword] = row[index]
});
tableData.push(mappedData);
});
return JSON.stringify(tableData.filter((data) => {
return data['Date'] === new Date().toLocaleDateString('en-US')
}).slice(-1)[0]);

trigger-qc-testing-workflow:
runs-on: ubuntu-latest
needs: fetch-and-process-gsheet
if: fromJson(needs.fetch-and-process-gsheet.outputs.qc-entry).Date
env:
Keywords: ${{ fromJson(needs.fetch-and-process-gsheet.outputs.qc-entry).Keywords }}
Facets: ${{ fromJson(needs.fetch-and-process-gsheet.outputs.qc-entry).Facets }}
Datasets: ${{ fromJson(needs.fetch-and-process-gsheet.outputs.qc-entry).Datasets }}
steps:
- name: Print data entry
run: |
echo "${{ needs.fetch-and-process-gsheet.outputs.qc-entry }}"

- name: Invoke workflow with inputs
uses: benc-uk/workflow-dispatch@v1
with:
workflow: quality_control_cypress.yml
inputs: '{ "SEARCH_KEYWORDS": "${{ env.Keywords }}", "FILTER_FACETS": "${{ env.Facets }}", "DATASET_IDS": "${{ env.Datasets }}" }'
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_production_cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Scheduled Production Cypress Testing

on:
schedule:
- cron: "0 0 * * 1"
- cron: "0 5 * * 1"

workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_staging_cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Scheduled Staging Cypress Testing

on:
schedule:
- cron: "0 0 * * 1"
- cron: "0 5 * * 1"

workflow_dispatch:

Expand Down
6 changes: 3 additions & 3 deletions tests/cypress/e2e/datasets/datasetInfo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ datasetIds.forEach((datasetId) => {
})
cy.get('@doiLink').invoke('attr', 'href').then((href) => {
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
expect(resp.redirects, 'Redirect should exist').to.have.length(1)
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
})
})
// Check 'View other version' directs to Versions tab
Expand All @@ -94,9 +94,9 @@ datasetIds.forEach((datasetId) => {
cy.wrap($content).contains('project(s):').siblings('.mt-8').should(($project) => {
expect($project, 'Project title should exist').to.exist
})
cy.get('.mt-8 > a').then(($link) => {
cy.get('.mt-8 > a').each(($link, index) => {
const title = $link.children().text()
cy.get('.mt-8 > a').click()
cy.get('.mt-8 > a').eq(index).click()
cy.waitForPageLoading()
cy.url().should((url) => {
expect(url, 'URL should contain correct slug').to.contain('/about/projects/')
Expand Down
45 changes: 24 additions & 21 deletions tests/cypress/e2e/datasets/detailtabs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ datasetIds.forEach((datasetId) => {
})
cy.get('@links').each(($link) => {
cy.wrap($link).invoke('attr', 'href').then((href) => {
cy.request(href).then((resp) => {
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
const title = $title.text().trim().replaceAll(' ', '.*')
const contributor = $contributor.text().replace(/Contributors:/i, '').split(',').map(name => name.trim().replace(' ', '.*'))
const contributorReversed = contributor.map(name => name.split(' ').reverse().join('.*'))
const regex = new RegExp('\(' + title + '|' + contributor.join('|') + '|' + contributorReversed.join('|') + '\)', 'gi')
expect(resp.status).to.eq(200)
expect(resp.body, 'Protocol link should make sense').to.match(regex)
const match = resp.body.match(regex) || []
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
expect(match, 'Protocol link should make sense').to.have.length.greaterThan(0)
})
})
})
Expand Down Expand Up @@ -216,7 +217,7 @@ datasetIds.forEach((datasetId) => {
cy.get(':nth-child(1) > p > .el-dropdown > .filter-dropdown').click()
cy.get('.el-dropdown-menu > .el-dropdown-menu__item:visible').contains('View All').click()
cy.waitForBrowserLoading()
cy.get('.cell').contains($title.text()).siblings('.property-table').contains(/Principal Investigator/i).siblings().as('PI')
cy.get('.cell').contains($title.text().replace(/\s\s+/g, ' ')).siblings('.property-table').contains(/Principal Investigator/i).siblings().as('PI')
cy.get('@PI').then(($pi) => {
const author = $content.text().normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase()
const pi = $pi.text().normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase()
Expand Down Expand Up @@ -247,23 +248,25 @@ datasetIds.forEach((datasetId) => {
cy.get('.dataset-about-info .label4').contains(/Associated project[(]s[)]/i).parent().as('project')
cy.get('.dataset-about-info .label4').contains(/Institution[(]s[)]/i).parent().as('institutions')
cy.get('@awards').then(($award) => {
const award = $award.text().replace('Award(s):', '').trim()
const awards = $award.text().replace('Award(s):', '').split(',').map((award) => award.trim())
cy.get('@project').then(($project) => {
const project = $project.text().replace('Associated project(s):', '').trim()
const projects = $project.text().replace('Associated project(s):', '').split(',').map((project) => project.trim())
cy.get('@institutions').then(($institution) => {
const institution = $institution.text().replace('Institution(s):', '').trim()
cy.wrap($project).find('a').click()
cy.waitForPageLoading()
cy.get('.row > .heading2', { timeout: 60000 }).should(($title) => {
expect($title, 'Project title should be the same').to.contain(project)
})
cy.get('span.label4').parent().contains(/INSTITUTION[(]S[)]/i).should(($institution) => {
expect($institution, 'Institution should be the same').to.contain(institution)
})
cy.get('.link1').should(($award) => {
expect(award, 'Award should be the same').to.include($award.text().trim())
const institutions = $institution.text().replace('Institution(s):', '').split(',').map((institution) => institution.trim())
cy.get('.dataset-about-info .label4').contains(/Associated project[(]s[)]/i).parent().find('a').each(($link, index) => {
cy.get('.dataset-about-info .label4').contains(/Associated project[(]s[)]/i).parent().find('a').eq(index).click()
cy.waitForPageLoading()
cy.get('.row > .heading2', { timeout: 60000 }).should(($title) => {
expect($title, 'Project title should be the same').to.contain(projects[index])
})
cy.get('span.label4').parent().contains(/INSTITUTION[(]S[)]/i).should(($institution) => {
expect($institution, 'Institution should be the same').to.contain(institutions[index])
})
cy.get('.link1').should(($award) => {
expect(awards[index], 'Award should be the same').to.include($award.text().trim())
})
cy.backToDetailPage(datasetId)
})
cy.backToDetailPage(datasetId)
})
})
})
Expand Down Expand Up @@ -510,8 +513,8 @@ datasetIds.forEach((datasetId) => {
expect($link, 'Citation link should have doi href').to.have.attr('href').to.contain('doi.org')
expect($link, 'Citation link should open a new tab').to.have.attr('target').to.contain('blank')
cy.wrap($link).invoke('attr', 'href').then((href) => {
cy.request(href).then((resp) => {
expect(resp.status).to.eq(200)
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
})
})
})
Expand Down Expand Up @@ -559,7 +562,7 @@ datasetIds.forEach((datasetId) => {
cy.get('.version-table > .table-rows > :nth-child(5) > a').each(($doi) => {
cy.wrap($doi).invoke('attr', 'href').then((href) => {
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
expect(resp.redirects, 'Redirect should exist').to.have.length(1)
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/datasets/imagegallery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ datasetIds.forEach((datasetId) => {
const link = stub.args[0][0]
expect(link.length, 'Button should contain external resource link').to.be.greaterThan(0)
})
cy.then(()=>{
cy.then(() => {
windowOpenStub.restore()
})
})
Expand Down
4 changes: 2 additions & 2 deletions tests/cypress/e2e/datasets/surfaceinsearch.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ datasetIds.forEach((datasetId) => {
cy.get('.el-col-sm-16 > .heading2').then(($title) => {
cy.get('.similar-datasets-container > .px-8').then(($similar) => {
if ($similar.text().includes('Type:')) {
const title = $title.text()
const title = $title.text().replace(/\s\s+/g, ' ')
const titleList = title.split(' ')
const input = titleList.slice(0, randomInteger(1, titleList.length - 1)).join(' ')
cy.wrap($similar).contains(/TYPE:/i).siblings('.facet-button-container').click()
Expand Down Expand Up @@ -55,7 +55,7 @@ datasetIds.forEach((datasetId) => {
cy.get(':nth-child(1) > p > .el-dropdown > .filter-dropdown').click()
cy.get('.el-dropdown-menu > .el-dropdown-menu__item:visible').contains('View All').click()
cy.waitForBrowserLoading()
cy.get('.cell').contains($title.text()).should(($dTitle) => {
cy.get('.cell').contains($title.text().replace(/\s\s+/g, ' ')).should(($dTitle) => {
expect($dTitle, 'Dataset title should exist in search results').to.exist
})
cy.backToDetailPage(datasetId)
Expand Down
Loading