Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed Nov 25, 2024
1 parent bfbbee3 commit 781a97c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ yarn-error.log*

secrets.json

cypress/screenshots
app/frontend/cypress/downloads
app/frontend/cypress/screenshots
app/frontend/cypress/videos

.nx/
Expand Down
11 changes: 8 additions & 3 deletions app/backend/src/updateBaseImagesInS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ export const updateBaseImagesInS3 = async ({
});
}
const hash = commitHash ?? diffId;
if (hash) {
const s3Paths = await getKeysFromS3(hash, bucket);
await replaceImagesInS3(s3Paths, bucket);
if (!hash) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Please provide either a commitHash or a diffId.'
});
}

const s3Paths = await getKeysFromS3(hash, bucket);
await replaceImagesInS3(s3Paths, bucket);
if (commitHash) {
await updateCommitStatus({ owner, repo, commitHash });
}
Expand Down
50 changes: 36 additions & 14 deletions app/frontend/cypress/component/App.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('App', () => {

it('should default to the diff image view of the first spec in the response list', () => {
cy.findByRole('heading', { name: 'large/example' });
cy.findByAltText('diff');
cy.findByAltText('diff').should('be.visible');
cy.findByRole('button', { name: /back-arrow/ }).should('be.disabled');
});

Expand All @@ -64,30 +64,30 @@ describe('App', () => {
});

it('should switch to different image views', () => {
cy.findByAltText('diff');
cy.findByAltText('diff').should('be.visible');
cy.findByRole('button', { name: 'new' }).click();
cy.findByAltText('new');
cy.findByAltText('new').should('be.visible');
cy.findByRole('button', { name: 'base' }).click();
cy.findByAltText('base');
cy.findByAltText('base').should('be.visible');
});

it('should switch between specs and default to diff image for each one', () => {
cy.findByRole('button', { name: /forward-arrow/ }).click();
cy.findByRole('heading', { name: 'small/example' });
cy.findByAltText('diff');
cy.findByAltText('diff').should('be.visible');
cy.findByRole('button', { name: /back-arrow/ }).click();
cy.findByRole('heading', { name: 'large/example' });
cy.findByAltText('diff');
cy.findByAltText('diff').should('be.visible');
});

it('should switch to side-by-side view and back', () => {
cy.findByRole('button', { name: /forward-arrow/ }).click();
cy.findByRole('button', { name: /side-by-side/i }).should('be.enabled');
cy.findByAltText('base');
cy.findByAltText('diff');
cy.findByAltText('new');
cy.findByAltText('base').should('be.visible');
cy.findByAltText('diff').should('be.visible');
cy.findByAltText('new').should('be.visible');
cy.findByRole('button', { name: /single/i }).click();
cy.findByAltText('diff');
cy.findByAltText('diff').should('be.visible');
cy.findByAltText('base').should('not.exist');
cy.findByAltText('new').should('not.exist');
cy.findByRole('button', { name: /side-by-side/i }).should('be.enabled');
Expand Down Expand Up @@ -181,13 +181,13 @@ describe('App', () => {
it('should display the new image with side-by-side view disabled', () => {
cy.findByRole('heading', { name: 'large/new-example' });
cy.findByRole('button', { name: /new/ });
cy.findByAltText('new');
cy.findByAltText('new').should('be.visible');
cy.findByRole('button', { name: /side-by-side/i }).should('be.disabled');
});

it('should show new image with side-by-side view disabled when switching to another spec', () => {
cy.findByRole('button', { name: /forward-arrow/ }).click();
cy.findByAltText('new');
cy.findByAltText('new').should('be.visible');
cy.findByRole('button', { name: /side-by-side/i }).should('be.disabled');
});
});
Expand All @@ -213,9 +213,31 @@ describe('App', () => {
it('should default to diff when no new image was found and the currently selected image is new', () => {
cy.findByRole('heading', { name: 'large/example' });
cy.findByRole('button', { name: /new/ }).click();
cy.findByAltText('new');
cy.findByAltText('new').should('be.visible');
cy.findByRole('button', { name: /forward-arrow/ }).click();
cy.findByAltText('diff');
cy.findByAltText('diff').should('be.visible');
});
});

describe('diffId param case', () => {
beforeEach(() => {
cy.intercept('/trpc/fetchCurrentPage*', req => {
const page = getPageFromRequest(req);
const body = page === 2 ? noNewImagesPage : firstPage;
req.reply(body);
});
cy.mount(
<MemoryRouter
initialEntries={['?diffId=123&bucket=bucket&repo=repo&owner=owner']}
>
<App />
</MemoryRouter>
);
});

it('should use diffId param when commitId not provided', () => {
cy.findByRole('heading', { name: 'large/example' });
cy.findByAltText('diff').should('be.visible');
});
});
});
1 change: 0 additions & 1 deletion app/frontend/cypress/downloads/downloads.html

This file was deleted.

0 comments on commit 781a97c

Please sign in to comment.