diff --git a/components/centraldashboard/cypress/e2e/landing-page.cy.ts b/components/centraldashboard/cypress/e2e/landing-page.cy.ts index ba093d47e53..8e1d0918de5 100644 --- a/components/centraldashboard/cypress/e2e/landing-page.cy.ts +++ b/components/centraldashboard/cypress/e2e/landing-page.cy.ts @@ -24,6 +24,26 @@ describe('Landing Page', () => { cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #namespaceDisplay').find('span').should('exist').and('have.text', 'user-name'); }); + it('should email keep number', ()=>{ + cy.intercept('GET', `/api/workgroup/exists`, { + "hasAuth":true, + "user":"user.name1@statcan.gc.ca", + "email": "user.name1@statcan.gc.ca", + "hasWorkgroup":false, + "registrationFlowAllowed": true, + "isAllowed": true + }).as('mockWorkgroupRequest'); + cy.visit('/'); + + cy.wait(['@mockWorkgroupRequest', '@mockDashboardLinksRequest']); + cy.get('main-page').shadow().find('blocked-user-view').should('not.be.visible'); + cy.get('main-page').shadow().find('landing-page').should('exist'); + cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > h2').should('have.text', 'Welcome'); + cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > p').find('a').should('exist').and('have.prop', 'href', 'https://zone.pages.cloud.statcan.ca/docs/en/'); + cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #emailDisplay').find('span').should('exist').and('have.text', 'user.name1@statcan.gc.ca'); + cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #namespaceDisplay').find('span').should('exist').and('have.text', 'user-name1'); + }); + // If the email is cloud statcan (or any not statcan.gc.ca) expect to see error with logout it('should show wrong email page', ()=>{ cy.intercept('GET', `/api/workgroup/exists`, { diff --git a/components/centraldashboard/public/components/landing-page.js b/components/centraldashboard/public/components/landing-page.js index 0623c1f249e..fb99642e261 100644 --- a/components/centraldashboard/public/components/landing-page.js +++ b/components/centraldashboard/public/components/landing-page.js @@ -45,7 +45,6 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities errorDetail: {type: String, value: ''}, flowComplete: {type: Boolean, value: false}, loading: {type: Boolean, value: false}, - showAPIText: {type: Boolean, value: false}, isStatcanEmail: {type: Boolean, value: false}, }; } @@ -67,41 +66,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities ns = ns .replace(/[^\w]|\./g, '-') .replace(/^-+|-+$|_/g, '') - .replace(/[0-9]/g, '') .toLowerCase(); - - this.getNamespaces(ns); - } - - async getNamespaces(ns) { - await fetch( - `/api/namespaces/`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - }, - } - ) - .then((res) => res.json()) - .then((data) => { - const namespaceNames = []; - data.forEach((element) => { - namespaceNames.push(element.metadata.name); - }); - let counter = 1; - // Remove any numbers at the end - const originalNs = ns.replace(/\d+/g, ''); - if (namespaceNames.includes(originalNs)) { - while (namespaceNames.includes(originalNs + counter)) { - counter++; - } - ns = originalNs + counter; - } - this.namespaceName = ns; - }).catch((e)=> { - this.showError('landingPage.errGeneral'); - this.errorDetail= e; - }); + this.namespaceName = ns; } logout() { @@ -119,10 +85,9 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities async handleMakeNamespace() { /* - * Poll for profile over a span of 20 seconds (every 300ms) - * Waits for the new profile to be available - * if still not there, let the user click next again! - */ + * Poll for profile over a span of 20 seconds (every 300ms* max 66 times) + * Waits for the new profile to be available + */ const success = await this.pollProfile(66, 300); if (success) this._successSetup();