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

test: [M3-7124] - Add Cypress integration tests for VPC assign/unassign flows #9818

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

cliu-akamai
Copy link
Contributor

Description 📝

Add new cypress tests for VPC assign/unassign flows.

Major Changes 🔄

  • Add e2e tests to verify assigning/unassigning Linode(s) to/from a VPC.

How to test 🧪

yarn cy:run -s "cypress/e2e/core/vpc/vpc-linodes-update.spec.ts"

Known Issues

  1. When there are multiple Linodes in the select list, users type the label to select one of them, then it will deselect all when users type another label and select it.
  2. When users click the Unassign Linode button, it doesn’t send any request to tell the VPC to unassign Linodes.

@cliu-akamai cliu-akamai requested a review from a team as a code owner October 19, 2023 15:54
@cliu-akamai cliu-akamai requested review from mjac0bs and jaalah-akamai and removed request for a team October 19, 2023 15:54
@mjac0bs mjac0bs added the VPC Relating to VPC project label Oct 19, 2023
@cliu-akamai cliu-akamai changed the title test: [EW-7124] - Add Cypress integration tests for VPC assign/unassign flows test: [M3-7124] - Add Cypress integration tests for VPC assign/unassign flows Oct 19, 2023
Comment on lines 235 to 244
cy.visitWithLogin('/linodes');
cy.wait(['@getFeatureFlags', '@getClientStream']);

ui.nav.findItemByTitle('VPC').should('be.visible').click();
cy.wait('@getVPCs');

cy.url().should('endWith', '/vpcs');

cy.visitWithLogin(`/vpcs/${mockVPC.id}`);
cy.wait(['@getVPC', '@getSubnets']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to navigate to the VPCs page manually? We might be able to save some time by navigating to /vpcs/${mockVPC.id} directly (I didn't test though!)

Suggested change
cy.visitWithLogin('/linodes');
cy.wait(['@getFeatureFlags', '@getClientStream']);
ui.nav.findItemByTitle('VPC').should('be.visible').click();
cy.wait('@getVPCs');
cy.url().should('endWith', '/vpcs');
cy.visitWithLogin(`/vpcs/${mockVPC.id}`);
cy.wait(['@getVPC', '@getSubnets']);
cy.visitWithLogin(`/vpcs/${mockVPC.id}`);
cy.wait(['@getFeatureFlags', '@getClientStream', '@getVPC', '@getSubnets']);

Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

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

Thanks @cliu-akamai, this looks great!

When there are multiple Linodes in the select list, users type the label to select one of them, then it will deselect all when users type another label and select it.

I'm seeing this too -- I'm guessing this has to do with the issue fixed by #9820 (though I haven't had a chance to look too closely at that PR yet).

When users click the Unassign Linode button, it doesn’t send any request to tell the VPC to unassign Linodes.

Also observing no HTTP request getting fired off upon submitting the drawer, but curious if this might be a data mocking issue -- for example, maybe we have to mock the GET request to the Linode config endpoint with the VPC interface data set up correctly in order for the frontend to make a PUT to remove the VPC.

Would a developer be able to offer any insight here?

@jaalah-akamai
Copy link
Contributor

I think both those issues will be resolved in #9820

@cpathipa cpathipa requested review from jdamore-linode and removed request for jaalah-akamai October 23, 2023 17:52
@mjac0bs
Copy link
Contributor

mjac0bs commented Oct 26, 2023

@cliu-akamai #9820 was just merged! Can we get the latest develop merged into this branch?

@cliu-akamai
Copy link
Contributor Author

@cliu-akamai #9820 was just merged! Can we get the latest develop merged into this branch?

Sure thing! I will rebase the code.

@cliu-akamai
Copy link
Contributor Author

After I rebase the code, the Unassign Linodes button is always disabled even though I select a Linode.

@coliu-akamai
Copy link
Contributor

Hey Cassie! Could you send a screenshot of what you're seeing for the Unassign Linodes drawer? I'm not seeing the button grey'd out

image

Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

Hey Cassie! Could you send a screenshot of what you're seeing for the Unassign Linodes drawer? I'm not seeing the button grey'd out

Looks like this test is failing consistently in the can unassign Linode(s) from a VPC test case once a Linode is selected to be unassigned. The test checks for

        ui.button
          .findByTitle('Unassign Linodes')
          .should('be.visible')
          .should('be.enabled')
          .click();

and fails because it's not enabled. Can't replicate this in the UI, though, like @coliu-akamai mentioned so it seems like there's something in the test. Based on SubnetUnassignLinodesDrawer code, the Unassign Linodes button is only disabled when configInterfacesToDelete.length === 0, so are we not mocking something correctly?

Screenshot 2023-10-30 at 12 49 30 PM

/*
* - Confirms that can assign a Linode to the VPC when feature is enabled.
*/
it.skip('can assign Linode(s) to a VPC', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not forget to unskip this!

Suggested change
it.skip('can assign Linode(s) to a VPC', () => {
it('can assign Linode(s) to a VPC', () => {

@jdamore-linode
Copy link
Contributor

jdamore-linode commented Oct 31, 2023

Looks like this test is failing consistently in the can unassign Linode(s) from a VPC test case once a Linode is selected to be unassigned. The test checks for

        ui.button
          .findByTitle('Unassign Linodes')
          .should('be.visible')
          .should('be.enabled')
          .click();

and fails because it's not enabled.

Thanks, @mjac0bs!

@cliu-akamai It looks like the root of the issue is that the Linode's mocked config doesn't contain the corresponding VPC interface. Defining the config mock like this:

  // (...Somewhere around line 214...)
  const mockLinodeConfig = configFactory.build({
    interfaces: [LinodeConfigInterfaceFactoryWithVPC.build({
      vpc_id: mockVPC.id,
      subnet_id: mockSubnet.id,
    })],
  });

And then using it on line 259 (instead of mockConfig, which you may be able to remove) allows the unassign button to become enabled!

@carrillo-erik
Copy link
Contributor

Don't forget to add a changeset to this PR.

Copy link
Contributor

@mjac0bs mjac0bs left a comment

Choose a reason for hiding this comment

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

Thanks, Cassie! This passed locally and seems to accomplish the goals of the flows.

We'll want a Test changeset for this PR (yarn changeset) and I spotted one typo we could fix with the new delete config interface function we're mocking.

Screenshot 2023-11-02 at 11 24 59 AM

*
* @returns Cypress chainable.
*/
export const mockDeleteLinodeConfignInterface = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const mockDeleteLinodeConfignInterface = (
export const mockDeleteLinodeConfigInterface = (

I think this is a small typo. 🔍

@mjac0bs mjac0bs added the Add'tl Approval Needed Waiting on another approval! label Nov 2, 2023
Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

Just some import conflicts but after these changes the test passes!

import {
mockCreateLinodeConfigInterfaces,
mockGetLinodeConfigs,
mockDeleteLinodeConfignInterface,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mockDeleteLinodeConfignInterface,
mockDeleteLinodeConfigInterface,

);
cy.findByText(mockSecondLinode.label).should('be.visible');

mockDeleteLinodeConfignInterface(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mockDeleteLinodeConfignInterface(
mockDeleteLinodeConfigInterface(

mockLinodeConfig.id,
mockLinodeConfig.interfaces[0].id
).as('deleteLinodeConfigInterface1');
mockDeleteLinodeConfignInterface(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mockDeleteLinodeConfignInterface(
mockDeleteLinodeConfigInterface(

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

Confirmed test passed! Approving pending one small comment regarding the changeset 🎉

@@ -0,0 +1,5 @@
---
"@linode/manager": Added
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we change this to Tests? You'll also need to update the file name itself from pr-9818-added-.. to pr-9818-tests-...

Suggested change
"@linode/manager": Added
"@linode/manager": Tests

Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

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

Nice work @cliu-akamai! One small suggestion to wrap the mocked interfaces in a makeResponse call (doesn't impact your test but could cause issues in other places), but otherwise this looks great!

return cy.intercept(
'POST',
apiMatcher(`linode/instances/${linodeId}/configs/${config.id}/interfaces`),
config.interfaces
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
config.interfaces
makeResponse(config.interfaces)

@coliu-akamai coliu-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Nov 9, 2023
@jdamore-linode
Copy link
Contributor

(@cliu-akamai we can also disregard the e2e failure for this, it'll be fixed by PR #9890)

@cliu-akamai cliu-akamai merged commit c5e1324 into linode:develop Nov 10, 2023
11 checks passed
@cliu-akamai cliu-akamai deleted the feature/M3-7124 branch November 10, 2023 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! VPC Relating to VPC project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants