Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions cypress/e2e/tests/pages/manager/kontainer-drivers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DeactivateDriverDialogPo from '@/cypress/e2e/po/prompts/deactivateDriverD
import ClusterManagerListPagePo from '@/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
import ClusterManagerCreatePagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/create/cluster-create.po';
import PromptRemove from '@/cypress/e2e/po/prompts/promptRemove.po';
import { MEDIUM_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';
import { LONG_TIMEOUT_OPT, MEDIUM_TIMEOUT_OPT, VERY_LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';

describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@adminUser'] }, () => {
const driversPage = new KontainerDriversPagePo();
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin
});

driversPage.list().details(exampleDriver, 1).should('contain', 'Activating');
driversPage.list().details(exampleDriver, 1).contains('Active', { timeout: 60000 });
driversPage.list().details(exampleDriver, 1).should('contain', 'Active', LONG_TIMEOUT_OPT );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question
I think the LONG_TIMEOUT_OPT cannot be used on the .should.
That is for most of the cases here. Are you sure it is actually applying the timeout?
I faced this problem before. (And I think I still have similar codes not working)

I usually change to something like this.

    driversPage.list().details(exampleDriver, 1).contains('Active', LONG_TIMEOUT_OPT);

I am happy to discuss if you are not sure. I did some tests but we can check together.


// Verify the driver tile appears on the cluster create page.
// Legacy ember-based kontainer drivers are shown disabled with an informational tooltip
Expand Down Expand Up @@ -144,12 +144,9 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin
driversPage.list().activate().click();
cy.wait('@activateOpenTelekomDriver').its('response.statusCode').should('eq', 200);
cy.wait('@activateOracleDriver').its('response.statusCode').should('eq', 200);
// wait for drivers to be activating
driversPage.list().details(openTelekomDriver, 1).should('contain', 'Activating');
driversPage.list().details(oracleDriver, 1).should('contain', 'Activating');
// wait for drivers to be active
driversPage.list().details(openTelekomDriver, 1).should('contain', 'Active');
driversPage.list().details(oracleDriver, 1).should('contain', 'Active');
driversPage.list().details(openTelekomDriver, 1).should('contain', 'Active', VERY_LONG_TIMEOUT_OPT);
driversPage.list().details(oracleDriver, 1).should('contain', 'Active', VERY_LONG_TIMEOUT_OPT);

// check options on cluster create page
ClusterManagerListPagePo.navTo();
Expand Down Expand Up @@ -205,6 +202,8 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin
expect(isMatch(request.body, requestData)).to.equal(true);
});

driversPage.list().details(exampleDriver, 1).should('contain', 'Inactive');

// check options on cluster create page
ClusterManagerListPagePo.navTo();
clusterList.waitForPage();
Expand All @@ -222,6 +221,21 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin
driversPage.list().resourceTable().sortableTable().checkVisible();
driversPage.list().resourceTable().sortableTable().checkLoadingIndicatorNotVisible();

// Ensure driver is inactive before attempting to activate
driversPage.list().details(exampleDriver, 1).then(($el) => {
if ($el.text().includes('Active')) {
cy.intercept('POST', `/v3/kontainerDrivers/*?action=deactivate`).as('deactivateForSetup');
driversPage.list().actionMenu(downloadUrl).getMenuItem('Deactivate').click();
const deactivateDialog = new DeactivateDriverDialogPo();

deactivateDialog.deactivate();
cy.wait('@deactivateForSetup');
driversPage.list().details(exampleDriver, 1).should('contain', 'Inactive');
}
});

driversPage.list().details(exampleDriver, 1).should('contain', 'Inactive');

cy.intercept('POST', `/v3/kontainerDrivers/*?action=activate`).as('activateDriver');

driversPage.list().actionMenu(downloadUrl).getMenuItem('Activate').click();
Expand All @@ -231,6 +245,9 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin
expect(isMatch(request.body, requestData)).to.equal(true);
});

// wait for driver to be active
driversPage.list().details(exampleDriver, 1).should('contain', 'Active');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No check for Activating->Active status here because the driver may be updated to Active too quickly, introducing some flakiness


// check options on cluster create page
ClusterManagerListPagePo.navTo();
clusterList.waitForPage();
Expand Down Expand Up @@ -329,31 +346,22 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin
body: { }
}).as('deleteDriver');

// Scroll element into view and select with force
driversPage.list().resourceTable().sortableTable().rowElementWithName(exampleDriver)
.scrollIntoView();
driversPage.list().resourceTable().sortableTable().rowSelectCtlWithName(exampleDriver)
.set();
driversPage.list().resourceTable().sortableTable().bulkActionDropDownOpen();
driversPage.list().resourceTable().sortableTable().bulkActionDropDownButton('Delete')
.click({ force: true });

driversPage.list().resourceTable().sortableTable().rowNames()
.then((rows: any) => {
const promptRemove = new PromptRemove();

promptRemove.remove();

cy.wait('@deleteDriver').then(({ response }) => {
expect(response?.statusCode).to.eq(200);
if (response?.statusCode === 200) {
removeDriver = false;
}
driversPage.waitForPage();
driversPage.list().resourceTable().sortableTable().rowNames()
.should('not.contain', exampleDriver);
});
});
driversPage.list().actionMenu(exampleDriver).getMenuItem('Delete').click();

const promptRemove = new PromptRemove();

promptRemove.remove();

cy.wait('@deleteDriver').then(({ response }) => {
expect(response?.statusCode).to.eq(200);
});

driversPage.waitForPage();
driversPage.list().resourceTable().sortableTable().rowElementWithName(exampleDriver, MEDIUM_TIMEOUT_OPT)
.should('not.exist');

// only mark removeDriver false once tests assert the driver is actually gone
removeDriver = false;
});

after(() => {
Expand Down
Loading