diff --git a/.github/workflows/stg_web_svc_merge.yml b/.github/workflows/stg_web_svc_merge.yml index 1a16e1cf8b..a801207cf6 100644 --- a/.github/workflows/stg_web_svc_merge.yml +++ b/.github/workflows/stg_web_svc_merge.yml @@ -3,7 +3,7 @@ name: Web service staging CD on: push: branches: - - master + - 1689-web-validator-app-consumes-execution_resultsjson workflow_dispatch: env: diff --git a/web/client/cypress/e2e/error_messages.cy.js b/web/client/cypress/e2e/error_messages.cy.js index 14c8039ab2..5e754c9859 100644 --- a/web/client/cypress/e2e/error_messages.cy.js +++ b/web/client/cypress/e2e/error_messages.cy.js @@ -1,28 +1,27 @@ /// -const url = 'https://developers.google.com/static/transit/gtfs/examples/sample-feed.zip'; +const url = + 'https://developers.google.com/static/transit/gtfs/examples/sample-feed.zip'; const jobId = '8f6be6fb-1fee-41f8-b401-b2b4b552e177-sample'; context('GTFS Validator - Confirm error messaging', () => { - it('Confirm error "Error authorizing upload"', () => { // Setup intercept aliases cy.intercept( 'POST', - `${Cypress.env("PUBLIC_CLIENT_API_ROOT")}/create-job`, + `${Cypress.env('PUBLIC_CLIENT_API_ROOT')}/create-job`, { forceNetworkError: true } - ) - .as('createJob'); + ).as('createJob'); - cy.visit('/') + cy.visit('/'); // Upload .zip file - cy.get('input#file') - .selectFile('cypress/fixtures/sample-feed.zip', { force: true }); + cy.get('input#file').selectFile('cypress/fixtures/sample-feed.zip', { + force: true, + }); // Submit - cy.get('button[type=submit]') - .click(); + cy.get('button[type=submit]').click(); // Wait for response error cy.wait('@createJob'); @@ -39,34 +38,33 @@ context('GTFS Validator - Confirm error messaging', () => { 'PUT', `https://storage.googleapis.com/stg-validator-user-uploads/${jobId}/gtfs-job.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256`, { forceNetworkError: true } - ) - .as('putFile'); + ).as('putFile'); cy.intercept( 'POST', - `${Cypress.env("PUBLIC_CLIENT_API_ROOT")}/create-job`, + `${Cypress.env('PUBLIC_CLIENT_API_ROOT')}/create-job`, (req) => { req.reply({ statusCode: 200, - statusMessage: "OK", + statusMessage: 'OK', headers: { - "access-control-allow-origin": '*', - "Access-Control-Allow-Credentials": "true", + 'access-control-allow-origin': '*', + 'Access-Control-Allow-Credentials': 'true', }, body: { jobId: jobId, - url: `https://storage.googleapis.com/stg-validator-user-uploads/${jobId}/gtfs-job.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256` - } + url: `https://storage.googleapis.com/stg-validator-user-uploads/${jobId}/gtfs-job.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256`, + }, }); } - ) - .as('createJob'); + ).as('createJob'); - cy.visit('/') + cy.visit('/'); // Upload .zip file - cy.get('input#file') - .selectFile('cypress/fixtures/sample-feed.zip', { force: true }); + cy.get('input#file').selectFile('cypress/fixtures/sample-feed.zip', { + force: true, + }); // Submit cy.get('button[type=submit]').click(); @@ -82,36 +80,71 @@ context('GTFS Validator - Confirm error messaging', () => { .and('contain.text', 'Error uploading file'); }); + // it('Confirm error "Error processing report"', () => { + // // Setup intercept aliases + // cy.intercept( + // 'POST', + // `${Cypress.env('PUBLIC_CLIENT_API_ROOT')}/create-job`, + // (req) => { + // req.reply({ + // statusCode: 200, + // statusMessage: 'OK', + // headers: { + // 'access-control-allow-origin': '*', + // 'Access-Control-Allow-Credentials': 'true', + // }, + // body: { + // jobId: jobId, + // url: `https://storage.googleapis.com/stg-validator-user-uploads/${jobId}/gtfs-job.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256`, + // }, + // }); + // } + // ).as('createJob'); + + let shouldFail = false; + it('Confirm error "Error processing report"', () => { // Setup intercept aliases cy.intercept( 'POST', - `${Cypress.env("PUBLIC_CLIENT_API_ROOT")}/create-job`, + `${Cypress.env('PUBLIC_CLIENT_API_ROOT')}/create-job`, (req) => { - req.reply({ - statusCode: 200, - statusMessage: "OK", - headers: { - "access-control-allow-origin": '*', - "Access-Control-Allow-Credentials": "true", - }, - body: { - jobId: jobId, - url: `https://storage.googleapis.com/stg-validator-user-uploads/${jobId}/gtfs-job.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256` - } - }); + if (shouldFail) { + req.reply({ + statusCode: 500, + statusMessage: 'Internal Server Error', + headers: { + 'access-control-allow-origin': '*', + 'Access-Control-Allow-Credentials': 'true', + }, + body: { + error: 'Error processing report.', + }, + }); + } else { + req.reply({ + statusCode: 200, + statusMessage: 'OK', + headers: { + 'access-control-allow-origin': '*', + 'Access-Control-Allow-Credentials': 'true', + }, + body: { + jobId: jobId, + url: `https://storage.googleapis.com/stg-validator-user-uploads/${jobId}/gtfs-job.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256`, + }, + }); + } } - ) - .as('createJob'); + ).as('awaitJob'); cy.intercept( 'HEAD', - `${Cypress.env("PUBLIC_CLIENT_REPORTS_ROOT")}/*/report.html`, + `${Cypress.env('PUBLIC_CLIENT_REPORTS_ROOT')}/*/report.html`, { forceNetworkError: true } - ) - .as('awaitJob'); + ).as('awaitJob'); - cy.visit('/') + cy.visit('/'); // Enter URL to .zip file cy.get('input#url').type(url); @@ -132,33 +165,35 @@ context('GTFS Validator - Confirm error messaging', () => { it('Confirm error "HTTP Error: 404"', () => { // Setup intercept aliases - cy.intercept( - 'rules.json', - (req) => { - req.reply({ - statusCode: 404, - headers: { - "access-control-allow-origin": '*', - "Access-Control-Allow-Credentials": "true", - }, - }); - } - ) - .as('getDocMarkdown'); - - cy.visit('/') + cy.intercept('rules.json', (req) => { + req.reply({ + statusCode: 404, + headers: { + 'access-control-allow-origin': '*', + 'Access-Control-Allow-Credentials': 'true', + }, + }); + }).as('getDocMarkdown'); + + cy.visit('/'); // Click "See Documentation" button cy.get('a:contains("See Documentation")').click(); - - cy.location('pathname', {timeout: 60000}).should('include', '/rules.html'); + + cy.location('pathname', { timeout: 60000 }).should( + 'include', + '/rules.html' + ); // Confirm error content cy.get('.container .markdown') .should('be.visible') .within((div) => { cy.get('h1').should('contain.text', 'HTTP Error: 404'); - cy.get('p').should('contain.text', 'There was a problem loading the rules file.'); - }) + cy.get('p').should( + 'contain.text', + 'There was a problem loading the rules file.' + ); + }); }); });