Adds fake login to tests made on the web

This commit is contained in:
mateuswetah 2022-06-30 09:58:45 -03:00
parent a27deaa190
commit 39ed50760c
2 changed files with 30 additions and 15 deletions

View File

@ -36,6 +36,13 @@
:icon="arrowForwardOutline" :icon="arrowForwardOutline"
></ion-icon> ></ion-icon>
</ion-button> </ion-button>
<ion-button @click="fakeLogin" color="danger" fill="clear">
Testes sem login
<ion-icon
slot="end"
:icon="arrowForwardOutline"
></ion-icon>
</ion-button>
</form> </form>
</ion-col> </ion-col>
</ion-row> </ion-row>
@ -136,6 +143,14 @@ export default {
} }
} }
}, },
fakeLogin() {
this.wpStore.login(
'https://rcteste.tainacan.org',
'',
''
);
this.$router.push("/home");
}
}, },
}; };
</script> </script>

View File

@ -26,7 +26,7 @@ const useTainacanStore = defineStore("tainacan", {
const wpStore = useWpStore(); const wpStore = useWpStore();
let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collections?`; let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collections?`;
const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null;
if (params && params.perPage) if (params && params.perPage)
endpoint += '&perpage=' + params.perPage; endpoint += '&perpage=' + params.perPage;
@ -34,11 +34,11 @@ const useTainacanStore = defineStore("tainacan", {
if (params && params.orderBy) if (params && params.orderBy)
endpoint += '&orderby=' + params.orderBy; endpoint += '&orderby=' + params.orderBy;
const response = await axios.get(endpoint, { const response = await axios.get(endpoint, authorization ? {
headers: { headers: {
authorization: authorization authorization: authorization
} }
}); } : {});
this.collections = response.data; this.collections = response.data;
this.totalCollections = response.headers['x-wp-total']; this.totalCollections = response.headers['x-wp-total'];
@ -57,13 +57,13 @@ const useTainacanStore = defineStore("tainacan", {
const wpStore = useWpStore(); const wpStore = useWpStore();
const endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collections?perpage=4&orderby=modified`; const endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collections?perpage=4&orderby=modified`;
const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null;
const response = await axios.get(endpoint, { const response = await axios.get(endpoint, authorization ? {
headers: { headers: {
authorization: authorization authorization: authorization
} }
}); } : {});
this.homeCollections = response.data; this.homeCollections = response.data;
this.totalHomeCollections = response.headers['x-wp-total']; this.totalHomeCollections = response.headers['x-wp-total'];
@ -82,7 +82,7 @@ const useTainacanStore = defineStore("tainacan", {
const wpStore = useWpStore(); const wpStore = useWpStore();
let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collection/${collectionId}/items?fetch_only=id,title,thumbnail`; let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/collection/${collectionId}/items?fetch_only=id,title,thumbnail`;
const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null;
if (params && params.perPage) if (params && params.perPage)
endpoint += '&perpage=' + params.perPage; endpoint += '&perpage=' + params.perPage;
@ -104,11 +104,11 @@ const useTainacanStore = defineStore("tainacan", {
endpoint += '&paged=' + this.nextItemsByCollectionPage; endpoint += '&paged=' + this.nextItemsByCollectionPage;
const response = await axios.get(endpoint, { const response = await axios.get(endpoint, authorization ? {
headers: { headers: {
authorization: authorization authorization: authorization
} }
}); } : {});
this.collectionItems.push(...response.data.items); this.collectionItems.push(...response.data.items);
this.totalCollectionItems = response.headers['x-wp-total']; this.totalCollectionItems = response.headers['x-wp-total'];
@ -132,13 +132,13 @@ const useTainacanStore = defineStore("tainacan", {
const wpStore = useWpStore(); const wpStore = useWpStore();
const endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/items?fetch_only=id,title,thumbnail&perpage=12&orderby=modified`; const endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/items?fetch_only=id,title,thumbnail&perpage=12&orderby=modified`;
const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null;
const response = await axios.get(endpoint, { const response = await axios.get(endpoint, authorization ? {
headers: { headers: {
authorization: authorization authorization: authorization
} }
}); } : {});
this.homeItems = response.data.items; this.homeItems = response.data.items;
this.totalHomeItems = response.headers['x-wp-total']; this.totalHomeItems = response.headers['x-wp-total'];
@ -156,7 +156,7 @@ const useTainacanStore = defineStore("tainacan", {
const wpStore = useWpStore(); const wpStore = useWpStore();
let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/items?fetch_only=id,title,thumbnail`; let endpoint = `${wpStore.userSiteUrl}/wp-json/tainacan/v2/items?fetch_only=id,title,thumbnail`;
const authorization = 'Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken); const authorization = (wpStore.userLogin && wpStore.userToken) ? ('Basic ' + btoa(wpStore.userLogin + ':' + wpStore.userToken)) : null;
if (params && params.perPage) if (params && params.perPage)
endpoint += '&perpage=' + params.perPage; endpoint += '&perpage=' + params.perPage;
@ -174,11 +174,11 @@ const useTainacanStore = defineStore("tainacan", {
endpoint += '&paged=' + this.nextItemsPage; endpoint += '&paged=' + this.nextItemsPage;
const response = await axios.get(endpoint, { const response = await axios.get(endpoint, authorization ? {
headers: { headers: {
authorization: authorization authorization: authorization
} }
}); } : {});
this.items.push(...response.data.items); this.items.push(...response.data.items);
this.totalItems = response.headers['x-wp-total']; this.totalItems = response.headers['x-wp-total'];