Skip to content

Commit

Permalink
Merge pull request #64 from frysztak/release/v0.7.1
Browse files Browse the repository at this point in the history
v0.7.1 into master
  • Loading branch information
frysztak authored Oct 6, 2022
2 parents 087417a + ea877db commit 359e132
Show file tree
Hide file tree
Showing 39 changed files with 2,251 additions and 1,733 deletions.
7 changes: 7 additions & 0 deletions .github/actions/e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
github-token:
description: 'GitHub token'
required: true
codecov-token:
description: 'Codecov.io token'
required: true

runs:
using: 'composite'
Expand All @@ -27,3 +30,7 @@ runs:
env:
CYPRESS_RECORD_KEY: ${{ inputs.cypress-key }}
GITHUB_TOKEN: ${{ inputs.github-token }}

- uses: codecov/codecov-action@v3
with:
token: ${{ inputs.codecov-token }}
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ jobs:
with:
cypress-key: ${{ secrets.CYPRESS_RECORD_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
with:
cypress-key: ${{ secrets.CYPRESS_RECORD_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}

docker:
name: Push to Docker Registry
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
with:
cypress-key: ${{ secrets.CYPRESS_RECORD_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}

docker:
name: Push to Docker Registry
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.1] - 2022-10-06

### Added

- Allow to mark Home collection as read
- Improved UX of when marking article as read

### Changed

- Hide article when changing active collection

### Fixed

- Mark as read: properly refresh home collection

## [0.7.0] - 2022-09-25

### Added
Expand Down Expand Up @@ -180,7 +195,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- The entire app!

[Unreleased]: https://github.com/frysztak/orpington-news/compare/0.7.0...HEAD
[Unreleased]: https://github.com/frysztak/orpington-news/compare/0.7.1...HEAD

[0.7.1]: https://github.com/frysztak/orpington-news/compare/0.7.0...0.7.1

[0.7.0]: https://github.com/frysztak/orpington-news/compare/0.6.4...0.7.0

Expand Down
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export default defineConfig({
feeds_url: process.env.FEEDS_URL,
codeCoverage: {
url: `${process.env.NEXT_PUBLIC_API_URL}/__coverage__`,
exclude: ['**/node_modules/**/*'],
},
},
e2e: {
baseUrl: process.env.APP_URL,
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config);

const buildDSN = (): string => {
const { db_user, db_pass, db_host, db_name, db_port } = config.env;
return `postgres://${db_user}:${db_pass}@${db_host}:${db_port}/${db_name}`;
Expand Down
175 changes: 175 additions & 0 deletions cypress/e2e/feed.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,180 @@ sizes.forEach((size) => {
);
});
});

describe('mark feed as read', () => {
it('from sidebar', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/collections/1/markAsRead'),
}).as('apiMarkAsRead');

cy.addFeedByApi({
title: 'Kent C. Dodds Blog',
url: getFeedUrl('kentcdodds.xml'),
icon: 'Code',
refreshInterval: 120,
});

cy.visit('/');

// all unread
cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getUnreadItems().should('have.length', 3);
});

cy.openDrawerIfExists();
// make collection active
cy.clickCollection('1');
cy.openDrawerIfExists();
// mark as read
cy.clickSidebarAction('1', 'markAsRead');
cy.closeDrawerIfExists();
cy.wait('@apiMarkAsRead').then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
});

cy.openDrawerIfExists();
cy.getBySel('collection-id-1').within(() => {
cy.getBySel('badge').should('not.exist');
});

cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getReadItems().should('have.length', 3);
});
});

it('from collection header', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/collections/1/markAsRead'),
}).as('apiMarkAsRead');

cy.addFeedByApi({
title: 'Kent C. Dodds Blog',
url: getFeedUrl('kentcdodds.xml'),
icon: 'Code',
refreshInterval: 120,
});

cy.visit('/');

// all unread
cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getUnreadItems().should('have.length', 3);
});

// make collection active
cy.openDrawerIfExists();
cy.clickCollection('1');
// mark as read
cy.clickCollectionHeaderMenuAction('markAsRead');

cy.wait('@apiMarkAsRead').then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
});

cy.openDrawerIfExists();
cy.getBySel('collection-id-1').within(() => {
cy.getBySel('badge').should('not.exist');
});

cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getReadItems().should('have.length', 3);
});
});

it('from sidebar, while on home page', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/collections/1/markAsRead'),
}).as('apiMarkAsRead');

cy.intercept({
method: 'GET',
url: getApiPath('/collections/home/items?pageIndex=0'),
}).as('apiGetHomeItems');

cy.addFeedByApi({
title: 'Kent C. Dodds Blog',
url: getFeedUrl('kentcdodds.xml'),
icon: 'Code',
refreshInterval: 120,
});

cy.visit('/');

// all unread
cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getUnreadItems().should('have.length', 3);
});

cy.openDrawerIfExists();
// mark as read
cy.clickSidebarAction('1', 'markAsRead');
cy.closeDrawerIfExists();
cy.wait('@apiMarkAsRead').then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
});

cy.wait('@apiGetHomeItems').then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
});

cy.openDrawerIfExists();
cy.getBySel('collection-id-1').within(() => {
cy.getBySel('badge').should('not.exist');
});

cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getReadItems().should('have.length', 3);
});
});

it('from collection header, while on home page', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/collections/home/markAsRead'),
}).as('apiMarkAsRead');
cy.intercept({
method: 'GET',
url: getApiPath('/collections/home/items?pageIndex=0'),
}).as('apiGetHomeItems');

cy.addFeedByApi({
title: 'Kent C. Dodds Blog',
url: getFeedUrl('kentcdodds.xml'),
icon: 'Code',
refreshInterval: 120,
});

cy.visit('/');

// all unread
cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getUnreadItems().should('have.length', 3);
});

// mark as read
cy.clickCollectionHeaderMenuAction('markAsRead');

cy.wait('@apiMarkAsRead').then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
});

cy.wait('@apiGetHomeItems').then(({ request, response }) => {
expect(response.statusCode).to.eq(200);
});

cy.openDrawerIfExists();
cy.getBySel('collection-id-1').within(() => {
cy.getBySel('badge').should('not.exist');
});

cy.getBySel('collectionItemList').within((itemList) => {
cy.wrap(itemList).getReadItems().should('have.length', 3);
});
});
});
});
});
37 changes: 21 additions & 16 deletions cypress/e2e/login.cy.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { getApiPath } from './utils';

describe('login page', () => {
beforeEach(() => {
cy.signupByApi('end2end', 'end2endpass', 'E2E');
});
const sizes = ['macbook-13', 'iphone-6'];

sizes.forEach((size) => {
describe(`login page, size '${size}'`, () => {
beforeEach(() => {
cy.viewport(size as any);
cy.signupByApi('end2end', 'end2endpass', 'E2E');
});

const baseUrl = Cypress.config('baseUrl');
const baseUrl = Cypress.config('baseUrl');

it('can successfully log in', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/auth/login'),
}).as('apiAuthLogin');
it('can successfully log in', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/auth/login'),
}).as('apiAuthLogin');

cy.visit('/login');
cy.getBySel('username').type('end2end');
cy.getBySel('password').type('end2endpass');
cy.getBySel('submit').click();
cy.visit('/login');
cy.getBySel('username').type('end2end');
cy.getBySel('password').type('end2endpass');
cy.getBySel('submit').click();

cy.wait('@apiAuthLogin').its('response.statusCode').should('eq', 200);
cy.url().should('equal', `${baseUrl}/`);
cy.wait('@apiAuthLogin').its('response.statusCode').should('eq', 200);
cy.url().should('equal', `${baseUrl}/`);
});
});
});
49 changes: 35 additions & 14 deletions cypress/e2e/signup.cy.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import { getApiPath } from './utils';

describe('signup page', () => {
it('can successfully sign up', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/auth/register'),
}).as('apiAuthRegister');
const sizes = ['macbook-13', 'iphone-6'];

cy.visit('/signup');
cy.getBySel('username').type('end2end');
cy.getBySel('displayName').type('E2E');
cy.getBySel('password').type('end2endpass');
cy.getBySel('passwordConfirm').type('end2endpass');
cy.getBySel('submit').click();
sizes.forEach((size) => {
describe(`signup page, size '${size}'`, () => {
beforeEach(() => {
cy.viewport(size as any);
});

cy.wait('@apiAuthRegister').its('response.statusCode').should('eq', 200);
cy.url().should('include', '/login');
it('can successfully sign up', () => {
cy.intercept({
method: 'POST',
url: getApiPath('/auth/register'),
}).as('apiAuthRegister');

cy.visit('/signup');
cy.getBySel('username').type('end2end');
cy.getBySel('displayName').type('E2E');
cy.getBySel('avatarBadgeUpload').should('be.visible');
cy.getBySel('avatarBadgeDelete').should('not.exist');
cy.getBySel('avatarInput').selectFile(
{
contents: 'cypress/fixtures/media/avatar.jpg',
fileName: 'av.jpg',
mimeType: 'image/jpeg',
},
{ force: true }
);
cy.getBySel('avatar').find('img').should('be.visible');
cy.getBySel('avatarBadgeUpload').should('not.exist');
cy.getBySel('avatarBadgeDelete').should('be.visible');
cy.getBySel('password').type('end2endpass');
cy.getBySel('passwordConfirm').type('end2endpass');
cy.getBySel('submit').click();

cy.wait('@apiAuthRegister').its('response.statusCode').should('eq', 200);
cy.url().should('include', '/login');
});
});
});
5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

Binary file added cypress/fixtures/media/avatar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions cypress/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ declare namespace Cypress {
): Chainable<JQuery<HTMLElement>>;

openDrawerIfExists(): Chainable<JQuery<HTMLElement>>;
closeDrawerIfExists(): Chainable<JQuery<HTMLElement>>;
getReadItems(): Chainable<JQuery<HTMLElement>>;
getUnreadItems(): Chainable<JQuery<HTMLElement>>;

clickCollection(id: string): Chainable<JQuery<HTMLElement>>;
clickSidebarAction(
collectionId: string,
action: string
): Chainable<JQuery<HTMLElement>>;

clickCollectionHeaderMenuAction(
action: string
): Chainable<JQuery<HTMLElement>>;

/**
* Signs user up by using API request
Expand Down
Loading

0 comments on commit 359e132

Please sign in to comment.