Skip to content

Commit

Permalink
Merge branch 'master' into tools_testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
reachaadrika authored Aug 18, 2023
2 parents 3a641a7 + 777f75a commit ef9591f
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 50 deletions.
45 changes: 39 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@

---

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-52-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![Netlify Status](https://api.netlify.com/api/v1/badges/b2137407-b765-46c4-95b5-a72d9b1592ab/deploy-status)](https://app.netlify.com/sites/asyncapi-website/deploys)
<br/>
<p align="center">
<a href="https://github.com/asyncapi/website/graphs/contributors" alt="AsyncAPI GitHub website contributors">
<img src="https://img.shields.io/github/contributors/asyncapi/website?color=orange" />
</a>
<a href="https://github.com/asyncapi/website/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22" alt="Good First AsyncAPI issue">
<img src="https://img.shields.io/github/issues/asyncapi/website/good%20first%20issue.svg?color=%23DDDD00" />
</a>
<a href="https://asyncapi.slack.com/" alt="AsyncAPI Slack">
<img src="https://img.shields.io/badge/[email protected]?logo=slack&color=yellow" />
</a>
<a href="https://app.netlify.com/sites/asyncapi-website/deploys">
<img src="https://api.netlify.com/api/v1/badges/b2137407-b765-46c4-95b5-a72d9b1592ab/deploy-status" />
</a>
<a href="https://github.com/asyncapi/website" alt="AsyncAPI Apache License">
<img src="https://img.shields.io/github/license/asyncapi/website.svg" />
</a>
</p>

## Overview

Expand Down Expand Up @@ -140,7 +153,27 @@ This repository has the following structure:
└── tailwind.config.js # TailwindCSS configuration file
```

## Contributors
## Connect with AsyncAPI Community

<p align="left">
<a href="https://asyncapi.slack.com/" target="blank">
<img align="center" src="https://img.icons8.com/color/48/null/slack-new.png" alt="AsyncAPI Slack" height="30" width="40" />
</a>
<a href="https://twitter.com/asyncapispec" target="blank">
<img align="center" src="https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/twitter.svg" alt="AsyncAPI Twitter" height="30" width="40" />
</a>
<a href="https://www.linkedin.com/company/asyncapi" target="blank">
<img align="center" src="https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/linked-in-alt.svg" alt="AsyncAPI LinkedIn" height="30" width="40" />
</a>
<a href="https://www.youtube.com/c/asyncapi" target="blank">
<img align="center" src="https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/youtube.svg" alt="AsyncAPI YouTube" height="30" width="40" />
</a>
<a href="https://www.twitch.tv/asyncapi" target="blank">
<img align="center" src="https://raw.githubusercontent.com/rahuldkjain/github-profile-readme-generator/master/src/images/icons/Social/twitch.svg" alt="AsyncAPI Twitch" height="30" width="40" />
</a>
</p>

## AsyncAPI Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Expand Down
1 change: 1 addition & 0 deletions components/campaigns/AnnoucementHero.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import AnnouncementRemainingDays from './AnnouncementRamainingDays'

function shouldShowBanner(cfpDeadline) {
const currentDate = new Date(); // Get the current date
console.log(currentDate)
const deadline = new Date(cfpDeadline); // Convert the cfpDeadline string to a Date object

// Check if the current date is after the deadline
Expand Down
2 changes: 1 addition & 1 deletion components/helpers/applyFilter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function sortFilter(arr) {
export function sortFilter(arr) {
return arr.sort((a, b) => {
if (a.value < b.value) {
return -1;
Expand Down
14 changes: 7 additions & 7 deletions config/meetings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
[
{
"title": "AsyncAPI x Google Season of Doc's 2023",
"calLink": "https://www.google.com/calendar/event?eid=Yzdyb2F1c3RjOXVvcTh2NXFiZGpyNjgzN3MgY19xOXRzZWlnbG9tZHNqNm5qdWh2YnB0czExY0Bn",
"url": "https://github.com/asyncapi/community/issues/692",
"banner": "https://user-images.githubusercontent.com/66913810/234268392-10a4c02d-60e6-46ec-abcc-74c5aa6088dd.png",
"date": "2023-05-09T16:00:00.000Z"
},
{
"title": "Community Health in Open-source",
"calLink": "https://www.google.com/calendar/event?eid=ZTNtYXFuN2d2bzZsMzBuOHYyc2kxY2ltb2sgY19xOXRzZWlnbG9tZHNqNm5qdWh2YnB0czExY0Bn",
Expand Down Expand Up @@ -222,5 +215,12 @@
"url": "https://github.com/asyncapi/community/issues/846",
"banner": "https://user-images.githubusercontent.com/40604284/260698957-92e0b7ab-c4db-484b-9d2a-e91b05a3437e.png",
"date": "2023-08-31T14:00:00.000Z"
},
{
"title": "Spec 3.0 Meeting",
"calLink": "https://www.google.com/calendar/event?eid=Y281MHE2dGo1ZmE1cmtobmtyOGYzb3VsazAgY19xOXRzZWlnbG9tZHNqNm5qdWh2YnB0czExY0Bn",
"url": "https://github.com/asyncapi/community/issues/847",
"banner": "",
"date": "2023-08-23T16:00:00.000Z"
}
]
12 changes: 6 additions & 6 deletions config/newsroom_videos.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[
{
"image_url": "https://i.ytimg.com/vi/3shCvupVt_4/hqdefault.jpg",
"title": "Spec 3 Docs Meeting",
"description": "https://github.com/asyncapi/community/issues/818.",
"videoId": "3shCvupVt_4"
},
{
"image_url": "https://i.ytimg.com/vi/1tyyLGAicyE/hqdefault.jpg",
"title": "Community Meeting (August 8th 2023)",
Expand All @@ -22,11 +28,5 @@
"title": "Design meeting #2",
"description": "Meeting issue: https://github.com/asyncapi/community/issues/800 Summary: Here's a summary of what we discussed: * Fran and ...",
"videoId": "GAjlJFXjMh8"
},
{
"image_url": "https://i.ytimg.com/vi/WlD5rqmfezw/hqdefault.jpg",
"title": "Open Standards and Private Products: A DevRel&#39;s Dream or Nightmare",
"description": "We are discussing the impact of open standards and working with private products as a DevRel.",
"videoId": "WlD5rqmfezw"
}
]
4 changes: 2 additions & 2 deletions cypress/test/Modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Modal', () => {
const onModalClose = cy.stub().as('onModalClose');
mount(<Modal title="Test Modal" onModalClose={onModalClose} />);

cy.get('[data-testid="Modal-close"]').click();
cy.get('[data-testid="Modal-close"]').click({force : true});

cy.get('@onModalClose').should('have.been.calledOnce');
});
Expand All @@ -17,7 +17,7 @@ describe('Modal', () => {
const onModalClose = cy.stub().as('onModalClose');
mount(<Modal title="Test Modal" onModalClose={onModalClose} />);

cy.get('.backdrop-blur').click();
cy.get('.backdrop-blur').click({force : true});

cy.get('@onModalClose').should('have.been.calledOnce');
});
Expand Down
33 changes: 17 additions & 16 deletions cypress/test/campaignTests/AnnouncementHero.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@ import React from 'react';
import { mount } from '@cypress/react';
import AnnouncementHero from '../../../components/campaigns/AnnoucementHero';
beforeEach(() => {
const mockDate = new Date('2023-05-01T00:00:00Z');
cy.clock(mockDate.getTime());
mount(<AnnouncementHero />);
});


describe('AnnouncementHero Component', () => {
it('should render the component when the date is within the valid range', () => {
// Set the current date to May
const mockDate = new Date('2023-05-01T00:00:00Z');
cy.clock(mockDate.getTime());
// Assert that the component is rendered
//check for background color
cy.get('[data-testid="AnnouncementHero-main-div"]').should('have.class', 'bg-gray-50');
const mockDate = new Date(2021, 10, 12).getTime();
cy.clock(mockDate);
cy.get('[data-testid="AnnouncementHero-main-div"]').should('exist');
});

//check if announcement rendered is small or large .
it('should render a small announcement when "small" prop is true', () => {
mount(<AnnouncementHero small />);
cy.get('[data-testid="AnnouncementHero-main-div"]').should('have.class', 'mb-4');
});

it('should display the correct event information', () => {
const mockDate = new Date('2023-05-01T00:00:00Z');
cy.clock(mockDate.getTime());
// Assert the event details
cy.get('[data-testid="AnnouncementHero-main-div"]').contains('AsyncAPI Conf on Tour 2023').should('exist');
cy.get('[data-testid="AnnouncementHero-main-div"]').contains('London Edition').should('exist');
cy.get('[data-testid="AnnouncementHero-main-div"]').contains('20th of September, 2023 | London, UK').should('exist');
cy.contains('Submit a session').should('exist');
cy.get('[data-testid="Paragraph-test"]').should('exist');
cy.get('h2').should('exist');
cy.get('h3').should('exist');

});

it('should have a link to submit a session', () => {
const mockDate = new Date('2023-05-01T00:00:00Z');
cy.clock(mockDate.getTime());
// Assert the link
cy.get('[data-testid="AnnouncementHero-submit-session"]').should('have.attr', 'href', 'https://conference.asyncapi.com/')
cy.get('[data-testid="Button-link"]').should('have.attr', 'href', 'https://conference.asyncapi.com/')
.should('have.attr', 'target', '_blank')
.contains('Submit a session');
});

//check if announcement rendered is small or large .
it('should render a small announcement when "small" prop is true', () => {
const mockDate = new Date('2023-05-01T00:00:00Z');
Expand Down
98 changes: 98 additions & 0 deletions cypress/test/helpers/applyFilter.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { sortFilter, applyFilterList, onFilterApply } from "../../../components/helpers/applyFilter";

describe('sortFilter function', () => {
it('should sort an array of objects by their value property', () => {
const input = [
{ name: 'Alice', value: 3 },
{ name: 'Bob', value: 1 },
{ name: 'Charlie', value: 2 },
];
const expected = [
{ name: 'Bob', value: 1 },
{ name: 'Charlie', value: 2 },
{ name: 'Alice', value: 3 },
];
const output = sortFilter(input);
expect(output).to.deep.equal(expected);
});
});
/**
* this function is designed to generate filter lists based on the provided data and filter conditions.
* It iterates through the data and creates filter entries in the lists according to certain rules,
* including checking for duplicates and sorting the filter values.
*/

describe('applyFilterList function', () => {
it('should apply filters to a list of data and sort them by value', () => {
//"checks" array that filters on the basis of name , age ,gender
//we are checking if code works on expected Array or not
const checks = [
{ name: 'name', checked: true },
{ name: 'age', checked: true },
{ name: 'gender', checked: true },
];
const data = [
{ name: 'Alice', age: 25, gender: 'female' },
{ name: 'Bob', age: 30, gender: 'male' },
{ name: 'Charlie', age: 28, gender: 'male' },
{ name: 'David', age: 22, gender: 'male' },
{ name: 'Eve', age: 27, gender: 'female' },
];

const expected = {
name: [
{ value: 'Alice', text: 'Alice' },
{ value: 'Bob', text: 'Bob' },
{ value: 'Charlie', text: 'Charlie' },
{ value: 'David', text: 'David' },
{ value: 'Eve', text: 'Eve' },
],
age: [
{ value: 22, text: 22 },
{ value: 25, text: 25 },
{ value: 27, text: 27 },
{ value: 28, text: 28 },
{ value: 30, text: 30 },
],
gender: [
{ value: 'female', text: 'female' },
{ value: 'male', text: 'male' },
],
};
let filters = {};
applyFilterList(checks, data, (lists) => {
filters = lists;
});
expect(filters).to.deep.equal(expected);
});
});

describe('onFilterApply function', () => {
/**
* function onFilterApply that is intended to filter data based on a given query
* and then call a specified callback function (onFilter) with the filtered result.
*/
it('should filter a list of data by a query object and return the filtered result', () => {

/**
* mock data (an array of data to be filtered),
* mock onFilter (a callback function to be called with the filtered data)
* mock query (an object containing filter criteria).
*/
const data = [
{ name: 'Alice', age: 25, gender: 'female', hobbies: ['reading', 'writing'] },
{ name: 'Bob', age: 30, gender: 'male', hobbies: ['gaming', 'coding'] },
{ name: 'Eve', age: 27, gender: 'female', hobbies: ['sports', 'dancing'] },
];
const query = { gender: 'female', hobbies: 'sports' };
const expected = [
{ name: 'Eve', age: 27, gender: 'female', hobbies: ['sports', 'dancing'] },
];
let result = [];
onFilterApply(data, (filtered) => {
result = filtered;
}, query);

expect(result).to.deep.equal(expected);
});
});
53 changes: 53 additions & 0 deletions cypress/test/helpers/is-mobile.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { isMobileDevice } from '../../../components/helpers/is-mobile';

// some user agents for testing
const androidUA = 'Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.210 Mobile Safari/537.36';
const iphoneUA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1';
const kindleUA = 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true';
const ipadUA = 'Mozilla/5.0 (iPad; CPU OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1';
const desktopUA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36';

// Define a helper function to mock the navigator object
function mockNavigator(userAgent) {
Object.defineProperty(window, 'navigator', {
value: { userAgent },
writable: true,
});
}

describe('isMobileDevice function', () => {
// Test for android user agent
it('should return true for android user agent', () => {
// Mock the navigator with android user agent
mockNavigator(androidUA);
expect(isMobileDevice()).to.be.true;
});

// Test for iphone user agent
it('should return true for iphone user agent', () => {
// Mock the navigator with iphone user agent
mockNavigator(iphoneUA);
expect(isMobileDevice()).to.be.true;
});

// Test for kindle user agent
it('should return true for kindle user agent', () => {
// Mock the navigator with kindle user agent
mockNavigator(kindleUA);
expect(isMobileDevice()).to.be.true;
});

// Test for ipad user agent
it('should return true for ipad user agent', () => {
// Mock the navigator with ipad user agent
mockNavigator(ipadUA);
expect(isMobileDevice()).to.be.true;
});

// Test for desktop user agent
it('should return false for desktop user agent', () => {
// Mock the navigator with desktop user agent
mockNavigator(desktopUA);
expect(isMobileDevice()).to.be.true;
});
});
Loading

0 comments on commit ef9591f

Please sign in to comment.