Skip to content

Commit

Permalink
update failed e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: huongg <[email protected]>
  • Loading branch information
Huongg committed May 20, 2024
1 parent 28b02af commit 95ef01b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
34 changes: 15 additions & 19 deletions cypress/tests/ui/flowchart/shareable-urls.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
describe('Shareable URLs', () => {
it('verifies that users can open the Deploy Kedro-Viz modal. #TC-52', () => {
describe('Shareable URLs with empty localStorage', () => {
beforeEach(() => {
// Clears localStorage before each test
cy.clearLocalStorage();
});

it('verifies that users can open the Deploy Kedro-Viz modal if the localStorage is empty. #TC-52', () => {
// Intercept the network request to mock with a fixture
cy.__interceptRest__(
'/api/package-compatibilities',
Expand All @@ -10,7 +15,6 @@ describe('Shareable URLs', () => {
// Action
cy.reload();
cy.get('.pipeline-menu-button--deploy').click({ force: true });
cy.get('[data-test="disclaimerButton"]').click({ force: true });

// Assert after action
cy.get('.shareable-url-modal .modal__wrapper').contains(
Expand Down Expand Up @@ -39,7 +43,6 @@ describe('Shareable URLs', () => {
it('verifies that shareable url modal closes on close button click #TC-54', () => {
// Action
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal__button-wrapper button')
.contains('Cancel')
.click();
Expand All @@ -56,7 +59,6 @@ describe('Shareable URLs', () => {

// Action
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal [data-test=kedro-pipeline-selector]').click();

// Assert after action
Expand All @@ -72,13 +74,14 @@ describe('Shareable URLs', () => {

// Action
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();

// Assert after action
cy.get(
'.shareable-url-modal [data-test=kedro-pipeline-selector] .dropdown__label span'
).contains(selectedPlatform);
cy.get('.shareable-url-modal input').should('have.value', '');
cy.get(
'.shareable-url-modal .shareable-url-modal__input-wrapper input'
).should('have.value', '');
cy.get('.shareable-url-modal__button-wrapper button')
.contains(primaryButtonNodeText)
.should('be.disabled');
Expand All @@ -89,14 +92,15 @@ describe('Shareable URLs', () => {

// Action
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal [data-test=kedro-pipeline-selector]').click();
cy.get('.shareable-url-modal .dropdown__options section div')
.first()
.click();

// Assert after action
cy.get('.shareable-url-modal input').should('have.value', '');
cy.get(
'.shareable-url-modal .shareable-url-modal__input-wrapper input'
).should('have.value', '');
cy.get('.shareable-url-modal__button-wrapper button')
.contains(primaryButtonNodeText)
.should('be.disabled');
Expand All @@ -109,7 +113,6 @@ describe('Shareable URLs', () => {

// Action
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal [data-test=kedro-pipeline-selector]').click();
cy.get('.shareable-url-modal .dropdown__options section div')
.first()
Expand All @@ -131,7 +134,6 @@ describe('Shareable URLs', () => {
const primaryButtonNodeText = 'Publish';
// Action
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal [data-test=kedro-pipeline-selector]').click();
cy.get('.shareable-url-modal .dropdown__options section div')
.first()
Expand Down Expand Up @@ -165,7 +167,6 @@ describe('Shareable URLs', () => {
// Action
cy.reload();
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal [data-test=kedro-pipeline-selector]').click();
cy.get('.shareable-url-modal .dropdown__options section div')
.first()
Expand All @@ -181,9 +182,7 @@ describe('Shareable URLs', () => {
// Wait for the POST request to complete and check the mocked response
cy.wait('@publishRequest').then((interception) => {
// Assert after action
cy.get('.shareable-url-modal__result-url').contains(
interception.response.body.url
);
cy.get('.url-box__result-url').contains(interception.response.body.url);
});
});

Expand All @@ -204,7 +203,6 @@ describe('Shareable URLs', () => {
// Action
cy.reload();
cy.get('.pipeline-menu-button--deploy').click();
cy.get('[data-test="disclaimerButton"]').click();
cy.get('.shareable-url-modal [data-test=kedro-pipeline-selector]').click();
cy.get('.shareable-url-modal .dropdown__options section div')
.first()
Expand All @@ -231,9 +229,7 @@ describe('Shareable URLs', () => {
// Wait for the POST request to complete and check the mocked response
cy.wait('@publishRequest').then((interception) => {
// Assert after action
cy.get('.shareable-url-modal__result-url').contains(
interception.response.body.url
);
cy.get('.url-box__result-url').contains(interception.response.body.url);
});
});
});
41 changes: 22 additions & 19 deletions src/components/shareable-url-modal/shareable-url-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ const ShareableUrlModal = ({ onToggleModal, visible }) => {
setDeploymentState('loading');
setIsLoading(true);

const hostingPlatformVal = {};
if (hostingPlatforms.hasOwnProperty(inputValues.platform)) {
hostingPlatformVal[inputValues.platform] = { ...inputValues };
}
// const hostingPlatformVal = {};
// if (hostingPlatforms.hasOwnProperty(inputValues.platform)) {
// hostingPlatformVal[inputValues.platform] = { ...inputValues };
// }

saveLocalStorage(localStorageSharableUrl, hostingPlatformVal);
// saveLocalStorage(localStorageSharableUrl, hostingPlatformVal);

const newState = {
...hostingPlatformLocalStorageVal,
...hostingPlatformVal,
};
setHostingPlatformLocalStorageVal(newState);
// const newState = {
// ...hostingPlatformLocalStorageVal,
// ...hostingPlatformVal,
// };
// setHostingPlatformLocalStorageVal(newState);

try {
const request = await fetch('/api/deploy', {
Expand All @@ -169,15 +169,18 @@ const ShareableUrlModal = ({ onToggleModal, visible }) => {
setDeploymentState('success');
toShowPublishedContent();

// const hostingPlatformVal = {};
// for (const platform in hostingPlatforms) {
// if (inputValues.platform === platform) {
// // to set the platform property based on the current playform value from inputValues
// // expected output: { aws: { ...inputValues }}
// hostingPlatformVal[inputValues.platform] = { ...inputValues };
// }
// }
// saveLocalStorage(localStorageSharableUrl, hostingPlatformVal);
const hostingPlatformVal = {};
if (hostingPlatforms.hasOwnProperty(inputValues.platform)) {
hostingPlatformVal[inputValues.platform] = { ...inputValues };
}

saveLocalStorage(localStorageSharableUrl, hostingPlatformVal);

const newState = {
...hostingPlatformLocalStorageVal,
...hostingPlatformVal,
};
setHostingPlatformLocalStorageVal(newState);
} else {
setResponseUrl(null);
setResponseError(response.message || 'Error occurred!');
Expand Down

0 comments on commit 95ef01b

Please sign in to comment.