Skip to content

Commit

Permalink
Use email exact text as username
Browse files Browse the repository at this point in the history
  • Loading branch information
wg102 committed Jun 6, 2024
1 parent d166e75 commit f90d42d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 39 deletions.
20 changes: 20 additions & 0 deletions components/centraldashboard/cypress/e2e/landing-page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":"[email protected]",
"email": "[email protected]",
"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', '[email protected]');
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`, {
Expand Down
43 changes: 4 additions & 39 deletions components/centraldashboard/public/components/landing-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
}
Expand All @@ -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() {
Expand All @@ -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();

Expand Down

0 comments on commit f90d42d

Please sign in to comment.