Skip to content

Commit

Permalink
E2E test at blog root route's header (#92)
Browse files Browse the repository at this point in the history
* chore: rename blog cypress file and directory

* test: append more test at root routes header function
  • Loading branch information
hyesungoh authored Jul 10, 2022
1 parent a7501e5 commit adc8872
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
7 changes: 0 additions & 7 deletions apps/blog/cypress/e2e/main.spec.ts

This file was deleted.

52 changes: 52 additions & 0 deletions apps/blog/cypress/e2e/root/header.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
describe('root - header', () => {
it('should has header', () => {
cy.visit('/');
cy.get('header').should('be.visible');
});

it('should navigate to root when click lever 1 heading', () => {
cy.get('h1').click();
cy.url().should('eq', Cypress.config().baseUrl);
});

const THEME_SWITCH_LABEL = 'theme switch';
const GET_THEME_SWITCH_BY_LABEL = `[aria-label="${THEME_SWITCH_LABEL}"]`;

it('should visible theme toggle switch at header', () => {
cy.get('header').within(() => {
cy.get(GET_THEME_SWITCH_BY_LABEL).should('be.visible');
});
});

it('should toggle theme when click theme toggle switch', () => {
// NOTE: visit with prefer white mode
cy.visit('/', {
onBeforeLoad: win => {
cy.stub(win, 'matchMedia')
.withArgs('(prefers-color-scheme: dark)')
.returns({ matches: false, addListener: () => {}, removeListener: () => {} });
},
});

cy.get('body').then($body => {
const lightBgColor = $body.css('background-color');

cy.get(GET_THEME_SWITCH_BY_LABEL).click();
cy.get('body').should('have.css', 'background-color').and('not.eq', lightBgColor);
});
});

it('should visible kbar button at header', () => {
cy.get('header').within(() => {
cy.get('button').should('be.visible');
});
});

it('should render kbar menu when click kbar button', () => {
cy.get('header').within(() => {
cy.get('button').click();
});

cy.get('input').should('be.visible');
});
});

2 comments on commit adc8872

@vercel
Copy link

@vercel vercel bot commented on adc8872 Jul 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

comet-land-blog – ./apps/blog

comet-land-blog-git-main-hyesungoh.vercel.app
comet-land-blog-hyesungoh.vercel.app
comet-land-blog.vercel.app

@vercel
Copy link

@vercel vercel bot commented on adc8872 Jul 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

comet-land-resume – ./apps/resume

comet-land-resume-hyesungoh.vercel.app
comet-land-resume-git-main-hyesungoh.vercel.app
comet-land-resume.vercel.app

Please sign in to comment.