Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organization Campaign Page #55

Merged
merged 5 commits into from
Feb 9, 2021
Merged

Organization Campaign Page #55

merged 5 commits into from
Feb 9, 2021

Conversation

kristofferlarberg
Copy link
Contributor

Fixes #41

Adjustments to organization campaign page. Contains campaign title and information as well as events of the campaign.

FireShot Capture 028 -  - localhost

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

It's looking mostly good! I have some comments regarding the tests below that I'd like to hear your thoughts on.


it('contains a campaign title', () => {
cy.visit('/o/1/campaigns/941');
cy.get('[data-test="campaign-heading"]').should('be.visible');
Copy link
Member

Choose a reason for hiding this comment

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

This works, but it doesn't actually check that the title is being rendered, just that an element (which may or may not contain the title) with a certain ID is being rendered.

I would have preferred checking for the actual title from dummyCampaign.

Comment on lines 1 to 9
interface ZetkinEvent {
activity: { title: string },
campaign: { title: string },
end_time: string,
id: number,
location: { title: string },
start_time: string,
title: string
}
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't this already implemented somewhere else? Instead of duplicating, I think we should split this out into a separate file and reuse the same interface in both places. Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is also used in getEvents. Sounds good!

Comment on lines 12 to 15
it('contains campaign information', () => {
cy.visit('/o/1/campaigns/941');
cy.get('[data-test="campaign-information"]').should('be.visible');
});
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should need to be a separate test from the previous one. Just have one test to assert that all campaign information is being displayed, both the title and the description in the same it block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Is it a problem that this doesn't check the content just the element, as with the title?

Copy link
Member

Choose a reason for hiding this comment

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

I would say that the issue is the same here. With a small difference being that you could envision a scenario where the text is so long that it is truncated (which would cause the test to fail if you're looking for the entire text). But for the test case the easiest way to solve that is the make sure that the dummy text isn't that long.

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

Some more comments below!

It turns out the linter has not been running on the cypress directory, and hence has not been checking the integration test code. These are the errors it found in the org_campaign_page.spec.ts file relevant to this PR:

/Users/richardolsson/src/zetkin/product/app.zetkin.org/cypress/integration/org_campaign_page.spec.ts
   3:1   error  Expected indentation of 4 spaces but found 8   indent
   4:1   error  Expected indentation of 8 spaces but found 12  indent
  11:15  error  Missing semicolon                              semi
  12:1   error  Expected indentation of 4 spaces but found 8   indent
  14:1   error  Expected indentation of 4 spaces but found 8   indent
  15:1   error  Expected indentation of 8 spaces but found 12  indent
  17:1   error  Expected indentation of 8 spaces but found 12  indent
  18:1   error  Expected indentation of 8 spaces but found 12  indent
  19:1   error  Expected indentation of 4 spaces but found 8   indent
  22:1   error  Expected blank line before this statement      padding-line-between-statements

I suggest you fix these now, and then we'll have to fix the rest in a separate PR.

Run eslint cypress to run the linter on all JS/TS files in the cypress directory.

src/fetching/getCampaignEvents.ts Show resolved Hide resolved
@@ -0,0 +1,7 @@
{
"data": {
"id": 1,
Copy link
Member

Choose a reason for hiding this comment

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

Indentation looks off in this file.

@@ -1,5 +1,5 @@
export default function getCampaign(orgId : string, campId : string) {
return async () : Promise<{ title: string }> => {
return async () : Promise<{ title: string, info_text: string }> => {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe introduce a type/interface for this as well? E.g. ZetkinCampaign.

@kristofferlarberg
Copy link
Contributor Author

Run eslint cypress to run the linter on all JS/TS files in the cypress directory.

I've tried this is the terminal with no luck?

Copy link
Member

@richardolsson richardolsson left a comment

Choose a reason for hiding this comment

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

We have arrived!

@richardolsson richardolsson merged commit 484bbc2 into main Feb 9, 2021
@richardolsson richardolsson deleted the issue-41/campaign-page branch February 9, 2021 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Campaign page
2 participants