Skip to content

Commit

Permalink
Merge pull request #4252 from systeminit/wendy/test-fixes-for-modal
Browse files Browse the repository at this point in the history
tests now check for page loading and the modal properly
  • Loading branch information
wendybujalski authored Jul 30, 2024
2 parents a807ca0 + 9182905 commit 6aa759d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig({
chromeWebSecurity: false,
viewportHeight: 1000,
viewportWidth: 1500,
retries: 3,
retries: process.env.VITE_SI_CYPRESS_MULTIPLIER ? Number(process.env.VITE_SI_CYPRESS_MULTIPLIER) : 3,
},
projectId: "k8tgfj",
video: true,
Expand Down
4 changes: 3 additions & 1 deletion app/web/cypress/e2e/authentication/logout.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => {
return false;
});
cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID);
cy.appModelPageLoaded();
cy.clickButtonByIdIfExists("first-time-modal-continue-button");

cy.contains('Create change set', { timeout: 10000 }).should('be.visible');
cy.get('.modal-close-button').should('exist').click();
cy.get('.vbutton').contains("Let's Get Started!").parent().parent().click();
cy.get('[aria-label="Profile"]').should('exist').click();
cy.get('.profile-dropdown-menu-logout').should('exist').should('be.visible').click({ force: true });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => {
});
cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID);

cy.appModelPageLoaded();

cy.clickButtonByIdIfExists("first-time-modal-continue-button");

cy.get('[class=vorm-input__input]').get('[type=text]').clear().type(UUID);

cy.contains('Create change set', { timeout: 30000 }).click();

// Give time to redirect onto the new change set
cy.url().should('not.include', 'head', { timeout: 10000 });
cy.get('.vbutton').contains("Let's Get Started!").parent().parent().click();

// Create a region component
cy.createComponent("region");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => {
return false;
});
cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID);
cy.appModelPageLoaded();
cy.clickButtonByIdIfExists("first-time-modal-continue-button");

cy.get('[class=vorm-input__input]').get('[type=text]').clear().type(UUID);
cy.contains('Create change set', { timeout: 30000 }).click();

// Give time to redirect onto the new change set
cy.url().should('not.include', 'head', { timeout: 10000 });
cy.get('.vbutton').contains("Let's Get Started!").parent().parent().click();

// Create a region component
cy.createComponent("region");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => {
return false;
});
cy.sendPosthogEvent(Cypress.currentTest.titlePath.join("/"), "test_uuid", UUID);
cy.appModelPageLoaded();
cy.clickButtonByIdIfExists("first-time-modal-continue-button");

cy.get('[class=vorm-input__input]').get('[type=text]').clear().type(UUID);

cy.contains('Create change set', { timeout: 30000 }).click();

// Give time to redirect onto the new change set
cy.url().should('not.include', 'head', { timeout: 10000 });
cy.get('.vbutton').contains("Let's Get Started!").parent().parent().click();

// Needs a proper way to select from the updated asset tree panel
// Find the region asset
Expand Down Expand Up @@ -86,9 +88,8 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => {
});
});

// Give the page a few seconds to load
cy.wait(1000);
cy.get('.vbutton').contains("Let's Get Started!").parent().parent().click();
cy.appModelPageLoaded();
cy.clickButtonByIdIfExists("first-time-modal-continue-button");

cy.intercept('POST', '/api/component/update_property_editor_value').as('updatePropertyEditorValue');

Expand All @@ -112,9 +113,8 @@ Cypress._.times(SI_CYPRESS_MULTIPLIER, () => {
});
});

// Wait for the values to propagate
cy.wait(10000);
cy.get('.vbutton').contains("Let's Get Started!").parent().parent().click();
cy.appModelPageLoaded();
cy.clickButtonByIdIfExists("first-time-modal-continue-button");

// Validate that the value has propagated through the system
cy.get('.attributes-panel-item__input-wrap input.region')
Expand Down
4 changes: 4 additions & 0 deletions app/web/cypress/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ declare namespace Cypress {
dragTo(sourceElement: string, targetElement: string, offsetX? :number, offsetY?: number): void;

createComponent(componentName: string): void;

appModelPageLoaded(): void;

clickButtonByIdIfExists(id: string): void;
}
}
18 changes: 18 additions & 0 deletions app/web/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ Cypress.Commands.add('dragTo', (sourceElement: string, targetElement: string, of
})
});

Cypress.Commands.add('appModelPageLoaded', () => {
cy.get('#asset-palette-title', { timeout: 60000 });
})

Cypress.Commands.add('clickButtonByIdIfExists', (id: string) => {
cy.get('body').then(($body) => {
// Check if element exists
if ($body.find(`#${id}`).length > 0) {
// Element exists, perform click
cy.log(`Trying to click the #${id} now`);
cy.get(`#${id}`).click();
} else {
// Element does not exist, continue with other actions
cy.log('Button not found, continuing with other actions');
}
});
});

//Cypress.Commands.add('setupVariables', () => {
// const SI_CYPRESS_MULTIPLIER = Cypress.env('VITE_SI_CYPRESS_MULTIPLIER') || import.meta.env.VITE_SI_CYPRESS_MULTIPLIER || 1;
// const AUTH0_USERNAME = Cypress.env('VITE_AUTH0_USERNAME') || import.meta.env.VITE_AUTH0_USERNAME;
Expand Down
2 changes: 1 addition & 1 deletion app/web/src/components/AssetPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<SidebarSubpanelTitle icon="component-plus">
<template #label>
<div class="flex flex-row gap-xs">
<div>Assets</div>
<div id="asset-palette-title">Assets</div>
<PillCounter :count="assetCount" />
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions app/web/src/pages/WorkspaceSinglePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
inlineLabel
/>
<VButton
id="first-time-modal-continue-button"
class="flex-grow"
label="Let's Get Started!"
@click="closeFirstTimeModal"
Expand Down

0 comments on commit 6aa759d

Please sign in to comment.