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

fixes #5954 feat(nimbus): group home page experiment tabs by all statuses #5969

Merged
merged 1 commit into from Jul 21, 2021

Conversation

jodyheavener
Copy link
Contributor

Closes #5954

This PR changes the directory/home page view to display for all experiment lifecycle statuses, instead of grouping them together.

As a bonus, I also added a mechanism to remember which tab you were last on.

Copy link
Collaborator

@jaredlockhart jaredlockhart left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you @jodyheavener , so much easier to navigate. The session thing is a neat idea but please pull that out of this pr and file a separate ticket for it, we explicitly wanted it to always land on Live on a fresh load. We should look at the idea of storing the current tab separately. I'd like it to persist in the URL, we can look at that separately.

@@ -105,14 +105,10 @@ function expectTableCells(testId: string, cellTexts: string[]) {
}

describe("DirectoryTable", () => {
it("renders as expected with default columns", () => {
fit("renders as expected with default columns", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Re: it => fit,

What dat about? I'm a bit unclear after https://jestjs.io/docs/api#testonlyname-fn-timeout about which tests will be run with that tweaked. If this describe("DirectoryTable", ...) suite has three it tests set, but one of them is fit, does that mean it will only run the 1 of the 3 tests now?

fit("renders as expected with default columns", async () => {...}
it("renders as expected without experiments", () => {...}
it("renders as expected with custom columns", () => {...}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops! Leftover from testing. Good catch.

@jodyheavener jodyheavener force-pushed the jh/5954/directory-tabs branch 2 times, most recently from bfcecc5 to 394a089 Compare July 16, 2021 13:03
Copy link
Collaborator

@jaredlockhart jaredlockhart left a comment

Choose a reason for hiding this comment

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

Yeyeyeyeyeye hypehypehypehype 🙏 🙏 🙏 🙏 🙏

Copy link
Contributor

@LZoog LZoog left a comment

Choose a reason for hiding this comment

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

Also LGTM! Thanks for the Storybook refactoring to the new pattern. 😁

Copy link
Contributor

@pdehaan pdehaan left a comment

Choose a reason for hiding this comment

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

Preemptively requesting changes until the integration tests are greenish.

@@ -7,7 +7,7 @@ class HomePage(Page):
"""Nimbus Home page."""

_create_new_btn_locator = (By.CSS_SELECTOR, "#create-new-button")
_page_wait_locator = (By.CSS_SELECTOR, ".table")
_page_wait_locator = (By.CSS_SELECTOR, ".directory-table")
Copy link
Contributor

Choose a reason for hiding this comment

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

I might not be understanding the exact role of data-testid.
Above we have the following snippet:

<table className="table" data-testid="DirectoryTable">

I don't know I'd expect this CSS selector to work if we're only setting a .table class, but then trying to use .directory-table here. Not sure if the selector should be something weird like table.table[data-testid="DirectoryTable"] or if just [data-testid="DirectoryTable"] works here (or heck, even just .table since we're now following The Highlander rules of "there can be only one").

But now that we've split the 3 sub-tables on live into separate tabs, the tests might need to be tweaked further if we were trying to do a lookup of experiments in "Review" or "Preview" states. /cc @jrbenny35

@jaredlockhart
Copy link
Collaborator

@jodyheavener rebasing this on main may clear up the integration failure

@jodyheavener
Copy link
Contributor Author

@jrbenny35 @pdehaan I'm a little stuck on these integration test failures. It appears to be having trouble finding the element to indicate the page is loaded. This was previously .table, but since that element is now conditionally rendered I switched it to .directory-table, an element that is always visible when the experiment request has finished. It is unable to find this element. I even tried using #PageHome-page, an element that is immediately visible, as the selector just to see if it could find that, with no luck. Kinda stumped 🤔

@pdehaan
Copy link
Contributor

pdehaan commented Jul 19, 2021

Ah, curious, so we should always have a .directory-table wrapper div, but don't always have a .table since we now conditionally render it based on experiments.length, and otherwise render <p data-testid="no-experiments">No experiments found.</p>.

It looks like the current integration_nimbus error is:

nimbus/test_e2e_create_experiment.py:118: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
nimbus/pages/home.py:23: in tables
    self.wait.until(EC.presence_of_element_located(_table_locator))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

@property
def tables(self):
_table_locator = (By.CSS_SELECTOR, ".active .directory-table .table")
self.wait.until(EC.presence_of_element_located(_table_locator))
tables = self.find_elements(*_table_locator)
return [self.Tables(self, el) for el in tables]

So, re: _table_locator = (By.CSS_SELECTOR, ".active .directory-table .table"), I see the .directory-table and [conditional] .table class names below:

    <div className="directory-table pb-2 mt-4">
      {experiments.length ? (
        <table className="table" data-testid="DirectoryTable">

I'll have to poke around a bit more and see where the .active className is being added. I'm guessing that's the active section tab, which I don't expect changed behavior (or I didn't see it in this PR).

@jodyheavener
Copy link
Contributor Author

@pdehaan Oh that's interesting, locally my tests fail with:

nimbus/test_e2e_create_experiment.py:236:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nimbus/pages/home.py:16: in wait_for_page_to_load
    self.wait.until(EC.visibility_of_element_located(self._page_wait_locator))

@pdehaan
Copy link
Contributor

pdehaan commented Jul 19, 2021

nimbus/pages/home.py:16: in wait_for_page_to_load
   self.wait.until(EC.visibility_of_element_located(self._page_wait_locator))

Curious, since that code is now:

_page_wait_locator = (By.CSS_SELECTOR, ".directory-table")

And I thought that <div className="directory-table pb-2 mt-4"> always existed. I might have to defer to @jrbenny35's expertise here in adding some pauses or screenshots to help debug locally.

@jodyheavener jodyheavener force-pushed the jh/5954/directory-tabs branch 6 times, most recently from 976b7f8 to 51b5ba1 Compare July 20, 2021 15:56
@jaredlockhart
Copy link
Collaborator

Eyyyyyy green finally 🍏 📗 🟢 💚 🥗

@@ -124,7 +124,7 @@ def test_create_new_experiment_remote_settings(selenium, base_url):
# Check it's live
home = HomePage(selenium, base_url).wait_for_page_to_load()
live_experiments = home.tables[0]
assert "live experiments" in live_experiments.table_name.lower()
assert home.active_tab_text, "Live"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should check that the active tab has "live experiments" within it, currently, this assert will always pass.

See: https://www.w3schools.com/python/ref_keyword_assert.asp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrbenny35 Hmm, would it always pass? I want to assert that the tab is selected (contains the .active class). So if "Review" was selected the active_tab_text would not equal "Live". I changed it to this since we removed the element/text that previously displayed "live experiments"

Edit: oh I see what you meant about the usage of assert. Updated that, but I'm still checking for "Live" in the tab text and since "Live experiments" no longer exists.

Copy link
Contributor

@pdehaan pdehaan left a comment

Choose a reason for hiding this comment

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

Great job!
Just 2 small questions.

@@ -105,14 +105,10 @@ function expectTableCells(testId: string, cellTexts: string[]) {
}

describe("DirectoryTable", () => {
it("renders as expected with default columns", () => {
it("renders as expected with default columns", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Why did we add async here?
I think this is the only test in this file that is async (but I don't see any await or returning a promise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, must have thought I was going to add an async method here and then didn't. Will update.

className={`border-top-0 ${
i === 0 ? "font-weight-bold" : "font-weight-normal"
}`}
className="border-top-0"
key={label}
data-testid="directory-table-header"
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: does a data-testid have to be unique?
Not a regression or change, more of a personal curiosity and didn't see any obvious answers on testing-library docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Q: does a data-testid have to be unique?

Nope! You can use the queryAllBy* / findAllBy* / getAllBy* methods to look up multiple elements of the same criteria. In fact, we are doing exactly that in this test file.

Copy link
Contributor

@pdehaan pdehaan left a comment

Choose a reason for hiding this comment

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

:shipit:

@jodyheavener jodyheavener merged commit 3d3f3bc into main Jul 21, 2021
@jodyheavener jodyheavener deleted the jh/5954/directory-tabs branch July 21, 2021 13:32
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.

Add all statuses as directory view tabs
5 participants