Skip to content

✨Add allow-blocked-end-date flag and e2e test#22029

Merged
cvializ merged 4 commits intoampproject:masterfrom
cvializ:feature/blocked-end-date
May 9, 2019
Merged

✨Add allow-blocked-end-date flag and e2e test#22029
cvializ merged 4 commits intoampproject:masterfrom
cvializ:feature/blocked-end-date

Conversation

@cvializ
Copy link
Copy Markdown
Contributor

@cvializ cvializ commented Apr 26, 2019

Implements #17950

/to @cathyxz @sparhami
/cc @estherkim

@cvializ cvializ force-pushed the feature/blocked-end-date branch from 9687c8f to e65ac83 Compare April 29, 2019 14:09
Comment thread build-system/tasks/e2e/functional-test-controller.js Outdated
Copy link
Copy Markdown
Collaborator

@estherkim estherkim left a comment

Choose a reason for hiding this comment

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

E2E changes LGTM; will defer to others regarding flag implementation

Comment thread build-system/app-test.js
});
});

app.use('/date-picker/config.json', (req, res) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think @cathyxz split some non test app stuff out into separate files, which I think is a pattern we should follow so that this file doesn't end up being huge as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure which non test app stuff you're referring to, since that's what I created this file for, but I'd be glad to do something cleaner in a followup PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Like this:

app.use('/list/', require('./routes/list'));

Basically, move the route logic into a separate file, then just import it from app-test, to keep this file from growing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice that looks pretty good. I will definitely do that in a followup PR

* actions instead of text.
* @enum {string}
*/
export const Keys = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This enum name should be singular (i.e. Key)

}

if (containsBlocked) {
if (blockedCount == 1 && this.allowBlockedEndDate_) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

function is getting a bit long, would consider extracting out this logic and the above into a function that just checks for blocked days, since it seems to be orthogonal to the rest of the function.


if (startDate && !endDate && allowBlockedEndDate) {
return isBlocked && !isSameDay(day, list.firstDateAfter(startDate));
} else {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

drop the else, and unindent


// This sequence of commands selects the date one week after the start
// date since the initial focused cell is the date after the start date.
await controller.type(null, Keys.ArrowLeft);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

in tests, not a good idea to rely on the current date. Tests should be (to the extent possible) completely reproducible. For example, your test at some point may go into the next month with the next arrow or down arrow key. It could end up that your test fails at some day in the future where this does not work. While it may work fine in this case, you should use specific dates to test that it works correctly (if that is indeed inspected).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with you generally, but for a few reasons I think for now this is the way to go:

  1. E2E tests are designed to execute with as minimal mocking as possible, and spoofing the date in the test is a kind of mocking
  2. There is currently no API in Puppeteer or Selenium to override the date and would have to be implemented
  3. The date picker changes the date it opens to depending on the current day and this tests that.
  4. This sequence of keys is designed to work for any day.

For these reasons I would prefer to keep current behavior at this time.

@cvializ cvializ force-pushed the feature/blocked-end-date branch from 87a48bd to fbabdbd Compare April 30, 2019 17:49
@ghost

This comment has been minimized.

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented Apr 30, 2019

PTAL

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented May 9, 2019

Thanks for the review 🎉

@cvializ cvializ merged commit 028cc68 into ampproject:master May 9, 2019
@cvializ cvializ deleted the feature/blocked-end-date branch May 10, 2019 14:06
@selfcatering
Copy link
Copy Markdown

Just so you know the flag breaks page validation.

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented Jul 16, 2019

Thanks for reporting, we'll have that fixed shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants