Skip to content

Commit

Permalink
#58 add cypress e2e test for exporting/downloading stories from room
Browse files Browse the repository at this point in the history
  • Loading branch information
xeronimus committed Jan 7, 2023
1 parent 3c5e736 commit 08a4c0a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
7 changes: 6 additions & 1 deletion client/app/components/Settings/RoomExportFileDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {getOwnUserToken} from '../../state/users/usersSelectors';
const RoomExportFileDownload = ({roomId, userToken}) => {
const {t} = useContext(L10nContext);
return (
<button type="button" className="pure-button pure-button-primary" onClick={onDownloadClick}>
<button
type="button"
className="pure-button pure-button-primary"
onClick={onDownloadClick}
data-testid="storiesExportButton"
>
{t('exportLinkText')} <i className="icon-download-cloud"></i>
</button>
);
Expand Down
1 change: 1 addition & 0 deletions client/cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
videos/
screenshots/
downloads/
1 change: 1 addition & 0 deletions client/cypress/e2e/_all.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import './backlogModification.cy';
import './changeRoomSettings.cy';
import './changeUserSettings.cy';
import './estimateStory.cy';
import './exportStories.cy';
import './joinNewRandomRoom.cy';
import './joinPasswordProtectedRoom.cy';
import './mobileMenuToggling.cy';
Expand Down
37 changes: 37 additions & 0 deletions client/cypress/e2e/exportStories.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {nanoid} from 'nanoid';
import path from 'path';

import {Room, Landing} from '../elements/elements';

beforeEach(function () {
cy.fixture('users/default.json').then((data) => (this.user = data));
cy.fixture('stories.json').then((data) => (this.stories = data));
});

it('setup stories in new room and export them (download json)', function () {
const customRoomName = 'e2e-room-' + nanoid();

cy.visit('/');
Landing.extendButton().click();
Landing.customRoomNameField().type(customRoomName);
Landing.joinButton().click();

Landing.joinButton().click();
Landing.usernameField().type(this.user.username);
Landing.joinButton().click();

Room.Backlog.StoryAddForm.titleField().type(this.stories[3].title);
Room.Backlog.StoryAddForm.descriptionField().type(this.stories[3].description);
Room.Backlog.StoryAddForm.addButton().click();

Room.EstimationArea.estimationCard(21).click();
Room.Users.userEstimationGiven(21, true); // since auto reveal is on by default. and we are one single user in the room

// now go to room settings and click "Download"
Room.TopBar.settingsToggleButton().click();
Room.Settings.storiesExportButton().click();

const downloadsFolder = Cypress.config('downloadsFolder');
const downloadedFilename = path.join(downloadsFolder, `${customRoomName.toLowerCase()}.json`);
cy.readFile(downloadedFilename); // will fail if file does not exist!
});
3 changes: 2 additions & 1 deletion client/cypress/elements/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const elements = {
roomPasswordField: () => cy.get(tid('settings', 'roomPasswordInput')),
roomPasswordInputRepeat: () => cy.get(tid('settings', 'roomPasswordInputRepeat')),
autoRevealToggle: () => cy.get(tid('settings', 'toggleAutoReveal')),
confidenceToggle: () => cy.get(tid('settings', 'toggleConfidence'))
confidenceToggle: () => cy.get(tid('settings', 'toggleConfidence')),
storiesExportButton: () => cy.get(tid('settings', 'storiesExportButton'))
},

Backlog: {
Expand Down

0 comments on commit 08a4c0a

Please sign in to comment.