Skip to content

Commit

Permalink
refactor: Better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
riceball-tw committed Jun 21, 2024
1 parent 636a19e commit bc55c0f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 61 deletions.
51 changes: 51 additions & 0 deletions cypress/e2e/post/post-[...slug].cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
describe('Post is effective', () => {
beforeEach(() => {
cy.visit('/post/demo-post');
});

it('Header should visible and working', () => {
cy.dataCy('post-icon-container').find('svg').should('exist');
cy.dataCy('post-title').should('have.prop', 'tagName', 'H1').should('not.be.empty');
cy.dataCy('post-subtitle').should('not.be.empty');
cy.dataCy('category').should('not.be.empty');
cy.dataCy('tag-link').each(($link) => {
cy.wrap($link).should('not.be.empty');
cy.request('GET', $link.attr('href')).its('status').should('eq', 200);
});
});

it('Comment should load', () => {
cy.dataCy('post-comment').scrollIntoView();
cy.dataCy('post-comment').should('not.be.empty');
});

it('Heading links should visible and working', () => {
cy.dataCy('post-content')
.find(
'h2 .rehype-auto-link, h3 .rehype-auto-link, h4 .rehype-auto-link, h5 .rehype-auto-link, h6 .rehype-auto-link',
)
.each(($link) => {
cy.request('GET', $link.attr('href')).its('status').should('eq', 200);
});
});

it('Series recommendation should visible and working', () => {
cy.dataCy('series-summary').should('not.be.empty');
cy.dataCy('post-title')
.invoke('text')
.then((postTitle) => {
cy.wrap(postTitle).as('postTitle');
});

cy.dataCy('series-active')
.should('have.length', 1)
.invoke('text')
.then((activeSeriesTitle) => {
cy.wrap(activeSeriesTitle).as('activeSeriesTitle');
});

Promise.all([cy.get('@postTitle'), cy.get('@activeSeriesTitle')]).then(([postTitle, activeSeriesTitle]) => {
expect(postTitle).to.equal(activeSeriesTitle);
});
});
});
19 changes: 0 additions & 19 deletions cypress/e2e/post/post-all.cy.ts

This file was deleted.

52 changes: 10 additions & 42 deletions cypress/e2e/post/post.cy.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
describe('Post is effective', () => {
describe('All post page is effective', () => {
beforeEach(() => {
cy.visit('/post/demo-post');
cy.visit('/post/');
});

it('Header should visible and working', () => {
cy.dataCy('post-icon-container').find('svg').should('exist');
cy.dataCy('post-title').should('have.prop', 'tagName', 'H1').should('not.be.empty');
cy.dataCy('post-subtitle').should('not.be.empty');
cy.dataCy('category').should('not.be.empty');
cy.dataCy('tag-link').each(($link) => {
cy.wrap($link).should('not.be.empty');
cy.request('GET', $link.attr('href')).its('status').should('eq', 200);
});
});

it('Comment should load', () => {
cy.dataCy('post-comment').scrollIntoView();
cy.dataCy('post-comment').should('not.be.empty');
});

it('Heading links should visible and working', () => {
cy.dataCy('post-content')
.find(
'h2 .rehype-auto-link, h3 .rehype-auto-link, h4 .rehype-auto-link, h5 .rehype-auto-link, h6 .rehype-auto-link',
)
.each(($link) => {
it('Post taxonomy links should work', () => {
cy.dataCy('categories-link')
.should('be.visible')
.then(($link) => {
cy.request('GET', $link.attr('href')).its('status').should('eq', 200);
});
});

it('Series recommendation should visible and working', () => {
cy.dataCy('series-summary').should('not.be.empty');
cy.dataCy('post-title')
.invoke('text')
.then((postTitle) => {
cy.wrap(postTitle).as('postTitle');
});

cy.dataCy('series-active')
.should('have.length', 1)
.invoke('text')
.then((activeSeriesTitle) => {
cy.wrap(activeSeriesTitle).as('activeSeriesTitle');
cy.dataCy('tags-link')
.should('be.visible')
.then(($link) => {
cy.request('GET', $link.attr('href')).its('status').should('eq', 200);
});

Promise.all([cy.get('@postTitle'), cy.get('@activeSeriesTitle')]).then(([postTitle, activeSeriesTitle]) => {
expect(postTitle).to.equal(activeSeriesTitle);
});
});
});

0 comments on commit bc55c0f

Please sign in to comment.